18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 18:56:49 +01:00

refactor(physics): TMoverParameters becomes physics::Vehicle, the mover is gone

The physics of a vehicle loses the name it had from the Pascal of 2001. Done by
tools/rename/mover_to_physics.py, committed with it:

  physics/mover.h                  physics/vehicle.h
  TMoverParameters                 physics::Vehicle (in namespace physics)
  TDynamicObject::MoverParameters  physics
  mvOccupied, mvControlled         occupied, controlled (TTrain, TController)
  mvSecond, mvThird                secondUnit, thirdUnit
  mvPantographUnit                 pantographUnit
  mover, Mover, movers             physics, Physics, vehicles (locals, params)
  m_mover, othermover, currentMover, from_movers, renderMoverEventSounds
                                   m_physics, otherPhysics, currentPhysics,
                                   from_vehicles, renderPhysicsEventSounds

The code and the comments are renamed, the string literals are not: no text
the game shows, logs or looks up has changed (none had the names). The movers
of the editor, the tracks a slide moves, keep their name.

By hand: two member functions of TDynamicObject (gather_off_track_terrain,
begin_off_track) had a local mover aliasing their own MoverParameters, which
the rename made physics { *physics }; the alias is gone, they use physics->.
No other function has a renamed local meeting a renamed member (checked over
all the functions of the code before the rename).

For the branches made before it: run the script on the branch (python
tools/rename/mover_to_physics.py, from the root of the repository) before
merging it with this one, and the names don't conflict. It can be run again;
the second time it changes nothing.

The class is the same as it was; breaking it into its parts (braking,
electrics, controls, load) and making its data private are the next stages.

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
This commit is contained in:
2026-11-28 23:56:46 +01:00
parent 9568dba9e4
commit d0387753f8
207 changed files with 5147 additions and 4950 deletions
+22 -22
View File
@@ -15,40 +15,40 @@ void mark(trace *Trace, std::string const &Event) {
}
}
bool is_powered(TMoverParameters const &Vehicle) {
bool is_powered(physics::Vehicle const &Vehicle) {
using enum TEngineType;
auto const type{Vehicle.EngineType};
return Vehicle.Power > 1.0 && (type == ElectricSeriesMotor || type == ElectricInductionMotor || type == DieselEngine || type == DieselElectric);
}
driven driving(vehicle &Vehicle) {
return {Vehicle.mover(), Vehicle.mover(), Vehicle.mover(), [&Vehicle](double Seconds, track const &Track) { Vehicle.run(Seconds, Track); }};
return {Vehicle.physics(), Vehicle.physics(), Vehicle.physics(), [&Vehicle](double Seconds, track const &Track) { Vehicle.run(Seconds, Track); }};
}
driven driving(consist &Consist) {
// the AI's mvControlling and mvPantographUnit: the first vehicle with an engine, and with pantographs
auto *controlling{&Consist[0].mover()};
auto *pantographs{&Consist[0].mover()};
// the AI's mvControlling and pantographUnit: the first vehicle with an engine, and with pantographs
auto *controlling{&Consist[0].physics()};
auto *pantographs{&Consist[0].physics()};
for (auto i = Consist.size(); i-- > 0;) {
auto &mover{Consist[i].mover()};
if (is_powered(mover)) {
controlling = &mover;
auto &physics{Consist[i].physics()};
if (is_powered(physics)) {
controlling = &physics;
}
if (mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector && mover.EnginePowerSource.CollectorParameters.CollectorsNo > 0) {
pantographs = &mover;
if (physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector && physics.EnginePowerSource.CollectorParameters.CollectorsNo > 0) {
pantographs = &physics;
}
}
return {Consist[0].mover(), *controlling, *pantographs, [&Consist](double Seconds, track const &Track) { Consist.run(Seconds, Track); }};
return {Consist[0].physics(), *controlling, *pantographs, [&Consist](double Seconds, track const &Track) { Consist.run(Seconds, Track); }};
}
namespace {
void attend(TMoverParameters &Mover) {
if (Mover.SecuritySystem.is_cabsignal_blinking() && Mover.SecuritySystem.has_separate_acknowledge()) {
Mover.SecuritySystem.cabsignal_reset();
void attend(physics::Vehicle &Physics) {
if (Physics.SecuritySystem.is_cabsignal_blinking() && Physics.SecuritySystem.has_separate_acknowledge()) {
Physics.SecuritySystem.cabsignal_reset();
}
if (Mover.SecuritySystem.is_blinking()) {
Mover.SecuritySystemReset();
if (Physics.SecuritySystem.is_blinking()) {
Physics.SecuritySystemReset();
}
}
@@ -62,7 +62,7 @@ void drive(driven Driven, track const &Track, double Seconds) {
}
}
void release_brakes(TMoverParameters &Cab) {
void release_brakes(physics::Vehicle &Cab) {
Cab.BrakeLevelSet(Cab.Handle->GetPos(bh_RP));
Cab.DecLocalBrakeLevel(LocalBrakePosNo);
Cab.DecManualBrakeLevel(ManualBrakePosNo);
@@ -85,12 +85,12 @@ void release_brakes(TMoverParameters &Cab) {
}
bool is_ready(driven const &Driven) {
auto const &mover{Driven.controlling};
auto const air{mover.VeselVolume <= 0.0 || mover.ScndPipePress >= 4.5};
auto const &physics{Driven.controlling};
auto const air{physics.VeselVolume <= 0.0 || physics.ScndPipePress >= 4.5};
// the converter feeds the 110 V circuits (the electrodynamic brake's control among them); the AI switches
// it on once the line breaker is closed, so a train already charged with air isn't ready before it runs
auto const converter{mover.ConverterStart != start_t::manual || mover.ConverterFlag};
return mover.Mains && air && converter;
auto const converter{physics.ConverterStart != start_t::manual || physics.ConverterFlag};
return physics.Mains && air && converter;
}
namespace {
@@ -140,7 +140,7 @@ void close_line_breaker(driven const &Driven) {
// the converter, the compressor and the motor blowers, once the line breaker is closed; and the switch of the
// field shunting of a diesel-electric that has one (AutoRelay=Optional with FieldShuntSwitch=Yes), as the AI does
void switch_auxiliaries_on(TMoverParameters &Cab) {
void switch_auxiliaries_on(physics::Vehicle &Cab) {
Cab.ConverterSwitch(true);
Cab.CompressorSwitch(true);
for (auto const side : VehicleEnds) {