(svn r16667) -Codechange: replace GetRandomTown() and GetRandomIndustry() by Town::GetRandom() and Industry::GetRandom()

This commit is contained in:
smatz
2009-06-26 15:08:54 +00:00
parent 0e5af86ead
commit 873a205ae6
5 changed files with 60 additions and 52 deletions

View File

@@ -140,6 +140,8 @@ struct Town : TownPool::PoolItem<&_town_pool> {
{
return Town::Get(GetTownIndex(tile));
}
static Town *GetRandom();
};
uint32 GetWorldPopulation();
@@ -179,28 +181,6 @@ bool CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type);
TileIndexDiff GetHouseNorthPart(HouseID &house);
/**
* Return a random valid town.
*/
static inline Town *GetRandomTown()
{
int num = RandomRange((uint16)Town::GetNumItems());
TownID index = INVALID_TOWN;
while (num >= 0) {
num--;
index++;
/* Make sure we have a valid town */
while (!Town::IsValidID(index)) {
index++;
assert(index < Town::GetPoolSize());
}
}
return Town::Get(index);
}
Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX, const Town *ignore = NULL);
#define FOR_ALL_TOWNS_FROM(var, start) FOR_ALL_ITEMS_FROM(Town, town_index, var, start)