From 2fb18e975c0d9bcd75e3536bf41192c5fedda8b6 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 28 Aug 2010 14:14:37 +0000 Subject: (svn r20645) -Codechange [FS#4086]: unify the code for checking for breakdown handling as well (Hirundo) --- src/vehicle.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/vehicle.cpp') diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 864b971cc..575f5a3a3 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -986,13 +986,18 @@ void CheckVehicleBreakdown(Vehicle *v) } } -void Vehicle::HandleBreakdown() +bool Vehicle::HandleBreakdown() { /* Possible states for Vehicle::breakdown_ctr * 0 - vehicle is running normally * 1 - vehicle is currently broken down * 2 - vehicle is going to break down now * >2 - vehicle is counting down to the actual breakdown event */ + if (this->breakdown_ctr == 0) return false; + if (this->breakdown_ctr > 2) { + if (!this->current_order.IsType(OT_LOADING)) this->breakdown_ctr--; + return false; + } if (this->breakdown_ctr != 1) { this->breakdown_ctr = 1; @@ -1024,7 +1029,7 @@ void Vehicle::HandleBreakdown() } /* Aircraft breakdowns end only when arriving at the airport */ - if (this->type == VEH_AIRCRAFT) return; + if (this->type == VEH_AIRCRAFT) return false; /* For trains this function is called twice per tick, so decrease v->breakdown_delay at half the rate */ if ((this->tick_counter & (this->type == VEH_TRAIN ? 3 : 1)) == 0) { @@ -1034,6 +1039,7 @@ void Vehicle::HandleBreakdown() SetWindowDirty(WC_VEHICLE_VIEW, this->index); } } + return true; } void AgeVehicle(Vehicle *v) -- cgit v1.2.3-70-g09d2