Mercurial > hg > openttd
changeset 6025:b3979c751708 draft
(svn r8748) -Fix
-Codechange: Do not hardcode the airports with a short airstrip anymore, but make it a flag in AirportFTAClass
author | tron <tron@openttd.org> |
---|---|
date | Thu, 15 Feb 2007 20:35:45 +0000 |
parents | 7558c046b94d |
children | fb6796cdcee4 |
files | src/aircraft_cmd.cpp src/airport.cpp src/airport.h |
diffstat | 3 files changed, 24 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -74,22 +74,23 @@ TileIndex vtile = TileVirtXY(v->x_pos, v->y_pos); FOR_ALL_STATIONS(st) { - if (st->owner == v->owner && st->facilities & FACIL_AIRPORT && - GetAirport(st->airport_type)->nof_depots > 0) { - uint distance; + if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue; - // don't crash the plane if we know it can't land at the airport - if ((AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) && - (st->airport_type == AT_SMALL || st->airport_type == AT_COMMUTER) && - !_cheats.no_jetcrash.value) - continue; + const AirportFTAClass *afc = GetAirport(st->airport_type); + if (afc->nof_depots == 0 || ( + /* don't crash the plane if we know it can't land at the airport */ + afc->flags & AirportFTAClass::SHORT_STRIP && + AircraftVehInfo(v->engine_type)->subtype & AIR_FAST && + !_cheats.no_jetcrash.value + )) { + continue; + } - // 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; - } + // v->tile can't be used here, when aircraft is flying v->tile is set to 0 + uint distance = DistanceSquare(vtile, st->airport_tile); + if (distance < best || index == INVALID_STATION) { + best = distance; + index = st->index; } } return index; @@ -1368,7 +1369,9 @@ //FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports prob = 0x10000 / 1500; - if (((st->airport_type == AT_SMALL) || (st->airport_type == AT_COMMUTER)) && (AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) && !_cheats.no_jetcrash.value) { + if (GetAirport(st->airport_type)->flags & AirportFTAClass::SHORT_STRIP && + AircraftVehInfo(v->engine_type)->subtype & AIR_FAST && + !_cheats.no_jetcrash.value) { prob = 0x10000 / 20; }
--- a/src/airport.cpp +++ b/src/airport.cpp @@ -37,7 +37,7 @@ _airport_terminal_country, NULL, 16, - AirportFTAClass::ALL, + AirportFTAClass::ALL | AirportFTAClass::SHORT_STRIP, _airport_fta_country, _airport_depots_country, lengthof(_airport_depots_country), @@ -128,7 +128,7 @@ _airport_terminal_commuter, _airport_helipad_commuter, 22, - AirportFTAClass::ALL, + AirportFTAClass::ALL | AirportFTAClass::SHORT_STRIP, _airport_fta_commuter, _airport_depots_commuter, lengthof(_airport_depots_commuter),
--- a/src/airport.h +++ b/src/airport.h @@ -125,6 +125,7 @@ PLANES = 0x1, HELICOPTERS = 0x2, ALL = PLANES | HELICOPTERS, + SHORT_STRIP = 0x4 }; AirportFTAClass( @@ -163,6 +164,9 @@ byte delta_z; // Z adjustment for helicopter pads } AirportFTAClass; +DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags) + + // internal structure used in openttd - Finite sTate mAchine --> FTA typedef struct AirportFTA { struct AirportFTA *next; // possible extra movement choices from this position