summaryrefslogtreecommitdiff
path: root/src/industry.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-03-20 14:30:16 +0000
committerfrosch <frosch@openttd.org>2010-03-20 14:30:16 +0000
commit116a5f56a4c1362446bcf921e4436a19057d105e (patch)
treeeeb12e8765bc1997310546c701043efd81c9b410 /src/industry.h
parente27e5febb60f1cd2a2c70b100652c9365d97dbbd (diff)
downloadopenttd-116a5f56a4c1362446bcf921e4436a19057d105e.tar.xz
(svn r19481) -Codechange: Turn _industry_counts into a static member of Industry.
Diffstat (limited to 'src/industry.h')
-rw-r--r--src/industry.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/industry.h b/src/industry.h
index 99ba24924..63c647a77 100644
--- a/src/industry.h
+++ b/src/industry.h
@@ -78,6 +78,48 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> {
static Industry *GetRandom();
static void PostDestructor(size_t index);
+
+ /**
+ * Increment the count of industries for this type.
+ * @param type IndustryType to increment
+ * @pre type < NUM_INDUSTRYTYPES
+ */
+ static inline void IncIndustryTypeCount(IndustryType type)
+ {
+ assert(type < NUM_INDUSTRYTYPES);
+ counts[type]++;
+ }
+
+ /**
+ * Decrement the count of industries for this type.
+ * @param type IndustryType to decrement
+ * @pre type < NUM_INDUSTRYTYPES
+ */
+ static inline void DecIndustryTypeCount(IndustryType type)
+ {
+ assert(type < NUM_INDUSTRYTYPES);
+ counts[type]--;
+ }
+
+ /**
+ * Get the count of industries for this type.
+ * @param type IndustryType to query
+ * @pre type < NUM_INDUSTRYTYPES
+ */
+ static inline uint16 GetIndustryTypeCount(IndustryType type)
+ {
+ assert(type < NUM_INDUSTRYTYPES);
+ return counts[type];
+ }
+
+ /** Resets industry counts. */
+ static inline void ResetIndustryCounts()
+ {
+ memset(&counts, 0, sizeof(counts));
+ }
+
+protected:
+ static uint16 counts[NUM_INDUSTRYTYPES]; ///< Number of industries per type ingame
};
void PlantRandomFarmField(const Industry *i);