mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 06:12:41 +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/.
|
||||
// the commands passed between the vehicles of a train
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "physics/mover.h"
|
||||
#include "physics/vehicle.h"
|
||||
#include "vehicle/DynObj.h"
|
||||
#include "physics/oerlikonest.h"
|
||||
#include "utilities/Globals.h"
|
||||
@@ -34,7 +34,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
// Q: 20160714
|
||||
// Wstawia komendę z parametrem, od sprzęgu i w lokalizacji do pojazdu
|
||||
// *************************************************************************************************
|
||||
void TMoverParameters::PutCommand(std::string const &NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation)
|
||||
void physics::Vehicle::PutCommand(std::string const &NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation)
|
||||
{
|
||||
auto const parsed{ParseVehicleCommand(NewCommand)};
|
||||
CommandIn.Command = parsed.command;
|
||||
@@ -50,7 +50,7 @@ void TMoverParameters::PutCommand(std::string const &NewCommand, double NewValue
|
||||
// Q: 20160714
|
||||
// Ustawienie komendy wraz z parametrami
|
||||
// *************************************************************************************************
|
||||
bool TMoverParameters::SetInternalCommand(VehicleCommand const NewCommand, double NewValue1, double NewValue2, CouplingSet const Couplertype)
|
||||
bool physics::Vehicle::SetInternalCommand(VehicleCommand const NewCommand, double NewValue1, double NewValue2, CouplingSet const Couplertype)
|
||||
{
|
||||
bool SIC;
|
||||
if (CommandIn.Command == NewCommand && CommandIn.Argument.empty() && CommandIn.Value1 == NewValue1 && CommandIn.Value2 == NewValue2 && CommandIn.couplings == Couplertype)
|
||||
@@ -74,7 +74,7 @@ bool TMoverParameters::SetInternalCommand(VehicleCommand const NewCommand, doubl
|
||||
// Q: 20160714
|
||||
// wysyłanie komendy w kierunku dir (1=przód, -1=tył) do kolejnego pojazdu (jednego)
|
||||
// *************************************************************************************************
|
||||
bool TMoverParameters::SendCtrlToNext(VehicleCommand const CtrlCommand, double const ctrlvalue, double const dir, CouplingSet const Couplertype)
|
||||
bool physics::Vehicle::SendCtrlToNext(VehicleCommand const CtrlCommand, double const ctrlvalue, double const dir, CouplingSet const Couplertype)
|
||||
{
|
||||
bool OK;
|
||||
int d; // numer sprzęgu w kierunku którego wysyłamy
|
||||
@@ -114,7 +114,7 @@ bool TMoverParameters::SendCtrlToNext(VehicleCommand const CtrlCommand, double c
|
||||
// Komenda musi być zdefiniowana tutaj, a jeśli się wywołuje funkcję, to ona nie może
|
||||
// sama przesyłać do kolejnych pojazdów. Należy też się zastanowić, czy dla uzyskania
|
||||
// jakiejś zmiany (np. IncMainCtrl) lepiej wywołać funkcję, czy od razu wysłać komendę.
|
||||
bool TMoverParameters::RunCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, std::string_view const Argument)
|
||||
bool physics::Vehicle::RunCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, std::string_view const Argument)
|
||||
{
|
||||
// the group of the command sets OK; a command none of them knows isn't done
|
||||
if (bool OK{false}; RunControllerCommand(Command, CValue1, CValue2, Couplertype, OK) || RunRelaysCommand(Command, CValue1, CValue2, Couplertype, OK) ||
|
||||
@@ -134,7 +134,7 @@ bool TMoverParameters::RunCommand(VehicleCommand const Command, double CValue1,
|
||||
}
|
||||
|
||||
// RunCommand() for the controllers; returns whether the command is one of them
|
||||
bool TMoverParameters::RunControllerCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
bool physics::Vehicle::RunControllerCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::mainController)
|
||||
{
|
||||
@@ -183,7 +183,7 @@ bool TMoverParameters::RunControllerCommand(VehicleCommand const Command, double
|
||||
}
|
||||
|
||||
// RunCommand() for the direction, the automatic start and the current relays; returns whether the command is one of them
|
||||
bool TMoverParameters::RunRelaysCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
bool physics::Vehicle::RunRelaysCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::direction)
|
||||
{
|
||||
@@ -217,7 +217,7 @@ bool TMoverParameters::RunRelaysCommand(VehicleCommand const Command, double CVa
|
||||
}
|
||||
|
||||
// RunCommand() for the cab and the speed control; returns whether the command is one of them
|
||||
bool TMoverParameters::RunCabCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
bool physics::Vehicle::RunCabCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::cabActivation)
|
||||
{
|
||||
@@ -268,7 +268,7 @@ bool TMoverParameters::RunCabCommand(VehicleCommand const Command, double CValue
|
||||
}
|
||||
|
||||
// RunCommand() for the train brake, the releaser and the emergency brake; returns whether the command is one of them
|
||||
bool TMoverParameters::RunBrakeCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
bool physics::Vehicle::RunBrakeCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::brake) // youBy - jak sie EP hamuje, to trza sygnal wyslac...
|
||||
{
|
||||
@@ -308,7 +308,7 @@ bool TMoverParameters::RunBrakeCommand(VehicleCommand const Command, double CVal
|
||||
}
|
||||
|
||||
// RunCommand() for the brake delays, the spring brake, the sand and the cab signalling; returns whether the command is one of them
|
||||
bool TMoverParameters::RunBrakeEquipmentCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
bool physics::Vehicle::RunBrakeEquipmentCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::brakeDelay)
|
||||
{
|
||||
@@ -355,7 +355,7 @@ bool TMoverParameters::RunBrakeEquipmentCommand(VehicleCommand const Command, do
|
||||
}
|
||||
|
||||
// RunCommand() for the heating, the converter, the battery and the compressor; returns whether the command is one of them
|
||||
bool TMoverParameters::RunAuxiliariesCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
bool physics::Vehicle::RunAuxiliariesCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::heatingSwitch)
|
||||
{
|
||||
@@ -403,7 +403,7 @@ bool TMoverParameters::RunAuxiliariesCommand(VehicleCommand const Command, doubl
|
||||
}
|
||||
|
||||
// RunCommand() for the water, fuel and oil pumps and the water heater; returns whether the command is one of them
|
||||
bool TMoverParameters::RunPumpsCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
bool physics::Vehicle::RunPumpsCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::waterPumpBreakerSwitch)
|
||||
{
|
||||
@@ -514,7 +514,7 @@ bool TMoverParameters::RunPumpsCommand(VehicleCommand const Command, double CVal
|
||||
}
|
||||
|
||||
// RunCommand() for the motor blowers and the compartment lights; returns whether the command is one of them
|
||||
bool TMoverParameters::RunBlowersCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
bool physics::Vehicle::RunBlowersCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::motorBlowersFrontSwitch)
|
||||
{
|
||||
@@ -580,7 +580,7 @@ bool TMoverParameters::RunBlowersCommand(VehicleCommand const Command, double CV
|
||||
}
|
||||
|
||||
// RunCommand() for the line breaker, the relays and the pantographs; returns whether the command is one of them
|
||||
bool TMoverParameters::RunPowerCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
bool physics::Vehicle::RunPowerCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::mainSwitch)
|
||||
{
|
||||
@@ -634,7 +634,7 @@ bool TMoverParameters::RunPowerCommand(VehicleCommand const Command, double CVal
|
||||
}
|
||||
|
||||
// RunCommand() for the doors and the departure signal; returns whether the command is one of them
|
||||
bool TMoverParameters::RunDoorsCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
bool physics::Vehicle::RunDoorsCommand(VehicleCommand const Command, double CValue1, double CValue2, CouplingSet const Couplertype, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::doorPermit)
|
||||
{
|
||||
@@ -675,7 +675,7 @@ bool TMoverParameters::RunDoorsCommand(VehicleCommand const Command, double CVal
|
||||
|
||||
// the doors' permits, on the sides the command names: CValue1 the sides, negative to take the permit back, CValue2 the
|
||||
// direction the command comes from
|
||||
void TMoverParameters::DoorPermitCommand(double const CValue1, double const CValue2)
|
||||
void physics::Vehicle::DoorPermitCommand(double const CValue1, double const CValue2)
|
||||
{
|
||||
auto const leftside{CValue2 > 0 ? 1 : 2};
|
||||
if (auto const rightside{3 - leftside}; std::abs(static_cast<int>(CValue1)) & rightside)
|
||||
@@ -689,7 +689,7 @@ void TMoverParameters::DoorPermitCommand(double const CValue1, double const CVal
|
||||
}
|
||||
|
||||
// the doors opened or closed from afar on the sides the command names, unless they're only worked locally
|
||||
void TMoverParameters::DoorRemoteCommand(bool const Open, double const CValue1, double const CValue2)
|
||||
void physics::Vehicle::DoorRemoteCommand(bool const Open, double const CValue1, double const CValue2)
|
||||
{
|
||||
using enum control_t;
|
||||
if (auto const doorcontrol{Open ? Doors.open_control : Doors.close_control};
|
||||
@@ -731,7 +731,7 @@ bool setOrClear(DamageSet &damage, int const number)
|
||||
} // namespace
|
||||
|
||||
// RunCommand() for the load and the damage; returns whether the command is one of them
|
||||
bool TMoverParameters::RunLoadCommand(VehicleCommand const Command, double CValue1, double CValue2, std::string_view const Argument, bool &OK)
|
||||
bool physics::Vehicle::RunLoadCommand(VehicleCommand const Command, double CValue1, double CValue2, std::string_view const Argument, bool &OK)
|
||||
{
|
||||
if (Command == VehicleCommand::load)
|
||||
{
|
||||
@@ -794,7 +794,7 @@ bool TMoverParameters::RunLoadCommand(VehicleCommand const Command, double CValu
|
||||
// Q: 20160714
|
||||
// Uruchamia funkcję RunCommand aż do skutku. Jeśli będzie pozytywny to kasuje komendę.
|
||||
// *************************************************************************************************
|
||||
bool TMoverParameters::RunInternalCommand()
|
||||
bool physics::Vehicle::RunInternalCommand()
|
||||
{
|
||||
bool OK;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user