From ff33ed94ceef4dabb45b5f8ccbae81a1c4402ba6 Mon Sep 17 00:00:00 2001 From: smatz Date: Fri, 26 Jun 2009 15:08:54 +0000 Subject: (svn r16667) -Codechange: replace GetRandomTown() and GetRandomIndustry() by Town::GetRandom() and Industry::GetRandom() --- src/town.h | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) (limited to 'src/town.h') 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) -- cgit v1.2.3-54-g00ecf