From a8960f64be1a7796e90e2634fc2a5419e369f0b5 Mon Sep 17 00:00:00 2001 From: truebrain Date: Sat, 10 Dec 2011 21:07:04 +0000 Subject: (svn r23486) -Fix (r22764): 3 for the price of 1: fix up ScriptTile::GetTownAuthority() (tnx to Torrasque for reporting) --- src/script/api/script_tile.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/script/api') diff --git a/src/script/api/script_tile.cpp b/src/script/api/script_tile.cpp index b898b9c15..c0855b902 100644 --- a/src/script/api/script_tile.cpp +++ b/src/script/api/script_tile.cpp @@ -270,16 +270,22 @@ /* static */ TownID ScriptTile::GetTownAuthority(TileIndex tile) { - if (!::IsValidTile(tile)) return false; + if (!::IsValidTile(tile)) return INVALID_TOWN; - return ::ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority)->index; + Town *town = ::ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority); + if (town == NULL) return INVALID_TOWN; + + return town->index; } /* static */ TownID ScriptTile::GetClosestTown(TileIndex tile) { if (!::IsValidTile(tile)) return INVALID_TOWN; - return ::ClosestTownFromTile(tile, UINT_MAX)->index; + Town *town = ::ClosestTownFromTile(tile, UINT_MAX); + if (town == NULL) return INVALID_TOWN; + + return town->index; } /* static */ Money ScriptTile::GetBuildCost(BuildType build_type) -- cgit v1.2.3-70-g09d2