summaryrefslogtreecommitdiff
path: root/town_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-06-08 18:31:54 +0000
committertron <tron@openttd.org>2006-06-08 18:31:54 +0000
commit7c1f1d823f059e3e8c8a336b6acb819c0ee5a03c (patch)
tree1721f3f0ea1d8ad323751b7106f968c10d52a3b2 /town_cmd.c
parentb690e85604ce3f024dab32bf19a23afe992090e7 (diff)
downloadopenttd-7c1f1d823f059e3e8c8a336b6acb819c0ee5a03c.tar.xz
(svn r5171) Get rid of an ungly hack in the load routine, which temporarily turned house and road tiles into void tiles to calculate the closest town
Diffstat (limited to 'town_cmd.c')
-rw-r--r--town_cmd.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/town_cmd.c b/town_cmd.c
index 2c7a8653c..753be77b4 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -1739,18 +1739,12 @@ bool CheckIfAuthorityAllows(TileIndex tile)
}
-Town *ClosestTownFromTile(TileIndex tile, uint threshold)
+Town* CalcClosestTownFromTile(TileIndex tile, uint threshold)
{
Town *t;
uint dist, best = threshold;
Town *best_town = NULL;
- if (IsTileType(tile, MP_HOUSE) || (
- IsTileType(tile, MP_STREET) &&
- (IsLevelCrossing(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile)) == OWNER_TOWN
- ))
- return GetTownByTile(tile);
-
FOR_ALL_TOWNS(t) {
if (t->xy != 0) {
dist = DistanceManhattan(tile, t->xy);
@@ -1764,6 +1758,20 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold)
return best_town;
}
+
+Town *ClosestTownFromTile(TileIndex tile, uint threshold)
+{
+ if (IsTileType(tile, MP_HOUSE) || (
+ IsTileType(tile, MP_STREET) &&
+ (IsLevelCrossing(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile)) == OWNER_TOWN
+ )) {
+ return GetTownByTile(tile);
+ } else {
+ return CalcClosestTownFromTile(tile, threshold);
+ }
+}
+
+
void ChangeTownRating(Town *t, int add, int max)
{
int rating;