mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 23:14: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:
@@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <map>
|
||||
#include "hamulce.h"
|
||||
#include "scripting/ladderlogic.h"
|
||||
#include "vehicle/odometer.h"
|
||||
|
||||
class cParser;
|
||||
/*
|
||||
@@ -1963,6 +1964,7 @@ class TMoverParameters
|
||||
int SoundFlag = 0; /*!o patrz stale sound_ */
|
||||
int AIFlag{0}; // HACK: events of interest for consist owner
|
||||
double DistCounter = 0.0; /*! licznik kilometrow */
|
||||
odometer::reading Odometer; // total distance run, kept between the sessions (eu07/maszyna#72)
|
||||
std::pair<double, double> EnergyMeter; // energy <drawn, returned> from grid [kWh]
|
||||
double V = 0.0; // predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0)
|
||||
double Vel = 0.0; // moduł prędkości w [km/h], używany przez AI
|
||||
|
||||
@@ -1510,6 +1510,7 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
|
||||
dL)};
|
||||
|
||||
DistCounter += fabs(dL) / 1000.0;
|
||||
Odometer.run(dL);
|
||||
dL = 0;
|
||||
|
||||
// koniec procedury, tu nastepuja dodatkowe procedury pomocnicze
|
||||
@@ -1576,6 +1577,7 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape & /*Sh
|
||||
dL)};
|
||||
|
||||
DistCounter += fabs(dL) / 1000.0;
|
||||
Odometer.run(dL);
|
||||
dL = 0;
|
||||
|
||||
// koniec procedury, tu nastepuja dodatkowe procedury pomocnicze
|
||||
|
||||
Reference in New Issue
Block a user