mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 04:47:06 +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:
@@ -490,30 +490,30 @@ bool joints_tool::joint_fix(joint_issue &Issue, std::vector<std::pair<TTrack *,
|
||||
std::string reason;
|
||||
return Track->eType == tt_Normal && editor_track::can_edit_geometry(*Track, reason) && scene::Layers.editable(Track);
|
||||
};
|
||||
TTrack *mover{nullptr};
|
||||
TTrack *physics{nullptr};
|
||||
editor_track::point_ref moved;
|
||||
TTrack *fixed{nullptr};
|
||||
editor_track::point_ref held;
|
||||
if (movable(Issue.track))
|
||||
{
|
||||
mover = Issue.track;
|
||||
physics = Issue.track;
|
||||
moved = Issue.point;
|
||||
fixed = Issue.other;
|
||||
held = Issue.theirs;
|
||||
}
|
||||
else if (movable(Issue.other) && (Issue.type != kind::gap || false == editor_track::is_connected(*Issue.other, Issue.theirs)))
|
||||
{
|
||||
mover = Issue.other;
|
||||
physics = Issue.other;
|
||||
moved = Issue.theirs;
|
||||
fixed = Issue.track;
|
||||
held = Issue.point;
|
||||
}
|
||||
if (mover == nullptr)
|
||||
if (physics == nullptr)
|
||||
return false;
|
||||
if (std::none_of(States.begin(), States.end(), [&](auto const &Entry) { return Entry.first == mover; }))
|
||||
States.emplace_back(mover, editor_track::capture(*mover));
|
||||
if (std::find(Changed.begin(), Changed.end(), mover) == Changed.end())
|
||||
Changed.push_back(mover);
|
||||
if (std::none_of(States.begin(), States.end(), [&](auto const &Entry) { return Entry.first == physics; }))
|
||||
States.emplace_back(physics, editor_track::capture(*physics));
|
||||
if (std::find(Changed.begin(), Changed.end(), physics) == Changed.end())
|
||||
Changed.push_back(physics);
|
||||
editor_track::snap_target target;
|
||||
target.track = fixed;
|
||||
target.point = held;
|
||||
@@ -524,14 +524,14 @@ bool joints_tool::joint_fix(joint_issue &Issue, std::vector<std::pair<TTrack *,
|
||||
case kind::gap:
|
||||
case kind::kink:
|
||||
case kind::grade:
|
||||
editor_track::snap_point(*mover, moved, target, true);
|
||||
editor_track::snap_point(*physics, moved, target, true);
|
||||
break;
|
||||
case kind::step:
|
||||
editor_track::snap_point(*mover, moved, target, false);
|
||||
editor_track::snap_point(*physics, moved, target, false);
|
||||
break;
|
||||
case kind::cant:
|
||||
{
|
||||
auto &path{mover->m_paths[moved.path]};
|
||||
auto &path{physics->m_paths[moved.path]};
|
||||
auto const roll{static_cast<float>(roll_into(*fixed, held))};
|
||||
if (at_start(moved))
|
||||
path.rolls[0] = -roll;
|
||||
|
||||
Reference in New Issue
Block a user