(svn r16667) -Codechange: replace GetRandomTown() and GetRandomIndustry() by Town::GetRandom() and Industry::GetRandom()
This commit is contained in:
24
src/town.h
24
src/town.h
@@ -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)
|
||||
|
Reference in New Issue
Block a user