@@ -1775,14 +1775,7 @@ static bool AircraftEventHandler(Aircraf
if (v->vehstatus & VS_STOPPED) return true;
/* aircraft is broken down? */
if (v->breakdown_ctr != 0) {
if (v->breakdown_ctr <= 2) {
v->HandleBreakdown();
} else {
if (!v->current_order.IsType(OT_LOADING)) v->breakdown_ctr--;
}
HandleAircraftSmoke(v);
ProcessOrders(v);
@@ -1485,14 +1485,7 @@ static bool RoadVehController(RoadVehicl
/* road vehicle has broken down? */
return true;
if (v->HandleBreakdown()) return true;
@@ -424,13 +424,7 @@ static void ShipController(Ship *v)
v->tick_counter++;
v->current_order_time++;
return;
if (v->HandleBreakdown()) return;
if (v->vehstatus & VS_STOPPED) return;
@@ -3716,13 +3716,7 @@ static bool TrainLocoHandler(Train *v, b
/* train is broken down? */
if (HasBit(v->flags, VRF_REVERSING) && v->cur_speed == 0) {
ReverseTrainDirection(v);
@@ -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);
void AgeVehicle(Vehicle *v)
@@ -523,11 +523,14 @@ public:
this->service_interval = src->service_interval;
/**
* Handle all of the aspects of a vehicle breakdown.
* Handle all of the aspects of a vehicle breakdown
* This includes adding smoke and sounds, and ending the breakdown when appropriate.
* @return true iff the vehicle is stopped because of a breakdown
* @note This function always returns false for aircraft, since these never stop for breakdowns
*/
void HandleBreakdown();
bool HandleBreakdown();
bool NeedsAutorenewing(const Company *c) const;
Status change: