16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 11:19:19 +02:00

Simplify derailing logic, derail reason enum

- The `TMoverParameters::derail()` function has been renamed to `::Derail()`, with a capital D.
- All derail events now use that function.
  - Simplified and unified the logic behind different derail types.
  - The `dtrack_freerail` track type is now slightly increasing the chance of derailing on a tight curve, as it was the intention.
- A new `DerailReason` enum has been created which holds all derail types.
- The `DerailReason` field in the `TMoverParameters` class has been removed.
  - This was a transient field which is not necessary anymore.
  - The logging functionality as such has been moved from `DynObj.cpp` to `Mover.cpp`.
This commit is contained in:
jakubg1
2026-04-04 02:05:49 +02:00
parent 4b847e79b9
commit 8c38d2c7e9
3 changed files with 34 additions and 63 deletions

View File

@@ -4265,27 +4265,6 @@ bool TDynamicObject::Update(double dt, double dt1)
MoverParameters->InactiveCabPantsCheck = false;
}
if (MoverParameters->DerailReason > 0)
{
switch (MoverParameters->DerailReason)
{
case 1:
ErrorLog("Bad driving: " + asName + " derailed due to end of track");
break;
case 2:
ErrorLog("Bad driving: " + asName + " derailed due to too high speed");
break;
case 3:
ErrorLog("Bad dynamic: " + asName + " derailed due to track width");
break; // błąd w scenerii
case 4:
ErrorLog("Bad dynamic: " + asName + " derailed due to wrong track type");
break; // błąd w scenerii
}
MoverParameters->DerailReason = 0; //żeby tylko raz
}
if( MoverParameters->LoadStatus ) {
LoadUpdate(); // zmiana modelu ładunku
}