(svn r16746) -Codechange: use Town::PostDestructor() instead of not very clean construct for invalidating nearest town for road tiles

This commit is contained in:
smatz
2009-07-05 13:21:51 +00:00
parent c861d9b64b
commit 59f94619c7
4 changed files with 16 additions and 7 deletions

View File

@@ -102,8 +102,17 @@ Town::~Town()
DeleteSubsidyWithTown(this->index);
MarkWholeScreenDirty();
}
UpdateNearestTownForRoadTiles(false, this);
/**
* Invalidating of the "nearest town cache" has to be done
* after removing item from the pool.
* @param index index of deleted item
*/
void Town::PostDestructor(size_t index)
{
UpdateNearestTownForRoadTiles(false);
}
/**
@@ -2694,14 +2703,13 @@ bool CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags)
}
Town *CalcClosestTownFromTile(TileIndex tile, uint threshold, const Town *ignore)
Town *CalcClosestTownFromTile(TileIndex tile, uint threshold)
{
Town *t;
uint best = threshold;
Town *best_town = NULL;
FOR_ALL_TOWNS(t) {
if (t == ignore) continue;
uint dist = DistanceManhattan(tile, t->xy);
if (dist < best) {
best = dist;