equal
deleted
inserted
replaced
78 StringID production_down_text; |
78 StringID production_down_text; |
79 } IndustrySpec; |
79 } IndustrySpec; |
80 |
80 |
81 const IndustrySpec *GetIndustrySpec(IndustryType thistype); |
81 const IndustrySpec *GetIndustrySpec(IndustryType thistype); |
82 |
82 |
83 extern MemoryPool _industry_pool; |
83 DECLARE_POOL(Industry, Industry, 3, 8000) |
84 |
84 |
85 /** |
85 /** |
86 * Check if an Industry really exists. |
86 * Check if an Industry really exists. |
87 */ |
87 */ |
88 static inline bool IsValidIndustry(const Industry *industry) |
88 static inline bool IsValidIndustry(const Industry *industry) |
89 { |
89 { |
90 return industry->xy != 0; |
90 return industry->xy != 0; |
91 } |
|
92 |
|
93 /** |
|
94 * Get the pointer to the industry with index 'index' |
|
95 */ |
|
96 static inline Industry *GetIndustry(uint index) |
|
97 { |
|
98 return (Industry*)GetItemFromPool(&_industry_pool, index); |
|
99 } |
|
100 |
|
101 /** |
|
102 * Get the current size of the IndustryPool |
|
103 */ |
|
104 static inline uint16 GetIndustryPoolSize(void) |
|
105 { |
|
106 return _industry_pool.total_items; |
|
107 } |
91 } |
108 |
92 |
109 VARDEF int _total_industries; |
93 VARDEF int _total_industries; |
110 |
94 |
111 static inline IndustryID GetIndustryArraySize(void) |
95 static inline IndustryID GetIndustryArraySize(void) |
148 { |
132 { |
149 DestroyIndustry(i); |
133 DestroyIndustry(i); |
150 i->xy = 0; |
134 i->xy = 0; |
151 } |
135 } |
152 |
136 |
153 #define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1 < GetIndustryPoolSize()) ? GetIndustry(i->index + 1) : NULL) if (IsValidIndustry(i)) |
137 #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)) |
154 #define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0) |
138 #define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0) |
155 |
139 |
156 VARDEF const Industry** _industry_sort; |
140 VARDEF const Industry** _industry_sort; |
157 VARDEF bool _industry_sort_dirty; |
141 VARDEF bool _industry_sort_dirty; |
158 |
142 |