author | tron |
Sun, 17 Jul 2005 20:14:58 +0000 | |
changeset 2116 | 23031555ff54 |
parent 1330 | 5d76a0522a11 |
child 2186 | db48cf29b983 |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef INDUSTRY_H |
2 |
#define INDUSTRY_H |
|
3 |
||
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
4 |
#include "pool.h" |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
5 |
|
0 | 6 |
struct Industry { |
7 |
TileIndex xy; |
|
8 |
byte width; /* swapped order of w/h with town */ |
|
9 |
byte height; |
|
10 |
Town *town; |
|
11 |
byte produced_cargo[2]; |
|
12 |
uint16 cargo_waiting[2]; |
|
13 |
byte production_rate[2]; |
|
14 |
byte accepts_cargo[3]; |
|
15 |
byte prod_level; |
|
16 |
uint16 last_mo_production[2]; |
|
17 |
uint16 last_mo_transported[2]; |
|
18 |
byte pct_transported[2]; |
|
19 |
uint16 total_production[2]; |
|
20 |
uint16 total_transported[2]; |
|
21 |
uint16 counter; |
|
22 |
||
23 |
byte type; |
|
24 |
byte owner; |
|
25 |
byte color_map; |
|
26 |
byte last_prod_year; |
|
27 |
byte was_cargo_delivered; |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
830
diff
changeset
|
28 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
830
diff
changeset
|
29 |
uint16 index; |
0 | 30 |
}; |
31 |
||
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
32 |
extern MemoryPool _industry_pool; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
830
diff
changeset
|
33 |
|
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
34 |
/** |
1330
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1267
diff
changeset
|
35 |
* Check if an Industry really exists. |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1267
diff
changeset
|
36 |
*/ |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1267
diff
changeset
|
37 |
static inline bool IsValidIndustry(Industry* industry) |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1267
diff
changeset
|
38 |
{ |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1267
diff
changeset
|
39 |
return industry->xy != 0; /* XXX: Replace by INVALID_TILE someday */ |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1267
diff
changeset
|
40 |
} |
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1267
diff
changeset
|
41 |
|
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1267
diff
changeset
|
42 |
/** |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
43 |
* Get the pointer to the industry with index 'index' |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
44 |
*/ |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
45 |
static inline Industry *GetIndustry(uint index) |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
46 |
{ |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
47 |
return (Industry*)GetItemFromPool(&_industry_pool, index); |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
48 |
} |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
49 |
|
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
50 |
/** |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
51 |
* Get the current size of the IndustryPool |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
52 |
*/ |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
53 |
static inline uint16 GetIndustryPoolSize(void) |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
54 |
{ |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
55 |
return _industry_pool.total_items; |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
56 |
} |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
57 |
|
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
58 |
#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1 < GetIndustryPoolSize()) ? GetIndustry(i->index + 1) : NULL) |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
59 |
#define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0) |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
60 |
|
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
61 |
VARDEF int _total_industries; // For the AI: the amount of industries active |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
830
diff
changeset
|
62 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
830
diff
changeset
|
63 |
VARDEF uint16 *_industry_sort; |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1220
diff
changeset
|
64 |
VARDEF bool _industry_sort_dirty; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
830
diff
changeset
|
65 |
|
0 | 66 |
void DeleteIndustry(Industry *is); |
67 |
||
68 |
enum { |
|
69 |
IT_COAL_MINE = 0, |
|
70 |
IT_POWER_STATION = 1, |
|
71 |
IT_SAWMILL = 2, |
|
72 |
IT_FOREST = 3, |
|
73 |
IT_OIL_REFINERY = 4, |
|
74 |
IT_OIL_RIG = 5, |
|
75 |
IT_FACTORY = 6, |
|
76 |
IT_PRINTING_WORKS = 7, |
|
77 |
IT_STEEL_MILL = 8, |
|
78 |
IT_FARM = 9, |
|
79 |
IT_COPPER_MINE = 10, |
|
80 |
IT_OIL_WELL = 11, |
|
81 |
IT_BANK = 12, |
|
82 |
IT_FOOD_PROCESS = 13, |
|
83 |
IT_PAPER_MILL = 14, |
|
84 |
IT_GOLD_MINE = 15, |
|
85 |
IT_BANK_2 = 16, |
|
86 |
IT_DIAMOND_MINE = 17, |
|
87 |
IT_IRON_MINE = 18, |
|
88 |
IT_FRUIT_PLANTATION = 19, |
|
89 |
IT_RUBBER_PLANTATION = 20, |
|
90 |
IT_WATER_SUPPLY = 21, |
|
91 |
IT_WATER_TOWER = 22, |
|
92 |
IT_FACTORY_2 = 23, |
|
93 |
IT_FARM_2 = 24, |
|
94 |
IT_LUMBER_MILL = 25, |
|
95 |
IT_COTTON_CANDY = 26, |
|
96 |
IT_CANDY_FACTORY = 27, |
|
97 |
IT_BATTERY_FARM = 28, |
|
98 |
IT_COLA_WELLS = 29, |
|
99 |
IT_TOY_SHOP = 30, |
|
100 |
IT_TOY_FACTORY = 31, |
|
101 |
IT_PLASTIC_FOUNTAINS = 32, |
|
102 |
IT_FIZZY_DRINK_FACTORY = 33, |
|
103 |
IT_BUBBLE_GENERATOR = 34, |
|
104 |
IT_TOFFEE_QUARRY = 35, |
|
105 |
IT_SUGAR_MINE = 36, |
|
106 |
}; |
|
107 |
||
108 |
#endif |