diff options
Diffstat (limited to 'src/industry.h')
-rw-r--r-- | src/industry.h | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/src/industry.h b/src/industry.h index 7bd1ead44..63843ad00 100644 --- a/src/industry.h +++ b/src/industry.h @@ -135,6 +135,8 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { Industry(TileIndex tile = INVALID_TILE) : xy(tile) {} ~Industry(); + + static Industry *GetRandom(); }; struct IndustryTileTable { @@ -300,30 +302,6 @@ static inline void ResetIndustryCounts() memset(&_industry_counts, 0, sizeof(_industry_counts)); } -/** - * Return a random valid industry. - */ -static inline Industry *GetRandomIndustry() -{ - if (Industry::GetNumItems() == 0) return NULL; - - int num = RandomRange((uint16)Industry::GetNumItems()); - IndustryID index = INVALID_INDUSTRY; - - while (num >= 0) { - num--; - index++; - - /* Make sure we have a valid industry */ - while (!Industry::IsValidID(index)) { - index++; - assert(index < Industry::GetPoolSize()); - } - } - - return Industry::Get(index); -} - #define FOR_ALL_INDUSTRIES_FROM(var, start) FOR_ALL_ITEMS_FROM(Industry, industry_index, var, start) #define FOR_ALL_INDUSTRIES(var) FOR_ALL_INDUSTRIES_FROM(var, 0) |