summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_airport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai/api/ai_airport.cpp')
-rw-r--r--src/ai/api/ai_airport.cpp15
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;
}