1
0
Fork 0

(svn r20646) -Codechange: make the code flow of breakdown handling a bit clearer

release/1.1
rubidium 2010-08-28 14:18:56 +00:00
parent 2fb18e975c
commit f1f1c71a41
1 changed files with 44 additions and 40 deletions

View File

@ -993,12 +993,11 @@ bool Vehicle::HandleBreakdown()
* 1 - vehicle is currently broken down * 1 - vehicle is currently broken down
* 2 - vehicle is going to break down now * 2 - vehicle is going to break down now
* >2 - vehicle is counting down to the actual breakdown event */ * >2 - vehicle is counting down to the actual breakdown event */
if (this->breakdown_ctr == 0) return false; switch (this->breakdown_ctr) {
if (this->breakdown_ctr > 2) { case 0:
if (!this->current_order.IsType(OT_LOADING)) this->breakdown_ctr--;
return false; return false;
}
if (this->breakdown_ctr != 1) { case 2:
this->breakdown_ctr = 1; this->breakdown_ctr = 1;
if (this->breakdowns_since_last_service != 255) { if (this->breakdowns_since_last_service != 255) {
@ -1026,8 +1025,8 @@ bool Vehicle::HandleBreakdown()
if (u != NULL) u->animation_state = this->breakdown_delay * 2; if (u != NULL) u->animation_state = this->breakdown_delay * 2;
} }
} }
} /* FALL THROUGH */
case 1:
/* Aircraft breakdowns end only when arriving at the airport */ /* Aircraft breakdowns end only when arriving at the airport */
if (this->type == VEH_AIRCRAFT) return false; if (this->type == VEH_AIRCRAFT) return false;
@ -1040,6 +1039,11 @@ bool Vehicle::HandleBreakdown()
} }
} }
return true; return true;
default:
if (!this->current_order.IsType(OT_LOADING)) this->breakdown_ctr--;
return false;
}
} }
void AgeVehicle(Vehicle *v) void AgeVehicle(Vehicle *v)