18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 10:46:45 +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
+18 -18
View File
@@ -1,12 +1,12 @@
#include "stdafx.h"
#include "doctest.h"
#include "physics/mover.h"
#include "physics/vehicle.h"
#include "physics/brakes.h"
#include "consist.h"
#include "vehicle.h"
// the air exchange through the main reservoir hoses between the vehicles of a train (TMoverParameters::UpdatePipeCouplers()).
// the air exchange through the main reservoir hoses between the vehicles of a train (physics::Vehicle::UpdatePipeCouplers()).
// taken in one explicit step of 0.01 s, a hose carried about 1.5 times the air which evens out the pipes on its ends,
// and the vehicles' own main reservoirs fed the pipe in the same step: the pipes of the middle vehicles of a multiple
// unit, or of locomotives in multiple traction, kept jumping 0.8 bar to and fro between the steps, with the main
@@ -66,18 +66,18 @@ evening_out even_out(Builder Train, int const Count, double const Pressure, doub
test::consist train;
Train(train, Count);
for (std::size_t i = 0; i < train.size(); ++i) {
auto &mover{train[i].mover()};
REQUIRE(mover.VeselVolume > 0.0);
auto &physics{train[i].physics()};
REQUIRE(physics.VeselVolume > 0.0);
auto const pressure{i == 0 ? Pressure : Pressure - 1.0};
mover.CompressedVolume = pressure * mover.VeselVolume;
mover.Compressor = pressure;
mover.Pipe2->CreatePress(pressure);
mover.Pipe2->Act();
mover.ScndPipePress = pressure;
physics.CompressedVolume = pressure * physics.VeselVolume;
physics.Compressor = pressure;
physics.Pipe2->CreatePress(pressure);
physics.Pipe2->Act();
physics.ScndPipePress = pressure;
}
evening_out result;
auto const &first{train[0].mover()};
auto const &last{train[train.size() - 1].mover()};
auto const &first{train[0].physics()};
auto const &last{train[train.size() - 1].physics()};
std::vector<double> previous(train.size());
std::vector<double> change(train.size());
for (std::size_t i = 0; i < train.size(); ++i) {
@@ -112,14 +112,14 @@ double charging_time(Builder Train, int const Count, double const Pressure, doub
Train(train, Count);
train[0].hold_main_reservoir(Pressure);
for (std::size_t i = 1; i < train.size(); ++i) {
auto &mover{train[i].mover()};
REQUIRE(mover.VeselVolume == 0.0);
mover.Pipe2->CreatePress(0.0);
mover.Pipe2->Act();
mover.ScndPipePress = 0.0;
auto &physics{train[i].physics()};
REQUIRE(physics.VeselVolume == 0.0);
physics.Pipe2->CreatePress(0.0);
physics.Pipe2->Act();
physics.ScndPipePress = 0.0;
}
auto const &first{train[0].mover()};
auto const &last{train[train.size() - 1].mover()};
auto const &first{train[0].physics()};
auto const &last{train[train.size() - 1].physics()};
auto time{0.0};
while ((last.ScndPipePress < 1.0 || std::abs(last.ScndPipePress - first.ScndPipePress) > 0.2) && time < 60.0) {
train.step({}, Dt);