(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

This commit is contained in:
tron
2006-06-08 18:31:54 +00:00
parent f2da689343
commit 047ee8a601
3 changed files with 37 additions and 26 deletions

View File

@@ -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;