18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-20 20:54:59 +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:
jerrrrycho
2026-11-11 08:27:33 +01:00
parent 9a873b2e18
commit 5a45446b4a
5 changed files with 109 additions and 6 deletions

View File

@@ -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:")
{