mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 10:37:07 +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:
@@ -27,7 +27,7 @@ definition sn61(bool const Joint = true) {
|
||||
// pressure built up, and the controller at the first position giving the engines fuel, which a mechanical diesel
|
||||
// starts at: everything but the engines ready to start
|
||||
void prepare(consist &Train) {
|
||||
auto &cab{Train[0].mover()};
|
||||
auto &cab{Train[0].physics()};
|
||||
cab.BatterySwitch(true);
|
||||
cab.CabActivisation();
|
||||
cab.OilPumpSwitch(true);
|
||||
@@ -38,7 +38,7 @@ void prepare(consist &Train) {
|
||||
Train.run(20.0);
|
||||
}
|
||||
|
||||
bool running(TMoverParameters const &Vehicle) {
|
||||
bool running(physics::Vehicle const &Vehicle) {
|
||||
return Vehicle.Mains && Vehicle.enrot > 0.5 * Vehicle.diesel.minRevolutions;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ int steps(double const Seconds) {
|
||||
}
|
||||
|
||||
// the switch of Engine held closed for Seconds, then let go, in steps of the train
|
||||
void hold(consist &Train, engine_start::remote_switch &Switch, TMoverParameters *Engine, double const Seconds, bool const Closesonrelease = false) {
|
||||
void hold(consist &Train, engine_start::remote_switch &Switch, physics::Vehicle *Engine, double const Seconds, bool const Closesonrelease = false) {
|
||||
for (auto step = 0; step < steps(Seconds); ++step) {
|
||||
Switch.update(Engine, true, false, dt, Closesonrelease);
|
||||
Train.step({}, dt);
|
||||
@@ -63,8 +63,8 @@ void hold(consist &Train, engine_start::remote_switch &Switch, TMoverParameters
|
||||
|
||||
TEST_CASE("engine start: the joint start is the default, and JointEngineStart=No keeps the cab's switch to its vehicle") {
|
||||
consist train;
|
||||
auto const &joint{train.add(sn61(), 1).mover()};
|
||||
auto const &separate{train.add(sn61(false)).mover()};
|
||||
auto const &joint{train.add(sn61(), 1).physics()};
|
||||
auto const &separate{train.add(sn61(false)).physics()};
|
||||
CHECK(joint.JointEngineStart);
|
||||
CHECK_FALSE(separate.JointEngineStart);
|
||||
CHECK(joint.MainSwitchRange() == range_t::consist);
|
||||
@@ -73,9 +73,9 @@ TEST_CASE("engine start: the joint start is the default, and JointEngineStart=No
|
||||
|
||||
TEST_CASE("engine start: the vehicles in multiple, counted from the cab's own one, those behind the cab first") {
|
||||
consist train;
|
||||
auto &first{train.add(sn61(), 1).mover()};
|
||||
auto &second{train.add(sn61()).mover()};
|
||||
auto &third{train.add(sn61()).mover()};
|
||||
auto &first{train.add(sn61(), 1).physics()};
|
||||
auto &second{train.add(sn61()).physics()};
|
||||
auto &third{train.add(sn61()).physics()};
|
||||
CHECK(engine_start::engine(first, first, 1) == &first);
|
||||
CHECK(engine_start::engine(first, first, 2) == &second);
|
||||
CHECK(engine_start::engine(first, first, 3) == &third);
|
||||
@@ -96,10 +96,10 @@ TEST_CASE("engine start: the vehicles in multiple, counted from the cab's own on
|
||||
|
||||
TEST_CASE("engine start: only the vehicles with an engine and under control through the cable count") {
|
||||
consist train;
|
||||
auto &first{train.add(sn61(), 1).mover()};
|
||||
auto &first{train.add(sn61(), 1).physics()};
|
||||
// a vehicle without an engine between the railcars is passed over
|
||||
auto &trailer{train.add(definition::fiz("ed72_v1/5bs-ra")).mover()};
|
||||
auto &second{train.add(sn61()).mover()};
|
||||
auto &trailer{train.add(definition::fiz("ed72_v1/5bs-ra")).physics()};
|
||||
auto &second{train.add(sn61()).physics()};
|
||||
REQUIRE(trailer.Power < 0.01);
|
||||
CHECK(engine_start::engine(first, first, 2) == &second);
|
||||
// the vehicle with the cab doesn't drive itself: its engine is in the vehicle it controls, which isn't counted twice
|
||||
@@ -110,15 +110,15 @@ TEST_CASE("engine start: only the vehicles with an engine and under control thro
|
||||
|
||||
// coupled without the control cable, the other railcar isn't under the cab's control
|
||||
consist apart;
|
||||
auto &alone{apart.add(sn61(), 1).mover()};
|
||||
auto &alone{apart.add(sn61(), 1).physics()};
|
||||
apart.add(sn61(), 0, Coupling::coupler | Coupling::brakeHose);
|
||||
CHECK(engine_start::engine(alone, alone, 2) == nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("engine start: by default the cab's switch starts and stops the engines of all the vehicles in multiple") {
|
||||
consist train;
|
||||
auto &first{train.add(sn61(), 1).mover()};
|
||||
auto const &second{train.add(sn61()).mover()};
|
||||
auto &first{train.add(sn61(), 1).physics()};
|
||||
auto const &second{train.add(sn61()).physics()};
|
||||
prepare(train);
|
||||
REQUIRE_FALSE(first.Mains);
|
||||
REQUIRE_FALSE(second.Mains);
|
||||
@@ -134,9 +134,9 @@ TEST_CASE("engine start: by default the cab's switch starts and stops the engine
|
||||
|
||||
TEST_CASE("engine start: with JointEngineStart=No each engine has its own switch") {
|
||||
consist train;
|
||||
auto &first{train.add(sn61(false), 1).mover()};
|
||||
auto &second{train.add(sn61(false)).mover()};
|
||||
auto &third{train.add(sn61(false)).mover()};
|
||||
auto &first{train.add(sn61(false), 1).physics()};
|
||||
auto &second{train.add(sn61(false)).physics()};
|
||||
auto &third{train.add(sn61(false)).physics()};
|
||||
prepare(train);
|
||||
// the cab's own switch starts its own engine only
|
||||
first.MainSwitch(true, first.MainSwitchRange());
|
||||
@@ -177,7 +177,7 @@ TEST_CASE("engine start: with JointEngineStart=No each engine has its own switch
|
||||
TEST_CASE("engine start: the switch of another vehicle is held for the vehicle's delay, with the vehicle ready") {
|
||||
consist train;
|
||||
train.add(sn61(false).set("Cntrl", "IniCDelay", "2.0"), 1);
|
||||
auto &second{train.add(sn61(false).set("Cntrl", "IniCDelay", "2.0")).mover()};
|
||||
auto &second{train.add(sn61(false).set("Cntrl", "IniCDelay", "2.0")).physics()};
|
||||
REQUIRE(second.InitialCtrlDelay == doctest::Approx(2.0));
|
||||
engine_start::remote_switch switchb;
|
||||
|
||||
@@ -207,7 +207,7 @@ TEST_CASE("engine start: the switch of another vehicle is held for the vehicle's
|
||||
TEST_CASE("engine start: a switch closing on release, as an electric locomotive's impulse switch, waits to be let go") {
|
||||
consist train;
|
||||
train.add(sn61(false), 1);
|
||||
auto &second{train.add(sn61(false).set("Cntrl", "IniCDelay", "1.0")).mover()};
|
||||
auto &second{train.add(sn61(false).set("Cntrl", "IniCDelay", "1.0")).physics()};
|
||||
prepare(train);
|
||||
engine_start::remote_switch switchb;
|
||||
// held past the delay, the circuit stays open while the switch is held
|
||||
@@ -233,8 +233,8 @@ TEST_CASE("engine start: an engine stopping on its own stops the others only whe
|
||||
for (auto const joint : {true, false}) {
|
||||
CAPTURE(joint);
|
||||
consist train;
|
||||
auto &first{train.add(sn61(joint), 1).mover()};
|
||||
auto const &second{train.add(sn61(joint)).mover()};
|
||||
auto &first{train.add(sn61(joint), 1).physics()};
|
||||
auto const &second{train.add(sn61(joint)).physics()};
|
||||
prepare(train);
|
||||
engine_start::remote_switch switchb;
|
||||
first.MainSwitch(true, first.MainSwitchRange());
|
||||
@@ -259,9 +259,9 @@ TEST_CASE("engine start: an engine stopped from its own switch doesn't stop the
|
||||
consist train;
|
||||
// the middle railcar keeps the joint start, as a .fiz without the key does. what a vehicle without the cab relays
|
||||
// goes on away from the cab, so it's the third one that would stop
|
||||
auto &first{train.add(sn61(false), 1).mover()};
|
||||
auto &second{train.add(sn61()).mover()};
|
||||
auto &third{train.add(sn61(false)).mover()};
|
||||
auto &first{train.add(sn61(false), 1).physics()};
|
||||
auto &second{train.add(sn61()).physics()};
|
||||
auto &third{train.add(sn61(false)).physics()};
|
||||
prepare(train);
|
||||
engine_start::remote_switch switchb;
|
||||
engine_start::remote_switch switchc;
|
||||
@@ -284,8 +284,8 @@ TEST_CASE("engine start: an engine stopped from its own switch doesn't stop the
|
||||
TEST_CASE("engine start: the stopped engine of the cab's vehicle doesn't stop the one started from its switch") {
|
||||
consist train;
|
||||
// the cab's railcar keeps the joint start, its engine stopped
|
||||
auto &first{train.add(sn61(), 1).mover()};
|
||||
auto &second{train.add(sn61(false)).mover()};
|
||||
auto &first{train.add(sn61(), 1).physics()};
|
||||
auto &second{train.add(sn61(false)).physics()};
|
||||
prepare(train);
|
||||
REQUIRE_FALSE(first.Mains);
|
||||
// mainb_on
|
||||
|
||||
Reference in New Issue
Block a user