mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 16:27:11 +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.
57 lines
2.5 KiB
C++
57 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
#include "vehicle.h"
|
|
|
|
namespace test {
|
|
|
|
class trace;
|
|
class consist;
|
|
|
|
// what a driver does with a vehicle, made of the steps the AI takes (TController and the driver hints of
|
|
// application/driverhints.cpp), on the vehicle's own controls. the driver sits in a vehicle with a cab
|
|
// (Cab != 0): a lone one, or the first one of a consist, and drives the whole of it
|
|
|
|
// what the driver drives: the vehicle with the driver in it, the vehicles the driver controls the engine and
|
|
// the pantographs of (the AI's occupied, mvControlling, pantographUnit; all the same one in a lone
|
|
// vehicle or a locomotive), and the way to run the whole of it
|
|
struct driven {
|
|
physics::Vehicle &cab;
|
|
physics::Vehicle &controlling;
|
|
physics::Vehicle &pantographs;
|
|
std::function<void(double Seconds, track const &Track)> run;
|
|
};
|
|
driven driving(vehicle &Vehicle);
|
|
driven driving(consist &Consist);
|
|
|
|
// gets the vehicle ready to run, the way TController::PrepareEngine() does: battery, cab, pumps and heating
|
|
// of a diesel engine, pantographs, line breaker, converter, compressor and motor blowers, then waits for the
|
|
// air. stops trying after Seconds; returns whether the vehicle got ready
|
|
bool start_up(driven Driven, track const &Track, double Seconds = 300.0, trace *Trace = nullptr);
|
|
|
|
// runs the vehicle for Seconds with the driver paying attention, as TController::control_security_system()
|
|
// does: once a second the vigilance and the cab signalling get acknowledged when they call for it
|
|
void drive(driven Driven, track const &Track, double Seconds);
|
|
|
|
// releases every brake the driver has a hand on: the train brake to running, the independent brake, the
|
|
// hand brake and the spring brake; and the hand and spring brakes of the vehicles coupled to the cab's
|
|
void release_brakes(physics::Vehicle &Cab);
|
|
|
|
// whether the vehicle is ready to run: line breaker closed (or the engine running), air in the main reservoir
|
|
bool is_ready(driven const &Driven);
|
|
|
|
// whether the vehicle drives itself
|
|
bool is_powered(physics::Vehicle const &Vehicle);
|
|
|
|
// a trace mark, when there's a trace
|
|
void mark(trace *Trace, std::string const &Event);
|
|
|
|
// a whole run: start up, release the brakes, notch up to full power, the second controller (field weakening,
|
|
// shunting) up and down, notch down, coast and brake to a stop. the controllers move on a fixed schedule,
|
|
// not the way a driver watching the ammeter would, so the relays may trip on the way
|
|
void drive_cycle(driven Driven, track const &Track, trace &Trace);
|
|
|
|
} // namespace test
|