summaryrefslogtreecommitdiff
path: root/src/script/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/script_tile.cpp12
1 files changed, 9 insertions, 3 deletions
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)