diff options
author | smatz <smatz@openttd.org> | 2008-09-16 15:15:41 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2008-09-16 15:15:41 +0000 |
commit | 192d348f78794793ba19cbeb51444f7f1d4e8c03 (patch) | |
tree | 8c0cbc3280dbb8a0efcbd528f27f88cc872f845c /src/vehicle.cpp | |
parent | 47d19f7914919d9a1a97aea083f49771264666bf (diff) | |
download | openttd-192d348f78794793ba19cbeb51444f7f1d4e8c03.tar.xz |
(svn r14343) -Fix [FS#2300]: invalid v->u.air.targetairport could cause crashes at several places when the station pool got smaller
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 87568e8e8..193562abf 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -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)))) { |