84 }; |
84 }; |
85 |
85 |
86 |
86 |
87 DECLARE_ENUM_AS_BIT_SET(IndustyBehaviour); |
87 DECLARE_ENUM_AS_BIT_SET(IndustyBehaviour); |
88 |
88 |
|
89 struct Industry; |
|
90 DECLARE_OLD_POOL(Industry, Industry, 3, 8000) |
|
91 |
89 /** |
92 /** |
90 * Defines the internal data of a functionnal industry |
93 * Defines the internal data of a functionnal industry |
91 */ |
94 */ |
92 struct Industry { |
95 struct Industry : PoolItem<Industry, IndustryID, &_Industry_pool> { |
93 TileIndex xy; ///< coordinates of the primary tile the industry is built one |
96 TileIndex xy; ///< coordinates of the primary tile the industry is built one |
94 byte width; |
97 byte width; |
95 byte height; |
98 byte height; |
96 const Town *town; ///< Nearest town |
99 const Town *town; ///< Nearest town |
97 uint16 produced_cargo_waiting[2]; ///< amount of cargo produced per cargo |
100 uint16 produced_cargo_waiting[2]; ///< amount of cargo produced per cargo |
103 byte last_month_pct_transported[2]; ///< percentage transported per cargo in the last full month |
106 byte last_month_pct_transported[2]; ///< percentage transported per cargo in the last full month |
104 uint16 last_month_production[2]; ///< total units produced per cargo in the last full month |
107 uint16 last_month_production[2]; ///< total units produced per cargo in the last full month |
105 uint16 last_month_transported[2]; ///< total units transported per cargo in the last full month |
108 uint16 last_month_transported[2]; ///< total units transported per cargo in the last full month |
106 uint16 counter; ///< used for animation and/or production (if available cargo) |
109 uint16 counter; ///< used for animation and/or production (if available cargo) |
107 |
110 |
108 IndustryType type; ///< type of industry. see IT_COAL_MINE and others |
111 IndustryType type; ///< type of industry. |
109 OwnerByte owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE |
112 OwnerByte owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE |
110 byte random_color; ///< randomized colour of the industry, for display purpose |
113 byte random_color; ///< randomized colour of the industry, for display purpose |
111 Year last_prod_year; ///< last year of production |
114 Year last_prod_year; ///< last year of production |
112 byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry |
115 byte was_cargo_delivered; ///< flag that indicate this has been the closest industry chosen for cargo delivery by a station. see DeliverGoodsToIndustry |
113 |
116 |
114 IndustryID index; ///< index of the industry in the pool of industries |
|
115 |
|
116 OwnerByte founder; ///< Founder of the industry |
117 OwnerByte founder; ///< Founder of the industry |
117 Date construction_date; ///< Date of the construction of the industry |
118 Date construction_date; ///< Date of the construction of the industry |
118 uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType) |
119 uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType) |
119 Date last_cargo_accepted_at; ///< Last day cargo was accepted by this industry |
120 Date last_cargo_accepted_at; ///< Last day cargo was accepted by this industry |
|
121 |
|
122 Industry(TileIndex tile = 0) : xy(tile) {} |
|
123 ~Industry(); |
|
124 |
|
125 bool IsValid() const { return this->xy != 0; } |
120 }; |
126 }; |
121 |
127 |
122 struct IndustryTileTable { |
128 struct IndustryTileTable { |
123 TileIndexDiffC ti; |
129 TileIndexDiffC ti; |
124 IndustryGfx gfx; |
130 IndustryGfx gfx; |
203 struct GRFFileProps grf_prop; |
209 struct GRFFileProps grf_prop; |
204 }; |
210 }; |
205 |
211 |
206 /* industry_cmd.cpp*/ |
212 /* industry_cmd.cpp*/ |
207 const IndustrySpec *GetIndustrySpec(IndustryType thistype); ///< Array of industries data |
213 const IndustrySpec *GetIndustrySpec(IndustryType thistype); ///< Array of industries data |
208 const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx); ///< Array of industry tiles data |
214 const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx, bool full_check = true); ///< Array of industry tiles data |
209 void ResetIndustries(); |
215 void ResetIndustries(); |
210 void PlantRandomFarmField(const Industry *i); |
216 void PlantRandomFarmField(const Industry *i); |
211 |
217 |
212 /* writable arrays of specs */ |
218 /* writable arrays of specs */ |
213 extern IndustrySpec _industry_specs[NUM_INDUSTRYTYPES]; |
219 extern IndustrySpec _industry_specs[NUM_INDUSTRYTYPES]; |
214 extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES]; |
220 extern IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES]; |
215 |
221 |
216 /* smallmap_gui.cpp */ |
222 /* smallmap_gui.cpp */ |
217 void BuildIndustriesLegend(); |
223 void BuildIndustriesLegend(); |
218 |
224 |
219 DECLARE_OLD_POOL(Industry, Industry, 3, 8000) |
|
220 |
|
221 /** |
|
222 * Check if an Industry really exists. |
|
223 * @param industry to check |
|
224 * @return true if position is a valid one |
|
225 */ |
|
226 static inline bool IsValidIndustry(const Industry *industry) |
|
227 { |
|
228 return industry->xy != 0; |
|
229 } |
|
230 |
|
231 /** |
225 /** |
232 * Check if an Industry exists whithin the pool of industries |
226 * Check if an Industry exists whithin the pool of industries |
233 * @param index of the desired industry |
227 * @param index of the desired industry |
234 * @return true if it is inside the pool |
228 * @return true if it is inside the pool |
235 */ |
229 */ |
236 static inline bool IsValidIndustryID(IndustryID index) |
230 static inline bool IsValidIndustryID(IndustryID index) |
237 { |
231 { |
238 return index < GetIndustryPoolSize() && IsValidIndustry(GetIndustry(index)); |
232 return index < GetIndustryPoolSize() && GetIndustry(index)->IsValid(); |
239 } |
233 } |
240 |
234 |
241 |
235 |
242 static inline IndustryID GetMaxIndustryIndex() |
236 static inline IndustryID GetMaxIndustryIndex() |
243 { |
237 { |
316 } |
310 } |
317 |
311 |
318 return GetIndustry(index); |
312 return GetIndustry(index); |
319 } |
313 } |
320 |
314 |
321 void DestroyIndustry(Industry *i); |
315 #define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1U < GetIndustryPoolSize()) ? GetIndustry(i->index + 1U) : NULL) if (i->IsValid()) |
322 |
|
323 static inline void DeleteIndustry(Industry *i) |
|
324 { |
|
325 DestroyIndustry(i); |
|
326 i->xy = 0; |
|
327 } |
|
328 |
|
329 #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)) |
|
330 #define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0) |
316 #define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0) |
331 |
317 |
332 extern const Industry **_industry_sort; |
318 extern const Industry **_industry_sort; |
333 extern bool _industry_sort_dirty; |
319 extern bool _industry_sort_dirty; |
334 |
320 |
335 enum { |
321 static const uint8 IT_INVALID = 255; |
336 IT_COAL_MINE = 0, |
|
337 IT_POWER_STATION = 1, |
|
338 IT_SAWMILL = 2, |
|
339 IT_FOREST = 3, |
|
340 IT_OIL_REFINERY = 4, |
|
341 IT_OIL_RIG = 5, |
|
342 IT_FACTORY = 6, |
|
343 IT_PRINTING_WORKS = 7, |
|
344 IT_STEEL_MILL = 8, |
|
345 IT_FARM = 9, |
|
346 IT_COPPER_MINE = 10, |
|
347 IT_OIL_WELL = 11, |
|
348 IT_BANK_TEMP = 12, |
|
349 IT_FOOD_PROCESS = 13, |
|
350 IT_PAPER_MILL = 14, |
|
351 IT_GOLD_MINE = 15, |
|
352 IT_BANK_TROPIC_ARCTIC = 16, |
|
353 IT_DIAMOND_MINE = 17, |
|
354 IT_IRON_MINE = 18, |
|
355 IT_FRUIT_PLANTATION = 19, |
|
356 IT_RUBBER_PLANTATION = 20, |
|
357 IT_WATER_SUPPLY = 21, |
|
358 IT_WATER_TOWER = 22, |
|
359 IT_FACTORY_2 = 23, |
|
360 IT_FARM_2 = 24, |
|
361 IT_LUMBER_MILL = 25, |
|
362 IT_COTTON_CANDY = 26, |
|
363 IT_CANDY_FACTORY = 27, |
|
364 IT_BATTERY_FARM = 28, |
|
365 IT_COLA_WELLS = 29, |
|
366 IT_TOY_SHOP = 30, |
|
367 IT_TOY_FACTORY = 31, |
|
368 IT_PLASTIC_FOUNTAINS = 32, |
|
369 IT_FIZZY_DRINK_FACTORY = 33, |
|
370 IT_BUBBLE_GENERATOR = 34, |
|
371 IT_TOFFEE_QUARRY = 35, |
|
372 IT_SUGAR_MINE = 36, |
|
373 IT_END, |
|
374 IT_INVALID = 255, |
|
375 }; |
|
376 |
322 |
377 #endif /* INDUSTRY_H */ |
323 #endif /* INDUSTRY_H */ |