18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 17:37: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
+48 -48
View File
@@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/.
// reading the vehicle definition (.fiz): the sections and their keywords
#include "stdafx.h"
#include "physics/mover.h"
#include "physics/vehicle.h"
#include "vehicle/DynObj.h"
#include "physics/oerlikonest.h"
#include "utilities/Globals.h"
@@ -54,7 +54,7 @@ int s2NNW(std::string s)
return NNW;
}
void TMoverParameters::LoadFIZ_Param(std::string const &line)
void physics::Vehicle::LoadFIZ_Param(std::string const &line)
{
extract_value(Mass, "M", line, "0");
@@ -106,7 +106,7 @@ void TMoverParameters::LoadFIZ_Param(std::string const &line)
}
}
void TMoverParameters::LoadFIZ_Load(std::string const &line)
void physics::Vehicle::LoadFIZ_Load(std::string const &line)
{
auto const acceptedloads{Split(extract_value("LoadAccepted", line), ',')};
@@ -138,7 +138,7 @@ void TMoverParameters::LoadFIZ_Load(std::string const &line)
extract_value(UnLoadSpeed, "UnLoadSpeed", line, "");
}
void TMoverParameters::LoadFIZ_Headlights(std::string const &line)
void physics::Vehicle::LoadFIZ_Headlights(std::string const &line)
{
extract_value(refR, "LampRed", line, "");
extract_value(refG, "LampGreen", line, "");
@@ -150,7 +150,7 @@ void TMoverParameters::LoadFIZ_Headlights(std::string const &line)
extract_value(highMultiplier, "HighBeamMultiplier", line, "");
}
void TMoverParameters::LoadFIZ_Dimensions(std::string const &line)
void physics::Vehicle::LoadFIZ_Dimensions(std::string const &line)
{
extract_value(Dim.L, "L", line, "");
@@ -173,7 +173,7 @@ void TMoverParameters::LoadFIZ_Dimensions(std::string const &line)
extract_value(Floor, "Floor", line, "");
}
void TMoverParameters::LoadFIZ_Wheels(std::string const &line)
void physics::Vehicle::LoadFIZ_Wheels(std::string const &line)
{
extract_value(WheelDiameter, "D", line, "");
@@ -206,7 +206,7 @@ void TMoverParameters::LoadFIZ_Wheels(std::string const &line)
}
}
void TMoverParameters::LoadFIZ_Brake(std::string const &line)
void physics::Vehicle::LoadFIZ_Brake(std::string const &line)
{
extract_value(BrakeValveParams, "BrakeValve", line, "");
@@ -353,7 +353,7 @@ void TMoverParameters::LoadFIZ_Brake(std::string const &line)
}
}
void TMoverParameters::LoadFIZ_Doors(std::string const &line)
void physics::Vehicle::LoadFIZ_Doors(std::string const &line)
{
std::map<std::string, control_t, std::less<>> doorcontrols{
@@ -552,7 +552,7 @@ collision::end_definition collision_definition(std::string const &Line)
} // namespace
void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Index)
void physics::Vehicle::LoadFIZ_BuffCoupl(std::string const &line, int const Index)
{
TCoupling *thiscoupler;
@@ -669,13 +669,13 @@ void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Inde
}
}
void TMoverParameters::LoadFIZ_TurboPos(std::string const &Input)
void physics::Vehicle::LoadFIZ_TurboPos(std::string const &Input)
{
extract_value(TurboTest, "TurboPos", Input, "");
}
void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
void physics::Vehicle::LoadFIZ_Cntrl(std::string const &line)
{
LoadFIZ_CntrlBrakes(line);
@@ -684,7 +684,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
}
// Cntrl.: the brake system, the handles, the brake delays and the local and manual brakes
void TMoverParameters::LoadFIZ_CntrlBrakes(std::string const &line)
void physics::Vehicle::LoadFIZ_CntrlBrakes(std::string const &line)
{
{
using enum TBrakeSystem;
@@ -709,7 +709,7 @@ void TMoverParameters::LoadFIZ_CntrlBrakes(std::string const &line)
}
// Cntrl.: of a vehicle with a train brake, its positions, delays, modes, handles, load weighing and anti-slip brake
void TMoverParameters::LoadFIZ_CntrlTrainBrake(std::string const &line)
void physics::Vehicle::LoadFIZ_CntrlTrainBrake(std::string const &line)
{
using enum TBrakeHandle;
@@ -777,7 +777,7 @@ void TMoverParameters::LoadFIZ_CntrlTrainBrake(std::string const &line)
}
// Cntrl.: the kind of the anti-slip brake, by hand or automatic only for a vehicle with a brake handle
void TMoverParameters::LoadFIZ_CntrlAntiSlipBrake(std::string_view const asb)
void physics::Vehicle::LoadFIZ_CntrlAntiSlipBrake(std::string_view const asb)
{
if (asb == "yes")
{
@@ -794,7 +794,7 @@ void TMoverParameters::LoadFIZ_CntrlAntiSlipBrake(std::string_view const asb)
}
// Cntrl.: the controllers, their delays, the cab and the switches of the driver's desk
void TMoverParameters::LoadFIZ_CntrlControllers(std::string const &line)
void physics::Vehicle::LoadFIZ_CntrlControllers(std::string const &line)
{
// maksymalna predkosc dostepna na tarczce predkosciomierza
extract_value(maxTachoSpeed, "MaxTachoSpeed", line, "");
@@ -901,7 +901,7 @@ void TMoverParameters::LoadFIZ_CntrlControllers(std::string const &line)
}
// Cntrl.: how the devices start (MainStart, BatteryStart, ...) and their relays
void TMoverParameters::LoadFIZ_CntrlStarts(std::string const &line)
void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line)
{
using enum start_t;
std::map<std::string, start_t, std::less<>> starts{{"Disabled", disabled}, {"Manual", manual}, {"Automatic", automatic}, {"Mixed", manualwithautofallback},
@@ -1017,7 +1017,7 @@ void TMoverParameters::LoadFIZ_CntrlStarts(std::string const &line)
}
}
void TMoverParameters::LoadFIZ_Blending(std::string const &line)
void physics::Vehicle::LoadFIZ_Blending(std::string const &line)
{
extract_value(MED_Vmax, "MED_Vmax", line, std::to_string(Vmax));
@@ -1032,7 +1032,7 @@ void TMoverParameters::LoadFIZ_Blending(std::string const &line)
extract_value(MED_ED_Delay2, "MED_ScndDelayED", line, "");
}
void TMoverParameters::LoadFIZ_DCEMUED(std::string const &line)
void physics::Vehicle::LoadFIZ_DCEMUED(std::string const &line)
{
extract_value(DCEMUED_CC, "CouplerCheck", line, "0");
@@ -1041,7 +1041,7 @@ void TMoverParameters::LoadFIZ_DCEMUED(std::string const &line)
extract_value(DCEMUED_EP_delay, "EP_delay", line, "0");
}
void TMoverParameters::LoadFIZ_SpringBrake(std::string const &line)
void physics::Vehicle::LoadFIZ_SpringBrake(std::string const &line)
{
double vol{1.0};
@@ -1065,7 +1065,7 @@ void TMoverParameters::LoadFIZ_SpringBrake(std::string const &line)
SpringBrake.IsReady = true;
}
void TMoverParameters::LoadFIZ_Light(std::string const &line)
void physics::Vehicle::LoadFIZ_Light(std::string const &line)
{
LightPowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("Light", line));
@@ -1079,7 +1079,7 @@ void TMoverParameters::LoadFIZ_Light(std::string const &line)
NominalBatteryVoltage = static_cast<float>(BatteryVoltage);
}
void TMoverParameters::LoadFIZ_Clima(std::string const &line)
void physics::Vehicle::LoadFIZ_Clima(std::string const &line)
{
HeatingPowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("Heating", line));
@@ -1088,7 +1088,7 @@ void TMoverParameters::LoadFIZ_Clima(std::string const &line)
LoadFIZ_PowerParamsDecode(AlterHeatPowerSource, "AlterH", line);
}
void TMoverParameters::LoadFIZ_Power(std::string const &Line)
void physics::Vehicle::LoadFIZ_Power(std::string const &Line)
{
EnginePowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("EnginePower", Line));
@@ -1115,7 +1115,7 @@ void TMoverParameters::LoadFIZ_Power(std::string const &Line)
}
// the genset of a dual-mode vehicle (eu07/maszyna#536), on the Power: line; all optional, no genset without GensetPower
void TMoverParameters::LoadFIZ_Genset(std::string const &Line)
void physics::Vehicle::LoadFIZ_Genset(std::string const &Line)
{
extract_value(Genset.power, "GensetPower", Line, "");
if (false == Genset.fitted())
@@ -1139,7 +1139,7 @@ void TMoverParameters::LoadFIZ_Genset(std::string const &Line)
Genset.traction_share = std::clamp(Genset.traction_share, 0.0, 1.0);
}
void TMoverParameters::LoadFIZ_SpeedControl(std::string const &Line)
void physics::Vehicle::LoadFIZ_SpeedControl(std::string const &Line)
{
// speed control
extract_value(SpeedCtrl, "SpeedCtrl", Line, "");
@@ -1178,7 +1178,7 @@ void TMoverParameters::LoadFIZ_SpeedControl(std::string const &Line)
extract_value(SpeedCtrlUnit.PowerDownSpeed, "PowerDownSpeed", Line, "");
}
void TMoverParameters::LoadFIZ_Engine(std::string const &Input)
void physics::Vehicle::LoadFIZ_Engine(std::string const &Input)
{
EngineType = LoadFIZ_EngineDecode(extract_value("EngineType", Input));
@@ -1267,7 +1267,7 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input)
}
// Engine: of a diesel engine, its revolutions, gears, hydraulic transmission and retarder
void TMoverParameters::LoadFIZ_EngineDiesel(std::string const &Input)
void physics::Vehicle::LoadFIZ_EngineDiesel(std::string const &Input)
{
extract_value(diesel.minRevolutions, "nmin", Input, "");
@@ -1347,7 +1347,7 @@ void TMoverParameters::LoadFIZ_EngineDiesel(std::string const &Input)
}
// Engine: of a diesel-electric
void TMoverParameters::LoadFIZ_EngineDieselElectric(std::string const &Input)
void physics::Vehicle::LoadFIZ_EngineDieselElectric(std::string const &Input)
{
extract_value(Ftmax, "Ftmax", Input, "");
@@ -1374,7 +1374,7 @@ void TMoverParameters::LoadFIZ_EngineDieselElectric(std::string const &Input)
}
// Engine: of an induction motor drive
void TMoverParameters::LoadFIZ_EngineInductionMotor(std::string const &Input)
void physics::Vehicle::LoadFIZ_EngineInductionMotor(std::string const &Input)
{
RVentnmax = 1.0;
@@ -1426,7 +1426,7 @@ void TMoverParameters::LoadFIZ_EngineInductionMotor(std::string const &Input)
}
// Engine: what both kinds of diesels have, their heat among it
void TMoverParameters::LoadFIZ_EngineDieselShared(std::string const &Input)
void physics::Vehicle::LoadFIZ_EngineDieselShared(std::string const &Input)
{
// oil pump
extract_value(OilPump.pressure_minimum, "OilMinPressure", Input, "");
@@ -1464,7 +1464,7 @@ void TMoverParameters::LoadFIZ_EngineDieselShared(std::string const &Input)
diesel.heat.powerfactor = 1235 / pf;
}
void TMoverParameters::LoadFIZ_Switches(std::string const &Input)
void physics::Vehicle::LoadFIZ_Switches(std::string const &Input)
{
extract_value(PantSwitchType, "Pantograph", Input, "");
@@ -1488,7 +1488,7 @@ void TMoverParameters::LoadFIZ_Switches(std::string const &Input)
}
}
void TMoverParameters::LoadFIZ_MotorParamTable(std::string const &Input)
void physics::Vehicle::LoadFIZ_MotorParamTable(std::string const &Input)
{
switch (EngineType)
@@ -1510,7 +1510,7 @@ void TMoverParameters::LoadFIZ_MotorParamTable(std::string const &Input)
}
}
void TMoverParameters::LoadFIZ_Circuit(std::string const &Input)
void physics::Vehicle::LoadFIZ_Circuit(std::string const &Input)
{
extract_value(CircuitRes, "CircuitRes", Input, "");
@@ -1530,7 +1530,7 @@ void TMoverParameters::LoadFIZ_Circuit(std::string const &Input)
extract_value(TUHEX_Stages, "TUHEX_Stages", Input, "0");
}
void TMoverParameters::LoadFIZ_AI(std::string const &Input)
void physics::Vehicle::LoadFIZ_AI(std::string const &Input)
{
extract_value(AIHintPantstate, "Pantstate", Input, "");
@@ -1539,7 +1539,7 @@ void TMoverParameters::LoadFIZ_AI(std::string const &Input)
extract_value(AIHintLocalBrakeAccFactor, "LocalBrakeAccFactor", Input, "");
}
void TMoverParameters::LoadFIZ_RList(std::string const &Input)
void physics::Vehicle::LoadFIZ_RList(std::string const &Input)
{
extract_value(RlistSize, "Size", Input, "");
@@ -1570,7 +1570,7 @@ void TMoverParameters::LoadFIZ_RList(std::string const &Input)
}
// the dynamic brake of a diesel-electric vehicle, from its Engine section: none without EDBrake
void TMoverParameters::LoadFIZ_DieselElectricDynamicBrake(std::string const &Input)
void physics::Vehicle::LoadFIZ_DieselElectricDynamicBrake(std::string const &Input)
{
using enum diesel_electric_dynamic_brake::control;
std::map<std::string, diesel_electric_dynamic_brake::control, std::less<>> const sources{{"Controller", controller}, {"Lever", lever}};
@@ -1598,7 +1598,7 @@ void TMoverParameters::LoadFIZ_DieselElectricDynamicBrake(std::string const &Inp
}
}
void TMoverParameters::LoadFIZ_UCList(std::string const &Input)
void physics::Vehicle::LoadFIZ_UCList(std::string const &Input)
{
extract_value(UniCtrlListSize, "Size", Input, "");
@@ -1609,7 +1609,7 @@ void TMoverParameters::LoadFIZ_UCList(std::string const &Input)
UniCtrlValStep = std::max(UniCtrlValStep, 0.0);
}
void TMoverParameters::LoadFIZ_DList(std::string const &Input)
void physics::Vehicle::LoadFIZ_DList(std::string const &Input)
{
extract_value(diesel.maxMoment, "Mmax", Input, "");
@@ -1633,30 +1633,30 @@ void TMoverParameters::LoadFIZ_DList(std::string const &Input)
diesel.fuelConsumption = diesel.nominalFuelConsumptionRate * dizel_max_energy / fuel_density / diesel.maxRevolutions;
}
void TMoverParameters::LoadFIZ_FFList(std::string const &Input)
void physics::Vehicle::LoadFIZ_FFList(std::string const &Input)
{
extract_value(FFListSize, "Size", Input, "");
}
void TMoverParameters::LoadFIZ_FFEDList(std::string const &Input)
void physics::Vehicle::LoadFIZ_FFEDList(std::string const &Input)
{
extract_value(FFEDListSize, "Size", Input, "");
}
void TMoverParameters::LoadFIZ_WiperList(std::string const &Input)
void physics::Vehicle::LoadFIZ_WiperList(std::string const &Input)
{
extract_value(WiperListSize, "Size", Input, "");
extract_value(WiperAngle, "Angle", Input, "");
extract_value(WiperDefaultPos, "Default", Input, "");
}
void TMoverParameters::LoadFIZ_DimmerList(std::string const &Input)
void physics::Vehicle::LoadFIZ_DimmerList(std::string const &Input)
{
// extract_value(modernWpierListSize, "Size", Input, "");
extract_value(modernDimmerCanCycle, "Cycle", Input, "");
extract_value(modernDimmerDefaultPosition, "DefaultPos", Input, "");
}
void TMoverParameters::LoadFIZ_LightsList(std::string const &Input)
void physics::Vehicle::LoadFIZ_LightsList(std::string const &Input)
{
extract_value(LightsPosNo, "Size", Input, "");
@@ -1664,7 +1664,7 @@ void TMoverParameters::LoadFIZ_LightsList(std::string const &Input)
extract_value(LightsDefPos, "Default", Input, "");
}
void TMoverParameters::LoadFIZ_CompressorList(std::string const &Input)
void physics::Vehicle::LoadFIZ_CompressorList(std::string const &Input)
{
extract_value(CompressorListPosNo, "Size", Input, "");
@@ -1672,7 +1672,7 @@ void TMoverParameters::LoadFIZ_CompressorList(std::string const &Input)
extract_value(CompressorListDefPos, "Default", Input, "");
}
void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const &Prefix, std::string const &Line)
void physics::Vehicle::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const &Prefix, std::string const &Line)
{
switch (Powerparameters.SourceType)
@@ -1693,7 +1693,7 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparamete
}
case TPowerSource::Generator:
{
// prime mover for the generator
// prime physics for the generator
auto &generatorparameters{Powerparameters.EngineGenerator};
if (auto const enginetype{LoadFIZ_EngineDecode(extract_value(Prefix + "GeneratorEngine", Line))}; enginetype == TEngineType::Main)
@@ -1792,7 +1792,7 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparamete
}
}
TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Powertype) const
TPowerType physics::Vehicle::LoadFIZ_PowerDecode(std::string const &Powertype) const
{
using enum TPowerType;
@@ -1802,7 +1802,7 @@ TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Powertype) c
return lookup != powertypes.end() ? lookup->second : NoPower;
}
TPowerSource TMoverParameters::LoadFIZ_SourceDecode(std::string const &Source) const
TPowerSource physics::Vehicle::LoadFIZ_SourceDecode(std::string const &Source) const
{
using enum TPowerSource;
@@ -1815,7 +1815,7 @@ TPowerSource TMoverParameters::LoadFIZ_SourceDecode(std::string const &Source) c
return lookup != powersources.end() ? lookup->second : NotDefined;
}
TEngineType TMoverParameters::LoadFIZ_EngineDecode(std::string const &Engine) const
TEngineType physics::Vehicle::LoadFIZ_EngineDecode(std::string const &Engine) const
{
using enum TEngineType;