diff options
author | rubidium <rubidium@openttd.org> | 2010-08-28 14:14:37 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-08-28 14:14:37 +0000 |
commit | 2fb18e975c0d9bcd75e3536bf41192c5fedda8b6 (patch) | |
tree | 1679e9e6786d2599682c0bcc697071426b5d7e22 /src/vehicle.cpp | |
parent | 702cc96943a5ffb52fd59718075667044a86775e (diff) | |
download | openttd-2fb18e975c0d9bcd75e3536bf41192c5fedda8b6.tar.xz |
(svn r20645) -Codechange [FS#4086]: unify the code for checking for breakdown handling as well (Hirundo)
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
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) |