tron@2186: /* $Id$ */ tron@2186: truelight@0: #ifndef INDUSTRY_H truelight@0: #define INDUSTRY_H truelight@0: truelight@1267: #include "pool.h" truelight@1267: truelight@0: struct Industry { truelight@0: TileIndex xy; truelight@0: byte width; /* swapped order of w/h with town */ truelight@0: byte height; truelight@0: Town *town; truelight@0: byte produced_cargo[2]; truelight@0: uint16 cargo_waiting[2]; truelight@0: byte production_rate[2]; truelight@0: byte accepts_cargo[3]; truelight@0: byte prod_level; truelight@0: uint16 last_mo_production[2]; truelight@0: uint16 last_mo_transported[2]; truelight@0: byte pct_transported[2]; truelight@0: uint16 total_production[2]; truelight@0: uint16 total_transported[2]; truelight@0: uint16 counter; truelight@0: truelight@0: byte type; truelight@0: byte owner; truelight@0: byte color_map; truelight@0: byte last_prod_year; truelight@0: byte was_cargo_delivered; truelight@919: truelight@919: uint16 index; truelight@0: }; truelight@0: truelight@1267: extern MemoryPool _industry_pool; truelight@919: truelight@1267: /** matthijs@1330: * Check if an Industry really exists. matthijs@1330: */ matthijs@1330: static inline bool IsValidIndustry(Industry* industry) matthijs@1330: { matthijs@1330: return industry->xy != 0; /* XXX: Replace by INVALID_TILE someday */ matthijs@1330: } matthijs@1330: matthijs@1330: /** truelight@1267: * Get the pointer to the industry with index 'index' truelight@1267: */ truelight@1267: static inline Industry *GetIndustry(uint index) truelight@1267: { truelight@1267: return (Industry*)GetItemFromPool(&_industry_pool, index); truelight@1267: } truelight@1267: truelight@1267: /** truelight@1267: * Get the current size of the IndustryPool truelight@1267: */ truelight@1267: static inline uint16 GetIndustryPoolSize(void) truelight@1267: { truelight@1267: return _industry_pool.total_items; truelight@1267: } truelight@1267: truelight@1267: #define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1 < GetIndustryPoolSize()) ? GetIndustry(i->index + 1) : NULL) truelight@1267: #define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0) truelight@1267: truelight@1267: VARDEF int _total_industries; // For the AI: the amount of industries active truelight@919: truelight@919: VARDEF uint16 *_industry_sort; truelight@1267: VARDEF bool _industry_sort_dirty; truelight@919: truelight@0: void DeleteIndustry(Industry *is); truelight@0: truelight@0: enum { truelight@0: IT_COAL_MINE = 0, truelight@0: IT_POWER_STATION = 1, truelight@0: IT_SAWMILL = 2, truelight@0: IT_FOREST = 3, truelight@0: IT_OIL_REFINERY = 4, truelight@0: IT_OIL_RIG = 5, truelight@0: IT_FACTORY = 6, truelight@0: IT_PRINTING_WORKS = 7, truelight@0: IT_STEEL_MILL = 8, truelight@0: IT_FARM = 9, truelight@0: IT_COPPER_MINE = 10, truelight@0: IT_OIL_WELL = 11, truelight@0: IT_BANK = 12, truelight@0: IT_FOOD_PROCESS = 13, truelight@0: IT_PAPER_MILL = 14, truelight@0: IT_GOLD_MINE = 15, truelight@0: IT_BANK_2 = 16, truelight@0: IT_DIAMOND_MINE = 17, truelight@0: IT_IRON_MINE = 18, truelight@0: IT_FRUIT_PLANTATION = 19, truelight@0: IT_RUBBER_PLANTATION = 20, truelight@0: IT_WATER_SUPPLY = 21, truelight@0: IT_WATER_TOWER = 22, truelight@0: IT_FACTORY_2 = 23, truelight@0: IT_FARM_2 = 24, truelight@0: IT_LUMBER_MILL = 25, truelight@0: IT_COTTON_CANDY = 26, truelight@0: IT_CANDY_FACTORY = 27, truelight@0: IT_BATTERY_FARM = 28, truelight@0: IT_COLA_WELLS = 29, truelight@0: IT_TOY_SHOP = 30, truelight@0: IT_TOY_FACTORY = 31, truelight@0: IT_PLASTIC_FOUNTAINS = 32, truelight@0: IT_FIZZY_DRINK_FACTORY = 33, truelight@0: IT_BUBBLE_GENERATOR = 34, truelight@0: IT_TOFFEE_QUARRY = 35, truelight@0: IT_SUGAR_MINE = 36, truelight@0: }; truelight@0: Darkvater@2436: #endif /* INDUSTRY_H */