summaryrefslogtreecommitdiff
path: root/src/town.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-06-26 15:08:54 +0000
committersmatz <smatz@openttd.org>2009-06-26 15:08:54 +0000
commitff33ed94ceef4dabb45b5f8ccbae81a1c4402ba6 (patch)
tree7772bd531c7e63794d47fdeecfea6399fe5697a6 /src/town.h
parentb668c24d463ca8059fd9be59efddb39298de9646 (diff)
downloadopenttd-ff33ed94ceef4dabb45b5f8ccbae81a1c4402ba6.tar.xz
(svn r16667) -Codechange: replace GetRandomTown() and GetRandomIndustry() by Town::GetRandom() and Industry::GetRandom()
Diffstat (limited to 'src/town.h')
-rw-r--r--src/town.h24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/town.h b/src/town.h
index f4cdf3e37..c65569ad1 100644
--- a/src/town.h
+++ b/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)