summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-12-09 19:30:30 +0000
committeryexo <yexo@openttd.org>2011-12-09 19:30:30 +0000
commitc9be5d50dac64fe9fefe1a1e85d4eeaf8cc2470c (patch)
treeb9ca1f44038117b6c621e448b6e87e2a2897685b /src/script
parent42c4fdf9ab6c9123609afdf5a0dde3f3164795fd (diff)
downloadopenttd-c9be5d50dac64fe9fefe1a1e85d4eeaf8cc2470c.tar.xz
(svn r23461) -Fix: handle a missing airport newgrf as graceful as possible by not crashing when loading such savegame or when an airport is removed
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/script_airport.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/script/api/script_airport.cpp b/src/script/api/script_airport.cpp
index d040d3094..43f809057 100644
--- a/src/script/api/script_airport.cpp
+++ b/src/script/api/script_airport.cpp
@@ -127,16 +127,17 @@
/* static */ int ScriptAirport::GetNoiseLevelIncrease(TileIndex tile, AirportType type)
{
- extern Town *AirportGetNearestTown(const AirportSpec *as, byte layout, TileIndex airport_tile);
- extern uint8 GetAirportNoiseLevelForTown(const AirportSpec *as, byte layout, TileIndex town_tile, TileIndex tile);
+ extern Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it);
+ extern uint8 GetAirportNoiseLevelForTown(const AirportSpec *as, TileIterator &it, TileIndex town_tile);
if (!::IsValidTile(tile)) return -1;
if (!IsAirportInformationAvailable(type)) return -1;
if (_settings_game.economy.station_noise_level) {
const AirportSpec *as = ::AirportSpec::Get(type);
- const Town *t = AirportGetNearestTown(as, 0, tile);
- return GetAirportNoiseLevelForTown(as, 0, t->xy, tile);
+ AirportTileTableIterator it(as->table[0], tile);
+ const Town *t = AirportGetNearestTown(as, it);
+ return GetAirportNoiseLevelForTown(as, it, t->xy);
}
return 1;
@@ -144,12 +145,13 @@
/* static */ TownID ScriptAirport::GetNearestTown(TileIndex tile, AirportType type)
{
- extern Town *AirportGetNearestTown(const AirportSpec *as, byte layout, TileIndex airport_tile);
+ extern Town *AirportGetNearestTown(const AirportSpec *as, const TileIterator &it);
if (!::IsValidTile(tile)) return INVALID_TOWN;
if (!IsAirportInformationAvailable(type)) return INVALID_TOWN;
- return AirportGetNearestTown(AirportSpec::Get(type), 0, tile)->index;
+ const AirportSpec *as = AirportSpec::Get(type);
+ return AirportGetNearestTown(as, AirportTileTableIterator(as->table[0], tile))->index;
}
/* static */ uint16 ScriptAirport::GetMaintenanceCostFactor(AirportType type)