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

This commit is contained in:
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
* 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--;
switch (this->breakdown_ctr) {
case 0:
return false;
}
if (this->breakdown_ctr != 1) {
case 2:
this->breakdown_ctr = 1;
if (this->breakdowns_since_last_service != 255) {
@ -1026,8 +1025,8 @@ bool Vehicle::HandleBreakdown()
if (u != NULL) u->animation_state = this->breakdown_delay * 2;
}
}
}
/* FALL THROUGH */
case 1:
/* Aircraft breakdowns end only when arriving at the airport */
if (this->type == VEH_AIRCRAFT) return false;
@ -1040,6 +1039,11 @@ bool Vehicle::HandleBreakdown()
}
}
return true;
default:
if (!this->current_order.IsType(OT_LOADING)) this->breakdown_ctr--;
return false;
}
}
void AgeVehicle(Vehicle *v)