mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 09:27:10 +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:
@@ -10,7 +10,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
// reading the vehicle definition (.fiz): the parser and its tables
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "physics/mover.h"
|
||||
#include "physics/vehicle.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#include "physics/oerlikonest.h"
|
||||
#include "utilities/Globals.h"
|
||||
@@ -75,7 +75,7 @@ static bool is_valid_mpt_index(int const Index)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readMPT0(std::string const &line)
|
||||
bool physics::Vehicle::readMPT0(std::string const &line)
|
||||
{
|
||||
|
||||
// TBD, TODO: split into separate functions similar to readMPT if more varied schemes appear?
|
||||
@@ -112,7 +112,7 @@ bool TMoverParameters::readMPT0(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readMPT(std::string const &line)
|
||||
bool physics::Vehicle::readMPT(std::string const &line)
|
||||
{
|
||||
|
||||
++LISTLINE;
|
||||
@@ -139,7 +139,7 @@ bool TMoverParameters::readMPT(std::string const &line)
|
||||
}
|
||||
}
|
||||
|
||||
bool TMoverParameters::readMPTElectricSeries(std::string const &line)
|
||||
bool physics::Vehicle::readMPTElectricSeries(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -168,7 +168,7 @@ bool TMoverParameters::readMPTElectricSeries(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readMPTDieselElectric(std::string const &line)
|
||||
bool physics::Vehicle::readMPTDieselElectric(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -188,7 +188,7 @@ bool TMoverParameters::readMPTDieselElectric(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readMPTDieselEngine(std::string const &line)
|
||||
bool physics::Vehicle::readMPTDieselEngine(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -217,7 +217,7 @@ bool TMoverParameters::readMPTDieselEngine(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readBPT(std::string const &line)
|
||||
bool physics::Vehicle::readBPT(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -248,7 +248,7 @@ bool TMoverParameters::readBPT(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readRList(std::string const &Input)
|
||||
bool physics::Vehicle::readRList(std::string const &Input)
|
||||
{
|
||||
|
||||
cParser parser(Input);
|
||||
@@ -278,7 +278,7 @@ bool TMoverParameters::readRList(std::string const &Input)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readUCList(std::string const &line)
|
||||
bool physics::Vehicle::readUCList(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -296,7 +296,7 @@ bool TMoverParameters::readUCList(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readDList(std::string const &line)
|
||||
bool physics::Vehicle::readDList(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -312,7 +312,7 @@ bool TMoverParameters::readDList(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readDMList(std::string const &line)
|
||||
bool physics::Vehicle::readDMList(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -332,7 +332,7 @@ bool TMoverParameters::readDMList(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readV2NMAXList(std::string const &line)
|
||||
bool physics::Vehicle::readV2NMAXList(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -352,7 +352,7 @@ bool TMoverParameters::readV2NMAXList(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readHTCList(std::string const &line)
|
||||
bool physics::Vehicle::readHTCList(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -372,7 +372,7 @@ bool TMoverParameters::readHTCList(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readPmaxList(std::string const &line)
|
||||
bool physics::Vehicle::readPmaxList(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -392,7 +392,7 @@ bool TMoverParameters::readPmaxList(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readFFList(std::string const &line)
|
||||
bool physics::Vehicle::readFFList(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -412,7 +412,7 @@ bool TMoverParameters::readFFList(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readFFEDList(std::string const &line)
|
||||
bool physics::Vehicle::readFFEDList(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -433,7 +433,7 @@ bool TMoverParameters::readFFEDList(std::string const &line)
|
||||
}
|
||||
|
||||
// parsowanie wiperList
|
||||
bool TMoverParameters::readWiperList(std::string const &line)
|
||||
bool physics::Vehicle::readWiperList(std::string const &line)
|
||||
{
|
||||
cParser parser(line);
|
||||
if (false == parser.getTokens(4, false))
|
||||
@@ -451,7 +451,7 @@ bool TMoverParameters::readWiperList(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readDimmerList(std::string const &line)
|
||||
bool physics::Vehicle::readDimmerList(std::string const &line)
|
||||
{
|
||||
cParser parser(line);
|
||||
if (false == parser.getTokens(3, false))
|
||||
@@ -468,7 +468,7 @@ bool TMoverParameters::readDimmerList(std::string const &line)
|
||||
}
|
||||
|
||||
// parsowanie WWList
|
||||
bool TMoverParameters::readWWList(std::string const &line)
|
||||
bool physics::Vehicle::readWWList(std::string const &line)
|
||||
{
|
||||
|
||||
cParser parser(line);
|
||||
@@ -496,7 +496,7 @@ bool TMoverParameters::readWWList(std::string const &line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readLightsList(std::string const &Input)
|
||||
bool physics::Vehicle::readLightsList(std::string const &Input)
|
||||
{
|
||||
|
||||
cParser parser(Input);
|
||||
@@ -530,7 +530,7 @@ bool TMoverParameters::readLightsList(std::string const &Input)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readCompressorList(std::string const &Input)
|
||||
bool physics::Vehicle::readCompressorList(std::string const &Input)
|
||||
{
|
||||
|
||||
cParser parser(Input);
|
||||
@@ -554,7 +554,7 @@ bool TMoverParameters::readCompressorList(std::string const &Input)
|
||||
// *************************************************************************************************
|
||||
// Q: 20160719
|
||||
// *************************************************************************************************
|
||||
void TMoverParameters::BrakeValveDecode(std::string const &Valve)
|
||||
void physics::Vehicle::BrakeValveDecode(std::string const &Valve)
|
||||
{
|
||||
using enum TBrakeValve;
|
||||
|
||||
@@ -599,7 +599,7 @@ void TMoverParameters::BrakeValveDecode(std::string const &Valve)
|
||||
// *************************************************************************************************
|
||||
// Q: 20160719
|
||||
// *************************************************************************************************
|
||||
void TMoverParameters::BrakeSubsystemDecode()
|
||||
void physics::Vehicle::BrakeSubsystemDecode()
|
||||
{
|
||||
using enum TBrakeSubSystem;
|
||||
BrakeSubsystem = ss_None;
|
||||
@@ -641,7 +641,7 @@ void TMoverParameters::BrakeSubsystemDecode()
|
||||
// TDynamicObject::Init()
|
||||
// Po niej wykonywana jest CreateBrakeSys(), ktora jest odpowiednikiem CheckLocomotiveParameters()
|
||||
// *************************************************************************************************
|
||||
bool TMoverParameters::LoadFIZ(std::string const &chkpath)
|
||||
bool physics::Vehicle::LoadFIZ(std::string const &chkpath)
|
||||
{
|
||||
chkPath = chkpath; // assign class path for reloading
|
||||
|
||||
@@ -668,14 +668,14 @@ bool TMoverParameters::LoadFIZ(std::string const &chkpath)
|
||||
}
|
||||
|
||||
// reads the vehicle definition from text in the .fiz format, e.g. one made up by a unit test
|
||||
bool TMoverParameters::LoadFIZ_Text(std::string const &Text)
|
||||
bool physics::Vehicle::LoadFIZ_Text(std::string const &Text)
|
||||
{
|
||||
ConversionError = 666;
|
||||
cParser fizparser(Text, cParser::buffer_TEXT);
|
||||
return LoadFIZ_Parse(fizparser);
|
||||
}
|
||||
|
||||
bool TMoverParameters::LoadFIZ_Parse(cParser &fizparser)
|
||||
bool physics::Vehicle::LoadFIZ_Parse(cParser &fizparser)
|
||||
{
|
||||
LISTLINE = 0;
|
||||
startBPT = false;
|
||||
@@ -764,7 +764,7 @@ bool TMoverParameters::LoadFIZ_Parse(cParser &fizparser)
|
||||
}
|
||||
|
||||
// the end of the table being read; returns whether the line is one
|
||||
bool TMoverParameters::LoadFIZ_TableEnd(std::string const &inputline) const
|
||||
bool physics::Vehicle::LoadFIZ_TableEnd(std::string const &inputline) const
|
||||
{
|
||||
// checking if table parsing should be switched off goes first...
|
||||
if (issection("END-MPT", inputline))
|
||||
@@ -859,7 +859,7 @@ bool TMoverParameters::LoadFIZ_TableEnd(std::string const &inputline) const
|
||||
}
|
||||
|
||||
// a section of the definition giving values, kept in fizlines by its name; returns whether the line is one
|
||||
bool TMoverParameters::LoadFIZ_Section(std::string const &inputline, std::map<std::string, std::string, std::less<>> &fizlines)
|
||||
bool physics::Vehicle::LoadFIZ_Section(std::string const &inputline, std::map<std::string, std::string, std::less<>> &fizlines)
|
||||
{
|
||||
// ...then all recognized sections...
|
||||
if (issection("Param.", inputline))
|
||||
@@ -1074,7 +1074,7 @@ bool TMoverParameters::LoadFIZ_Section(std::string const &inputline, std::map<st
|
||||
}
|
||||
|
||||
// a section of the definition opening a table, kept in fizlines by its name; returns whether the line is one
|
||||
bool TMoverParameters::LoadFIZ_TableSection(std::string const &inputline, std::map<std::string, std::string, std::less<>> &fizlines)
|
||||
bool physics::Vehicle::LoadFIZ_TableSection(std::string const &inputline, std::map<std::string, std::string, std::less<>> &fizlines)
|
||||
{
|
||||
if (issection("MotorParamTable:", inputline))
|
||||
{
|
||||
@@ -1231,7 +1231,7 @@ bool TMoverParameters::LoadFIZ_TableSection(std::string const &inputline, std::m
|
||||
}
|
||||
|
||||
// a row of the table being read
|
||||
void TMoverParameters::LoadFIZ_TableRow(std::string const &inputline)
|
||||
void physics::Vehicle::LoadFIZ_TableRow(std::string const &inputline)
|
||||
{
|
||||
// ...and finally, table parsers.
|
||||
// NOTE: once table parsing is enabled it lasts until switched off, when another section is recognized
|
||||
@@ -1321,7 +1321,7 @@ void TMoverParameters::LoadFIZ_TableRow(std::string const &inputline)
|
||||
}
|
||||
}
|
||||
|
||||
bool TMoverParameters::reload_FIZ()
|
||||
bool physics::Vehicle::reload_FIZ()
|
||||
{
|
||||
WriteLog("[DEV] Reloading FIZ for " + Name);
|
||||
// pause simulation
|
||||
|
||||
Reference in New Issue
Block a user