Codechange: Check airport layout would fit within map bounds before iterating tiles. (#7429)

This commit is contained in:
PeterN
2019-03-30 22:20:26 +00:00
committed by GitHub
parent 32fda83d39
commit e1069eee05
4 changed files with 25 additions and 1 deletions

View File

@@ -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;
}