summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2006-08-15 14:38:43 +0000
committerDarkvater <darkvater@openttd.org>2006-08-15 14:38:43 +0000
commitd447f025e9c44a347e9134a5ecda92fbbe14bb75 (patch)
treedebe990f9ac52b272288ccbfd92121107e76d57a
parentc54b71d4cee91cc5accccbdb44dfd38df0fb7e99 (diff)
downloadopenttd-d447f025e9c44a347e9134a5ecda92fbbe14bb75.tar.xz
(svn r5914) -Fix [FS#235]: Bugfix for errors in FindNearestHangar function in aircraft_cmd.c (mart3p).
-rw-r--r--aircraft_cmd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 65f8f7205..0f2fc2f93 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -63,6 +63,7 @@ static StationID FindNearestHangar(const Vehicle *v)
const Station *st;
uint best = 0;
StationID index = INVALID_STATION;
+ TileIndex vtile = TileVirtXY(v->x_pos, v->y_pos);
FOR_ALL_STATIONS(st) {
if (st->owner == v->owner && st->facilities & FACIL_AIRPORT &&
@@ -70,11 +71,13 @@ static StationID FindNearestHangar(const Vehicle *v)
uint distance;
// don't crash the plane if we know it can't land at the airport
- if (HASBIT(v->subtype, 1) && st->airport_type == AT_SMALL &&
+ if ((AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
+ (st->airport_type == AT_SMALL || st->airport_type == AT_COMMUTER) &&
!_cheats.no_jetcrash.value)
continue;
- distance = DistanceSquare(v->tile, st->airport_tile);
+ // v->tile can't be used here, when aircraft is flying v->tile is set to 0
+ distance = DistanceSquare(vtile, st->airport_tile);
if (distance < best || index == INVALID_STATION) {
best = distance;
index = st->index;