18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 08:17:09 +01:00

fix: the derailment notice builds on the layout of #531: physics/derailment.h, TDynamicObject::physics

This commit is contained in:
jerrrrycho
2026-11-29 15:57:26 +01:00
parent c1d1f1aead
commit efde2157eb
3 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -13,7 +13,7 @@ http://mozilla.org/MPL/2.0/.
#include "simulation/simulation.h"
#include "simulation/simulationtime.h"
#include "input/command.h"
#include "McZapkie/derailment.h"
#include "physics/derailment.h"
#include "vehicle/Driver.h"
#include "vehicle/DynObj.h"
#include "vehicle/Train.h"
@@ -616,11 +616,11 @@ void blackbox_recorder::write_derailed(TDynamicObject const *Vehicle, derailment
state.time = m_time;
state.vehicle = vehicle_id(Vehicle);
state.phase = blackbox::derailment_phases::derailed;
state.cause = cause_of(Notice.why, Vehicle->MoverParameters->Derailed);
state.cause = cause_of(Notice.why, Vehicle->physics->Derailed);
state.position = Vehicle->GetPosition();
state.heading = static_cast<float>(std::atan2(Vehicle->VectorFront().x, Vehicle->VectorFront().z));
// as it derailed, along its front as it moves now
state.speed_kmh = static_cast<float>(std::copysign(Notice.velocity, Vehicle->MoverParameters->V));
state.speed_kmh = static_cast<float>(std::copysign(Notice.velocity, Vehicle->physics->V));
state.reason = static_cast<std::uint8_t>(Notice.why);
state.track = text_of(Notice.track);
m_writer->derailment(state);
+2 -2
View File
@@ -11,7 +11,7 @@ http://mozilla.org/MPL/2.0/.
#include "simulation/simulationtest.h"
#include "application/application.h"
#include "McZapkie/derailment.h"
#include "physics/derailment.h"
#include "scene/scene.h"
#include "simulation/simulation.h"
#include "utilities/Globals.h"
@@ -210,7 +210,7 @@ bool test_manager::tested(TDynamicObject const &Vehicle) const
return true;
return std::ranges::any_of(Global.test.vehicles, [&Vehicle](std::string const &Name) {
auto *vehicle { simulation::Vehicles.find(Name) };
return vehicle != nullptr && vehicle->find_vehicle(coupling::coupler, [&Vehicle](TDynamicObject const *Other) { return Other == &Vehicle; }) != nullptr;
return vehicle != nullptr && vehicle->find_vehicle(Coupling::coupler, [&Vehicle](TDynamicObject const *Other) { return Other == &Vehicle; }) != nullptr;
});
}
+1 -1
View File
@@ -353,7 +353,7 @@ struct derailment_state {
float roll{0.0f}; // [rad] of its body against the level, to the left positive; 90 degrees on its side
float travelled{0.0f}; // [m] on the ground since it left the rails
bool lying{false}; // on its side
std::uint8_t reason{0}; // what derailed it, finer: the code of derailment::reason (McZapkie/derailment.h), 0 not known
std::uint8_t reason{0}; // what derailed it, finer: the code of derailment::reason (physics/derailment.h), 0 not known
std::string track; // name of the track it derailed on, empty for a track without one
};