(svn r18402) -Codechange: unify/centralise the code for crashing vehicles

This commit is contained in:
rubidium
2009-12-04 20:29:46 +00:00
parent 2e2aa3e7da
commit 6600610e47
10 changed files with 75 additions and 114 deletions

View File

@@ -1238,19 +1238,21 @@ void Aircraft::MarkDirty()
if (this->subtype == AIR_HELICOPTER) this->Next()->Next()->cur_image = GetRotorImage(this);
}
uint Aircraft::Crash(bool flooded)
{
uint pass = Vehicle::Crash(flooded) + 2; // pilots
this->crashed_counter = flooded ? 9000 : 0; // max 10000, disappear pretty fast when flooded
return pass;
}
static void CrashAirplane(Aircraft *v)
{
v->vehstatus |= VS_CRASHED;
v->crashed_counter = 0;
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
v->MarkDirty();
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
uint amt = 2;
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) amt += v->cargo.Count();
SetDParam(0, amt);
uint pass = v->Crash();
SetDParam(0, pass);
v->cargo.Truncate(0);
v->Next()->cargo.Truncate(0);