(svn r14343) -Fix [FS#2300]: invalid v->u.air.targetairport could cause crashes at several places when the station pool got smaller

This commit is contained in:
smatz
2008-09-16 15:15:41 +00:00
parent 564aa83835
commit e6afe2ea0c
3 changed files with 69 additions and 31 deletions

View File

@@ -652,9 +652,11 @@ void Vehicle::PreDestructor()
if (this->type == VEH_ROAD) ClearSlot(this);
if (this->type == VEH_AIRCRAFT && this->IsPrimaryVehicle()) {
Station *st = GetStation(this->u.air.targetairport);
const AirportFTA *layout = st->Airport()->layout;
CLRBITS(st->airport_flags, layout[this->u.air.previous_pos].block | layout[this->u.air.pos].block);
Station *st = GetTargetAirportIfValid(this);
if (st != NULL) {
const AirportFTA *layout = st->Airport()->layout;
CLRBITS(st->airport_flags, layout[this->u.air.previous_pos].block | layout[this->u.air.pos].block);
}
}
if (this->type != VEH_TRAIN || (this->type == VEH_TRAIN && (IsFrontEngine(this) || IsFreeWagon(this)))) {