Reduce sensitivity of train overheated breakdown

This commit is contained in:
Jonathan G Rennison
2021-04-11 22:53:02 +01:00
parent 5d88030feb
commit d484c32d44
5 changed files with 22 additions and 2 deletions

View File

@@ -1084,6 +1084,9 @@ static bool TrainAccelerationModelChanged(int32 p1)
static bool TrainBrakingModelChanged(int32 p1) static bool TrainBrakingModelChanged(int32 p1)
{ {
for (Train *t : Train::Iterate()) { for (Train *t : Train::Iterate()) {
if (!(t->vehstatus & VS_CRASHED)) {
t->crash_anim_pos = 0;
}
if (t->IsFrontEngine()) { if (t->IsFrontEngine()) {
t->UpdateAcceleration(); t->UpdateAcceleration();
} }

View File

@@ -163,6 +163,13 @@ class NIHVehicle : public NIHelper {
seprintf(buffer, lastof(buffer), " Railtype: %u, compatible_railtypes: 0x" OTTD_PRINTFHEX64, seprintf(buffer, lastof(buffer), " Railtype: %u, compatible_railtypes: 0x" OTTD_PRINTFHEX64,
t->railtype, t->compatible_railtypes); t->railtype, t->compatible_railtypes);
print(buffer); print(buffer);
if (t->vehstatus & VS_CRASHED) {
seprintf(buffer, lastof(buffer), " CRASHED: anim pos: %u", t->crash_anim_pos);
print(buffer);
} else if (t->crash_anim_pos > 0) {
seprintf(buffer, lastof(buffer), " Brake heating: %u", t->crash_anim_pos);
print(buffer);
}
if (t->lookahead != nullptr) { if (t->lookahead != nullptr) {
print (" Look ahead:"); print (" Look ahead:");
const TrainReservationLookAhead &l = *t->lookahead; const TrainReservationLookAhead &l = *t->lookahead;

View File

@@ -120,7 +120,7 @@ struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
uint32 flags; uint32 flags;
uint16 crash_anim_pos; ///< Crash animation counter. uint16 crash_anim_pos; ///< Crash animation counter, also used for realistic braking train brake overheating
TrackBits track; TrackBits track;
TrainForceProceeding force_proceed; TrainForceProceeding force_proceed;

View File

@@ -5959,6 +5959,9 @@ static bool TrainLocoHandler(Train *v, bool mode)
/* train has crashed? */ /* train has crashed? */
if (v->vehstatus & VS_CRASHED) { if (v->vehstatus & VS_CRASHED) {
return mode ? true : HandleCrashedTrain(v); // 'this' can be deleted here return mode ? true : HandleCrashedTrain(v); // 'this' can be deleted here
} else if (v->crash_anim_pos > 0) {
/* Reduce realistic braking brake overheating */
v->crash_anim_pos--;
} }
if (v->force_proceed != TFP_NONE) { if (v->force_proceed != TFP_NONE) {
@@ -6794,7 +6797,11 @@ void TrainRoadVehicleCrashBreakdown(Vehicle *v)
void TrainBrakesOverheatedBreakdown(Vehicle *v) void TrainBrakesOverheatedBreakdown(Vehicle *v)
{ {
Train *t = Train::From(v)->First(); Train *t = Train::From(v)->First();
if (t->breakdown_ctr != 0) return; if (t->breakdown_ctr != 0 || (t->vehstatus & VS_CRASHED)) return;
t->crash_anim_pos = std::min<uint>(1500, t->crash_anim_pos + 200);
if (t->crash_anim_pos < 1500) return;
t->breakdown_ctr = 2; t->breakdown_ctr = 2;
SetBit(t->flags, VRF_CONSIST_BREAKDOWN); SetBit(t->flags, VRF_CONSIST_BREAKDOWN);
t->breakdown_delay = 255; t->breakdown_delay = 255;

View File

@@ -2334,6 +2334,9 @@ void VehicleEnterDepot(Vehicle *v)
t->ConsistChanged(CCF_ARRANGE); t->ConsistChanged(CCF_ARRANGE);
t->reverse_distance = 0; t->reverse_distance = 0;
t->lookahead.reset(); t->lookahead.reset();
if (!(t->vehstatus & VS_CRASHED)) {
t->crash_anim_pos = 0;
}
break; break;
} }