diff options
author | yexo <yexo@openttd.org> | 2009-09-20 18:38:43 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2009-09-20 18:38:43 +0000 |
commit | 12ef0046dde205e0e111ed7e6d830ea4f93c45c9 (patch) | |
tree | 725c12c7662b29bea2b46b1ed10469a1fa44947c /src/ai/api/ai_airport.cpp | |
parent | 64ed7cc8de1dd551e9222119ec75465371494f3b (diff) | |
download | openttd-12ef0046dde205e0e111ed7e6d830ea4f93c45c9.tar.xz |
(svn r17591) -Add [NoAI] [FS#3212]: AIAirport::IsAirportInformationAvailable. Also update several preconditions so it's now possible to get information on airports types that can no longer be build (small airport after 1960)
Diffstat (limited to 'src/ai/api/ai_airport.cpp')
-rw-r--r-- | src/ai/api/ai_airport.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/ai/api/ai_airport.cpp b/src/ai/api/ai_airport.cpp index 3ddb4666d..d3a5f90b6 100644 --- a/src/ai/api/ai_airport.cpp +++ b/src/ai/api/ai_airport.cpp @@ -19,7 +19,12 @@ /* static */ bool AIAirport::IsValidAirportType(AirportType type) { - return type >= 0 && type < (AirportType)NUM_AIRPORTS && ::GetAirport(type)->IsAvailable(); + return IsAirportInformationAvailable(type) && ::GetAirport(type)->IsAvailable(); +} + +/* static */ bool AIAirport::IsAirportInformationAvailable(AirportType type) +{ + return type >= 0 && type < (AirportType)NUM_AIRPORTS; } /* static */ Money AIAirport::GetPrice(AirportType type) @@ -46,21 +51,21 @@ /* static */ int32 AIAirport::GetAirportWidth(AirportType type) { - if (!IsValidAirportType(type)) return -1; + if (!IsAirportInformationAvailable(type)) return -1; return ::GetAirport(type)->size_x; } /* static */ int32 AIAirport::GetAirportHeight(AirportType type) { - if (!IsValidAirportType(type)) return -1; + if (!IsAirportInformationAvailable(type)) return -1; return ::GetAirport(type)->size_y; } /* static */ int32 AIAirport::GetAirportCoverageRadius(AirportType type) { - if (!IsValidAirportType(type)) return -1; + if (!IsAirportInformationAvailable(type)) return -1; return _settings_game.station.modified_catchment ? ::GetAirport(type)->catchment : (uint)CA_UNMODIFIED; } @@ -143,7 +148,7 @@ extern Town *AirportGetNearestTown(const AirportFTAClass *afc, TileIndex airport_tile); if (!::IsValidTile(tile)) return INVALID_TOWN; - if (!IsValidAirportType(type)) return INVALID_TOWN; + if (!IsAirportInformationAvailable(type)) return INVALID_TOWN; return AirportGetNearestTown(GetAirport(type), tile)->index; } |