18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-20 16:14:58 +01:00

fix: the odometer store merges the file other simulations saved, keeps a made up state replaceable by the cab's counter

- each process writes its own <file>.<pid>.tmp and renames it in place; before writing it re-reads the file and
  merges it per vehicle (a known state beats a made up one, else the larger one, never the sum)
- a state counted from a made up one is saved as ~<km> and the .mmd counter offset still replaces it later
- a vehicle removed from the scenery has its odometer recorded right away
This commit is contained in:
jerrrrycho
2026-11-08 18:18:35 +01:00
parent 1083f3cb5d
commit a3ad30b72b
4 changed files with 292 additions and 34 deletions

View File

@@ -8890,6 +8890,11 @@ vehicle_table::erase_disabled() {
++vehicleiter;
}
else {
// the distance the vehicle ran goes in the odometer store now, it doesn't depend on the vehicle being
// kept on the list until the next save (eu07/maszyna#72)
if( vehicle->MoverParameters != nullptr ) {
odometer::states().record( vehicle->name(), vehicle->MoverParameters->Odometer );
}
if( vehicle->MyTrack != nullptr
&& true == vehicle->MyTrack->RemoveDynamicObject(vehicle) ) {
vehicle->MyTrack = nullptr;