summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-10 21:07:04 +0000
committertruebrain <truebrain@openttd.org>2011-12-10 21:07:04 +0000
commita8960f64be1a7796e90e2634fc2a5419e369f0b5 (patch)
tree36e7cf51c3e0c39679653c9ffe6f6b6b41199991 /src/script
parent14c6a7465ae14690b84a5b5e1c8cf98b09a4e87e (diff)
downloadopenttd-a8960f64be1a7796e90e2634fc2a5419e369f0b5.tar.xz
(svn r23486) -Fix (r22764): 3 for the price of 1: fix up ScriptTile::GetTownAuthority() (tnx to Torrasque for reporting)
Diffstat (limited to 'src/script')
-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)