summaryrefslogtreecommitdiff
path: root/src/industry.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/industry.h
parentb668c24d463ca8059fd9be59efddb39298de9646 (diff)
downloadopenttd-ff33ed94ceef4dabb45b5f8ccbae81a1c4402ba6.tar.xz
(svn r16667) -Codechange: replace GetRandomTown() and GetRandomIndustry() by Town::GetRandom() and Industry::GetRandom()
Diffstat (limited to 'src/industry.h')
-rw-r--r--src/industry.h26
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)