mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 05:44:59 +01:00
feat: keep the vehicle odometers between the sessions (#72)
Every vehicle gets an odometer (TMoverParameters::Odometer) counting along with the per-session DistCounter, starting from its state saved in eu07_odometers.txt in the user's settings directory, else from the file a python screen kept it in (kilometry/<name>_przebieg.txt), else from a state made up from the vehicle name. The store is saved every minute of simulation time and on closing. The cab's distcounter: gauge shows the odometer; its .mmd offset seeds a vehicle with no known state. Python screens get it as state["odometer_total"]; state["odometer"] stays the session distance the logbook and mirror scripts count differences of.
This commit is contained in:
@@ -796,7 +796,8 @@ std::shared_ptr<dictionary_source> TTrain::GetTrainState(dictionary_source const
|
||||
dict->insert("tractionforce", std::abs(mvOccupied->Ft));
|
||||
dict->insert("slipping_wheels", mvOccupied->SlippingWheels);
|
||||
dict->insert("sanding", mvOccupied->SandDose);
|
||||
dict->insert("odometer", mvOccupied->DistCounter);
|
||||
dict->insert("odometer", mvOccupied->DistCounter); // distance run in the session, km
|
||||
dict->insert("odometer_total", mvOccupied->Odometer.km); // the vehicle's odometer, kept between the sessions
|
||||
// electric current data
|
||||
dict->insert("traction_voltage", std::abs(mvPantographUnit->PantographVoltage));
|
||||
dict->insert("voltage", std::abs(mvControlled->EngineVoltage));
|
||||
@@ -12320,7 +12321,12 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
// Ra 2014-07: licznik kilometrów
|
||||
auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka
|
||||
gauge.Load(Parser, DynamicObject);
|
||||
gauge.AssignDouble(&mvControlled->DistCounter);
|
||||
// the counter shows the odometer of the vehicle, kept between the sessions (eu07/maszyna#72). its offset
|
||||
// was the state it started each session with, now it is that only for a vehicle with no known state
|
||||
if (auto const seed{odometer::counter_seed(gauge.offset(), gauge.scale())})
|
||||
mvControlled->Odometer.seed(*seed);
|
||||
gauge.offset(0.f);
|
||||
gauge.AssignDouble(&mvControlled->Odometer.km);
|
||||
}
|
||||
else if (Label == "shuntmodepower:")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user