18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 08:17:09 +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
+35 -35
View File
@@ -19,7 +19,7 @@ http://mozilla.org/MPL/2.0/.
#include "vehicle/Driver.h"
#include "world/mtable.h"
#include "utilities/Logs.h"
#include "physics/mover.h"
#include "physics/vehicle.h"
#ifdef _WIN32
extern "C"
@@ -188,7 +188,7 @@ OnCommandGet(multiplayer::DaneRozkaz const *pRozkaz)
d->Damage( pRozkaz->cString[ 0 ] );
d = d->Prev(); // w drugą stronę też
}
WyslijUszkodzenia( lookup->asName, static_cast<char>(lookup->MoverParameters->EngDmgFlag) ); // zwrot informacji o pojeździe
WyslijUszkodzenia( lookup->asName, static_cast<char>(lookup->physics->EngDmgFlag) ); // zwrot informacji o pojeździe
}
break;
default:
@@ -273,40 +273,40 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle)
size_t j = Vehicle->asName.length();
r.iPar[0] = i; // ilość danych liczbowych
r.fPar[1] = Global.fTimeAngleDeg / 360.0; // aktualny czas (1.0=doba)
r.fPar[2] = Vehicle->MoverParameters->Loc.X; // pozycja X
r.fPar[3] = Vehicle->MoverParameters->Loc.Y; // pozycja Y
r.fPar[4] = Vehicle->MoverParameters->Loc.Z; // pozycja Z
r.fPar[5] = Vehicle->MoverParameters->V; // prędkość ruchu X
r.fPar[6] = Vehicle->MoverParameters->nrot * M_PI *
Vehicle->MoverParameters->WheelDiameter; // prędkość obrotowa kóŁ
r.fPar[2] = Vehicle->physics->Loc.X; // pozycja X
r.fPar[3] = Vehicle->physics->Loc.Y; // pozycja Y
r.fPar[4] = Vehicle->physics->Loc.Z; // pozycja Z
r.fPar[5] = Vehicle->physics->V; // prędkość ruchu X
r.fPar[6] = Vehicle->physics->nrot * M_PI *
Vehicle->physics->WheelDiameter; // prędkość obrotowa kóŁ
r.fPar[7] = 0; // prędkość ruchu Z
r.fPar[8] = Vehicle->MoverParameters->AccS; // przyspieszenie X
r.fPar[9] = Vehicle->MoverParameters->AccN; // przyspieszenie Y //na razie nie
r.fPar[10] = Vehicle->MoverParameters->AccVert; // przyspieszenie Z
r.fPar[11] = Vehicle->MoverParameters->DistCounter; // przejechana odległość w km
r.fPar[12] = Vehicle->MoverParameters->PipePress; // ciśnienie w PG
r.fPar[13] = Vehicle->MoverParameters->ScndPipePress; // ciśnienie w PZ
r.fPar[14] = Vehicle->MoverParameters->BrakePress; // ciśnienie w CH
r.fPar[15] = Vehicle->MoverParameters->Compressor; // ciśnienie w ZG
r.fPar[16] = Vehicle->MoverParameters->Itot; // Prąd całkowity
r.iPar[17] = Vehicle->MoverParameters->MainCtrlPos; // Pozycja NJ
r.iPar[18] = Vehicle->MoverParameters->ScndCtrlPos; // Pozycja NB
r.iPar[19] = Vehicle->MoverParameters->MainCtrlActualPos; // Pozycja jezdna
r.iPar[20] = Vehicle->MoverParameters->ScndCtrlActualPos; // Pozycja bocznikowania
r.iPar[21] = Vehicle->MoverParameters->ScndCtrlActualPos; // Pozycja bocznikowania
r.iPar[22] = Vehicle->MoverParameters->ResistorsFlag * 1
+ Vehicle->MoverParameters->ConverterFlag * 2
+ Vehicle->MoverParameters->CompressorFlag * 4
+ Vehicle->MoverParameters->Mains * 8
r.fPar[8] = Vehicle->physics->AccS; // przyspieszenie X
r.fPar[9] = Vehicle->physics->AccN; // przyspieszenie Y //na razie nie
r.fPar[10] = Vehicle->physics->AccVert; // przyspieszenie Z
r.fPar[11] = Vehicle->physics->DistCounter; // przejechana odległość w km
r.fPar[12] = Vehicle->physics->PipePress; // ciśnienie w PG
r.fPar[13] = Vehicle->physics->ScndPipePress; // ciśnienie w PZ
r.fPar[14] = Vehicle->physics->BrakePress; // ciśnienie w CH
r.fPar[15] = Vehicle->physics->Compressor; // ciśnienie w ZG
r.fPar[16] = Vehicle->physics->Itot; // Prąd całkowity
r.iPar[17] = Vehicle->physics->MainCtrlPos; // Pozycja NJ
r.iPar[18] = Vehicle->physics->ScndCtrlPos; // Pozycja NB
r.iPar[19] = Vehicle->physics->MainCtrlActualPos; // Pozycja jezdna
r.iPar[20] = Vehicle->physics->ScndCtrlActualPos; // Pozycja bocznikowania
r.iPar[21] = Vehicle->physics->ScndCtrlActualPos; // Pozycja bocznikowania
r.iPar[22] = Vehicle->physics->ResistorsFlag * 1
+ Vehicle->physics->ConverterFlag * 2
+ Vehicle->physics->CompressorFlag * 4
+ Vehicle->physics->Mains * 8
#ifdef EU07_USEOLDDOORCODE
+ Vehicle->MoverParameters->DoorLeftOpened * 16
+ Vehicle->MoverParameters->DoorRightOpened * 32
+ Vehicle->physics->DoorLeftOpened * 16
+ Vehicle->physics->DoorRightOpened * 32
#else
+ ( false == Vehicle->MoverParameters->Doors.instances[VehicleSide::left].is_closed ) * 16
+ ( false == Vehicle->MoverParameters->Doors.instances[VehicleSide::right].is_closed ) * 32
+ ( false == Vehicle->physics->Doors.instances[VehicleSide::left].is_closed ) * 16
+ ( false == Vehicle->physics->Doors.instances[VehicleSide::right].is_closed ) * 32
#endif
+ Vehicle->MoverParameters->FuseFlag * 64
+ Vehicle->MoverParameters->DepartureSignal * 128;
+ Vehicle->physics->FuseFlag * 64
+ Vehicle->physics->DepartureSignal * 128;
// WriteLog("Zapisalem stare");
// WriteLog("Mam patykow "+IntToStr(t->DynamicObject->iAnimType[ANIM_PANTS]));
for (int p = 0; p < 4; p++)
@@ -326,10 +326,10 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle)
// WriteLog("Zapisalem pantografy");
for (int p = 0; p < 3; p++)
r.fPar[27 + p] =
Vehicle->MoverParameters->ShowCurrent(p + 1); // amperomierze kolejnych grup
Vehicle->physics->ShowCurrent(p + 1); // amperomierze kolejnych grup
// WriteLog("zapisalem prady");
r.iPar[30] = Vehicle->MoverParameters->WarningSignal; // trabienie
r.fPar[31] = Vehicle->MoverParameters->PantographVoltage; // napiecie WN
r.iPar[30] = Vehicle->physics->WarningSignal; // trabienie
r.fPar[31] = Vehicle->physics->PantographVoltage; // napiecie WN
// WriteLog("Parametry gotowe");
i <<= 2; // ilość bajtów
r.cString[i] = char(j); // na końcu nazwa, żeby jakoś zidentyfikować