diff options
author | belugas <belugas@openttd.org> | 2007-06-08 15:48:48 +0000 |
---|---|---|
committer | belugas <belugas@openttd.org> | 2007-06-08 15:48:48 +0000 |
commit | 7586143e3bafe14247953cc3c0b322d32ffe3ac8 (patch) | |
tree | 1ec1fab628f3051f606766e71174e557523e5c28 /src/industry.h | |
parent | 9c66082b079af7f608d033225c1544558c93a715 (diff) | |
download | openttd-7586143e3bafe14247953cc3c0b322d32ffe3ac8.tar.xz |
(svn r10063) -Codechange: Change VARDEF for extern
-CodeChange: Add the count of industries, basic support for variable 67, var action02 forindustries
Diffstat (limited to 'src/industry.h')
-rw-r--r-- | src/industry.h | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/industry.h b/src/industry.h index 09cb34071..38d1dca2f 100644 --- a/src/industry.h +++ b/src/industry.h @@ -197,7 +197,6 @@ static inline bool IsValidIndustryID(IndustryID index) return index < GetIndustryPoolSize() && IsValidIndustry(GetIndustry(index)); } -VARDEF int _total_industries; //general counter static inline IndustryID GetMaxIndustryIndex() { @@ -214,6 +213,36 @@ static inline uint GetNumIndustries() return _total_industries; } +extern int _total_industries; // general counter +extern uint16 _industry_counts[NUM_INDUSTRYTYPES]; // Number of industries per type ingame + +/** Increment the count of industries for this type + * @param type IndustryType to increment + * @pre type < INVALID_INDUSTRYTYPE */ +static inline void IncIndustryTypeCount(IndustryType type) +{ + assert(type < INVALID_INDUSTRYTYPE); + _industry_counts[type]++; +} + +/** Decrement the count of industries for this type + * @param type IndustryType to decrement + * @pre type < INVALID_INDUSTRYTYPE */ +static inline void DecIndustryTypeCount(IndustryType type) +{ + assert(type < INVALID_INDUSTRYTYPE); + _industry_counts[type]--; +} + +/** get the count of industries for this type + * @param type IndustryType to query + * @pre type < INVALID_INDUSTRYTYPE */ +static inline uint8 GetIndustryTypeCount(IndustryType type) +{ + assert(type < INVALID_INDUSTRYTYPE); + return min(_industry_counts[type], 0xFF); // callback expects only a byte, so cut it +} + /** * Return a random valid industry. */ @@ -249,8 +278,8 @@ static inline void DeleteIndustry(Industry *i) #define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1U < GetIndustryPoolSize()) ? GetIndustry(i->index + 1U) : NULL) if (IsValidIndustry(i)) #define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0) -VARDEF const Industry** _industry_sort; -VARDEF bool _industry_sort_dirty; +extern const Industry **_industry_sort; +extern bool _industry_sort_dirty; enum { IT_COAL_MINE = 0, |