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)
|
static void FloodVehicle(Vehicle *v)
|
||||||
{
|
{
|
||||||
if (!(v->vehstatus & VS_CRASHED)) {
|
if ((v->vehstatus & VS_CRASHED) != 0) return;
|
||||||
uint16 pass = 0;
|
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) {
|
if (v->type == VEH_AIRCRAFT) {
|
||||||
/* Crashing aircraft are always at z_pos == 1, never on z_pos == 0,
|
/* Crashing aircraft are always at z_pos == 1, never on z_pos == 0,
|
||||||
* because that's always the shadow. Except for the heliport, because
|
* 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();
|
const AirportFTAClass *airport = st->Airport();
|
||||||
|
|
||||||
if (v->z_pos != airport->delta_z + 1) return;
|
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 */
|
/* crash all wagons, and count passengers */
|
||||||
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
for (Vehicle *u = v; u != NULL; u = u->Next()) {
|
||||||
if (IsCargoInClass(u->cargo_type, CC_PASSENGERS)) pass += u->cargo.Count();
|
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);
|
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
|
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
|
||||||
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
|
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
|
||||||
|
@ -853,7 +850,6 @@ static void FloodVehicle(Vehicle *v)
|
||||||
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
|
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
|
||||||
SndPlayVehicleFx(SND_12_EXPLOSION, v);
|
SndPlayVehicleFx(SND_12_EXPLOSION, v);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the behaviour of a tile during flooding.
|
* Returns the behaviour of a tile during flooding.
|
||||||
|
|
Loading…
Reference in New Issue