mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 21:07:06 +01:00
d0387753f8
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.
63 lines
2.3 KiB
C++
63 lines
2.3 KiB
C++
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
#include "vehicle.h"
|
|
|
|
using test::definition;
|
|
using test::track;
|
|
using test::vehicle;
|
|
|
|
namespace {
|
|
|
|
struct braking_result {
|
|
bool skidded{false}; // the wheels locked while braking
|
|
bool stopped{false}; // came (almost) to a stop on the braking rail
|
|
};
|
|
|
|
// brakes the wagon from 40 km/h on the Braking rail until it's (nearly) stopped, then has it stand on the
|
|
// Standing one for 30 seconds
|
|
braking_result brake_to_stop_then_stand(vehicle &Coach, track const &Braking, track const &Standing) {
|
|
braking_result result;
|
|
Coach.hold_brake_pipe(5.0);
|
|
Coach.run(5.0, Braking);
|
|
Coach.hold_brake_pipe(3.5); // service braking
|
|
// a skidding wagon brakes on the sliding adhesion only, give it time
|
|
for (auto step = 0; step < 60000; ++step) { // 600 s in 0.01 s steps
|
|
result.skidded |= Coach->SlippingWheels;
|
|
if (auto const speed{std::abs(Coach.speed())}; speed > 0.0 && speed < 0.1) {
|
|
// almost stopped; a skidding wagon is still skidding at this point
|
|
result.stopped = true;
|
|
break;
|
|
}
|
|
Coach.step(Braking);
|
|
}
|
|
Coach.run(30.0, Standing);
|
|
return result;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
// the engine doesn't let a stopped, braked vehicle slip (the Vel > 0.1 trap in physics::Vehicle::ComputeTotalForce),
|
|
// so a wagon which stopped in a skid should be no different from one which stopped without it. it used to stay
|
|
// skidding instead, with its brakes capped by the sliding adhesion, and slid or crept away (eu07/maszyna#479)
|
|
TEST_CASE("wheelslip: a wagon which stopped in a skid holds like one which stopped without it") {
|
|
track const dry{0.15, 0.0};
|
|
track const slippery{0.02, 0.0};
|
|
// held only by the brakes: the sliding adhesion on this rail is too low for the slope
|
|
track const slipperyslope{0.02, 0.08};
|
|
|
|
vehicle normal{definition::load("wagon"), 40.0};
|
|
auto const normalbraking{brake_to_stop_then_stand(normal, dry, slipperyslope)};
|
|
vehicle skidding{definition::load("wagon"), 40.0};
|
|
auto const skiddingbraking{brake_to_stop_then_stand(skidding, slippery, slipperyslope)};
|
|
|
|
// the test means something only when the braking went as planned
|
|
REQUIRE(normalbraking.stopped);
|
|
REQUIRE_FALSE(normalbraking.skidded);
|
|
REQUIRE(skiddingbraking.stopped);
|
|
REQUIRE(skiddingbraking.skidded);
|
|
|
|
CHECK(std::abs(normal.speed()) < 0.1);
|
|
CHECK(std::abs(skidding.speed()) < 0.1);
|
|
CHECK_FALSE(skidding->SlippingWheels);
|
|
}
|