mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-21 23:44:58 +01:00
fix: record the odometer of a vehicle whose cab shows it, also without a driver's brake valve
HasDriverCab() decides by the BrakeHandle, which the DL2 draisine doesn't have: its cab counter (distcounter: with offset 85) was never saved and started from the .mmd offset each session. A vehicle is now also recorded when a cab showed its odometer in the session (reading::shown: TTrain loaded a cab model of it for a player, or bound a cab's counter to it) or when a cab's counter seeded its state (origin::counter). The counter-seeded state is saved as a known one, so the next session starts from it and keeps counting whenever the counter is bound again.
This commit is contained in:
@@ -11162,7 +11162,12 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
}
|
||||
|
||||
if (DynamicObject->mdKabina)
|
||||
{
|
||||
DynamicObject->mdKabina->Init(); // obrócenie modelu oraz optymalizacja, również zapisanie binarnego
|
||||
// the vehicle has a cab, a player is in it: the odometer store keeps the vehicle also when its type has no
|
||||
// driver's brake valve (eu07/maszyna#72)
|
||||
DynamicObject->MoverParameters->Odometer.shown = true;
|
||||
}
|
||||
|
||||
set_cab_controls(NewCabNo < 0 ? 2 : NewCabNo);
|
||||
|
||||
@@ -12788,6 +12793,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
mvControlled->Odometer.seed(*seed);
|
||||
gauge.offset(0.f);
|
||||
gauge.AssignDouble(&mvControlled->Odometer.km);
|
||||
// the vehicle the counter counts for is one the odometer store keeps, also in the sessions the counter seeds
|
||||
// nothing (its state is a saved one by then) and when it's the motor car of the unit the cab is in
|
||||
mvControlled->Odometer.shown = true;
|
||||
}
|
||||
else if (Label == "shuntmodepower:")
|
||||
{
|
||||
|
||||
@@ -158,8 +158,12 @@ void store::record(std::string const &Vehicle, reading const &Odometer) {
|
||||
m_modified = true;
|
||||
}
|
||||
|
||||
bool kept(bool const Drivercab, reading const &Odometer) {
|
||||
return Drivercab || Odometer.shown || Odometer.source == origin::counter;
|
||||
}
|
||||
|
||||
void record(store &States, std::string const &Vehicle, bool const Drivercab, reading const &Odometer) {
|
||||
if (false == Drivercab)
|
||||
if (false == kept(Drivercab, Odometer))
|
||||
return;
|
||||
States.record(Vehicle, Odometer);
|
||||
}
|
||||
|
||||
@@ -64,11 +64,20 @@ private:
|
||||
bool m_modified{false};
|
||||
};
|
||||
|
||||
// records the state of a vehicle in the store when it's one the store keeps: a vehicle with a driver's cab
|
||||
// (TMoverParameters::HasDriverCab()), which can show its odometer on the cab's counter or a python screen. that
|
||||
// includes the locomotives and units the AI runs before a player's cab loads them, their made up states stay
|
||||
// replaceable by the cab's counter. the wagons, which make most of the AI's trains, aren't recorded; the states the
|
||||
// store already holds for any of them stay as they are
|
||||
// the vehicle is one the store keeps: one with a driver's cab, which can show its odometer on the cab's counter or a
|
||||
// python screen. that's
|
||||
// - a vehicle whose type has a cab (Drivercab, TMoverParameters::HasDriverCab(): it has the driver's brake valve). that
|
||||
// includes the locomotives and units the AI runs before a player's cab loads them, their made up states stay
|
||||
// replaceable by the cab's counter
|
||||
// - a vehicle whose cab showed the odometer in this session (reading::shown): the cab was loaded for a player, or a
|
||||
// cab's counter was bound to it. the type alone misses the vehicles driven without a driver's brake valve (the DL2
|
||||
// draisine, with a counter in its cab) and the motor cars the counter of a unit's cab counts for. such a vehicle is
|
||||
// recorded in the sessions a player's cab shows it; in the others its saved state stays as it is
|
||||
// - a vehicle whose state a cab's counter seeded (origin::counter), which is the same thing, told by the state
|
||||
// the wagons, which make most of the AI's trains, aren't
|
||||
bool kept(bool Drivercab, reading const &Odometer);
|
||||
// records the state of a vehicle in the store when it's one the store keeps (kept()). the others aren't recorded; the
|
||||
// states the store already holds for any of them stay as they are
|
||||
void record(store &States, std::string const &Vehicle, bool Drivercab, reading const &Odometer);
|
||||
|
||||
// state kept in the file of the python screens before, when it holds a number. the screens opened the file in the
|
||||
|
||||
@@ -27,6 +27,9 @@ struct reading {
|
||||
double start{0.0}; // the state at the start of the session, km
|
||||
origin source{origin::guessed};
|
||||
double guess{0.0}; // the made up state a guessed one counts from, km
|
||||
// a cab shows the state in this session: a cab of the vehicle was loaded for a player (its python screens can
|
||||
// show it), or a cab's counter was bound to it. such a vehicle has a cab, whatever its type tells
|
||||
bool shown{false};
|
||||
|
||||
// sets the state the vehicle starts the session with
|
||||
void begin(double Km, origin Source);
|
||||
|
||||
Reference in New Issue
Block a user