mirror of https://github.com/OpenTTD/OpenTTD
(svn r18399) -Codechange: bail out early in FloodVehicle instead of a massive if (...) { } else { return }
parent
c1c9a3e835
commit
3817153a8e
|
@ -784,10 +784,9 @@ static void FloodVehicles(TileIndex tile)
|
|||
|
||||
static void FloodVehicle(Vehicle *v)
|
||||
{
|
||||
if (!(v->vehstatus & VS_CRASHED)) {
|
||||
uint16 pass = 0;
|
||||
if ((v->vehstatus & VS_CRASHED) != 0) return;
|
||||
if (v->type != VEH_TRAIN && v->type != VEH_ROAD && v->type != VEH_AIRCRAFT) return;
|
||||
|
||||
if (v->type == VEH_TRAIN || v->type == VEH_ROAD || v->type == VEH_AIRCRAFT) {
|
||||
if (v->type == VEH_AIRCRAFT) {
|
||||
/* Crashing aircraft are always at z_pos == 1, never on z_pos == 0,
|
||||
* because that's always the shadow. Except for the heliport, because
|
||||
|
@ -797,10 +796,11 @@ static void FloodVehicle(Vehicle *v)
|
|||
const AirportFTAClass *airport = st->Airport();
|
||||
|
||||
if (v->z_pos != airport->delta_z + 1) return;
|
||||
} else {
|
||||
v = v->First();
|
||||
}
|
||||
|
||||
if (v->type != VEH_AIRCRAFT) v = v->First();
|
||||
|
||||
uint pass = 0;
|
||||
/* crash all wagons, and count passengers */
|
||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
||||
if (IsCargoInClass(u->cargo_type, CC_PASSENGERS)) pass += u->cargo.Count();
|
||||
|
@ -838,9 +838,6 @@ static void FloodVehicle(Vehicle *v)
|
|||
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
|
||||
|
@ -852,7 +849,6 @@ static void FloodVehicle(Vehicle *v)
|
|||
v->index);
|
||||
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
|
||||
SndPlayVehicleFx(SND_12_EXPLOSION, v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue