diff options
Diffstat (limited to 'town_cmd.c')
-rw-r--r-- | town_cmd.c | 22 |
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; |