diff options
author | PeterN <peter@fuzzle.org> | 2019-03-30 22:20:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-30 22:20:26 +0000 |
commit | e1069eee05b648a64ff5dac3dd5701b01cfa2034 (patch) | |
tree | 019da19b2cc4b98fc7fb0f09e1738db17fe8a307 /src/script | |
parent | 32fda83d3916197a46215c83ddd85b2e50128a02 (diff) | |
download | openttd-e1069eee05b648a64ff5dac3dd5701b01cfa2034.tar.xz |
Codechange: Check airport layout would fit within map bounds before iterating tiles. (#7429)
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/script_airport.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/script/api/script_airport.cpp b/src/script/api/script_airport.cpp index dab868b75..7d80f97af 100644 --- a/src/script/api/script_airport.cpp +++ b/src/script/api/script_airport.cpp @@ -136,8 +136,10 @@ if (!::IsValidTile(tile)) return -1; if (!IsAirportInformationAvailable(type)) return -1; + const AirportSpec *as = ::AirportSpec::Get(type); + if (!as->IsWithinMapBounds(0, tile)) return -1; + if (_settings_game.economy.station_noise_level) { - const AirportSpec *as = ::AirportSpec::Get(type); AirportTileTableIterator it(as->table[0], tile); uint dist; AirportGetNearestTown(as, it, dist); @@ -155,6 +157,8 @@ if (!IsAirportInformationAvailable(type)) return INVALID_TOWN; const AirportSpec *as = AirportSpec::Get(type); + if (!as->IsWithinMapBounds(0, tile)) return INVALID_TOWN; + uint dist; return AirportGetNearestTown(as, AirportTileTableIterator(as->table[0], tile), dist)->index; } |