author | bjarni |
Thu, 30 Mar 2006 20:14:06 +0000 | |
changeset 3380 | f473785f812c |
parent 3349 | 1ad72db34298 |
child 3432 | 507fa7fd189d |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#ifndef TOWN_H |
4 |
#define TOWN_H |
|
5 |
||
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
6 |
#include "pool.h" |
0 | 7 |
#include "player.h" |
8 |
||
9 |
struct Town { |
|
10 |
TileIndex xy; |
|
11 |
||
12 |
// Current population of people and amount of houses. |
|
13 |
uint16 num_houses; |
|
14 |
uint32 population; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
15 |
|
0 | 16 |
// Town name |
17 |
uint16 townnametype; |
|
18 |
uint32 townnameparts; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
19 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
20 |
// NOSAVE: Location of name sign, UpdateTownVirtCoord updates this. |
0 | 21 |
ViewportSign sign; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
22 |
|
0 | 23 |
// Makes sure we don't build certain house types twice. |
24 |
byte flags12; |
|
25 |
||
26 |
// Which players have a statue? |
|
27 |
byte statues; |
|
28 |
||
29 |
// Player ratings as well as a mask that determines which players have a rating. |
|
30 |
byte have_ratings; |
|
31 |
uint8 unwanted[MAX_PLAYERS]; // how many months companies aren't wanted by towns (bribe) |
|
2498
befad2fe53d2
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2436
diff
changeset
|
32 |
PlayerID exclusivity; // which player has exslusivity |
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
4
diff
changeset
|
33 |
uint8 exclusive_counter; // months till the exclusivity expires |
0 | 34 |
int16 ratings[MAX_PLAYERS]; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
35 |
|
0 | 36 |
// Maximum amount of passengers and mail that can be transported. |
1377
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
37 |
uint32 max_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
38 |
uint32 max_mail; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
39 |
uint32 new_max_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
40 |
uint32 new_max_mail; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
41 |
uint32 act_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
42 |
uint32 act_mail; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
43 |
uint32 new_act_pass; |
2a418162176e
(svn r1881) -Fix: [ 1119308 ] Max passengers / mail variables are now 32 bit
celestar
parents:
1362
diff
changeset
|
44 |
uint32 new_act_mail; |
0 | 45 |
|
46 |
// Amount of passengers that were transported. |
|
47 |
byte pct_pass_transported; |
|
48 |
byte pct_mail_transported; |
|
49 |
||
50 |
// Amount of food and paper that was transported. Actually a bit mask would be enough. |
|
51 |
uint16 act_food; |
|
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
52 |
uint16 act_water; |
0 | 53 |
uint16 new_act_food; |
4
cad62d5f9708
(svn r5) -Fix: townname generation of TTDLX savegames. All work
darkvater
parents:
0
diff
changeset
|
54 |
uint16 new_act_water; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
55 |
|
0 | 56 |
// Time until we rebuild a house. |
57 |
byte time_until_rebuild; |
|
58 |
||
59 |
// When to grow town next time. |
|
60 |
byte grow_counter; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
61 |
byte growth_rate; |
0 | 62 |
|
63 |
// Fund buildings program in action? |
|
64 |
byte fund_buildings_months; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
121
diff
changeset
|
65 |
|
0 | 66 |
// Fund road reconstruction in action? |
67 |
byte road_build_months; |
|
68 |
||
69 |
// Index in town array |
|
3346
96c5db77aa83
(svn r4130) - CodeChange: Add proper semantics for TownID for such variables instead of using the general uint16-type. We probably need to change GetTown() and IsTownIndex() as well to use TownID.
Darkvater
parents:
2958
diff
changeset
|
70 |
TownID index; |
0 | 71 |
|
72 |
// NOSAVE: UpdateTownRadius updates this given the house count. |
|
73 |
uint16 radius[5]; |
|
74 |
}; |
|
75 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1080
diff
changeset
|
76 |
uint32 GetWorldPopulation(void); |
0 | 77 |
|
835
a22d6bc16a51
(svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents:
820
diff
changeset
|
78 |
void UpdateTownVirtCoord(Town *t); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1080
diff
changeset
|
79 |
void InitializeTown(void); |
3346
96c5db77aa83
(svn r4130) - CodeChange: Add proper semantics for TownID for such variables instead of using the general uint16-type. We probably need to change GetTown() and IsTownIndex() as well to use TownID.
Darkvater
parents:
2958
diff
changeset
|
80 |
void ShowTownViewWindow(TownID town); |
0 | 81 |
void DeleteTown(Town *t); |
82 |
void ExpandTown(Town *t); |
|
1362
adfd229bdc01
(svn r1866) -Fix: Intercepted generated maps with 0 towns on it. Currently just an
celestar
parents:
1330
diff
changeset
|
83 |
Town *CreateRandomTown(uint attempts); |
0 | 84 |
|
85 |
enum { |
|
86 |
ROAD_REMOVE = 0, |
|
87 |
UNMOVEABLE_REMOVE = 1, |
|
88 |
TUNNELBRIDGE_REMOVE = 1, |
|
89 |
INDUSTRY_REMOVE = 2 |
|
90 |
}; |
|
91 |
||
1005 | 92 |
enum { |
93 |
// These refer to the maximums, so Appalling is -1000 to -400 |
|
94 |
// MAXIMUM RATINGS BOUNDARIES |
|
95 |
RATING_MINIMUM = -1000, |
|
96 |
RATING_APPALLING = -400, |
|
97 |
RATING_VERYPOOR = -200, |
|
98 |
RATING_POOR = 0, |
|
99 |
RATING_MEDIOCRE = 200, |
|
100 |
RATING_GOOD = 400, |
|
101 |
RATING_VERYGOOD = 600, |
|
102 |
RATING_EXCELLENT = 800, |
|
103 |
RATING_OUTSTANDING= 1000, // OUTSTANDING |
|
104 |
||
105 |
RATING_MAXIMUM = RATING_OUTSTANDING, |
|
106 |
||
107 |
// RATINGS AFFECTING NUMBERS |
|
108 |
RATING_TREE_DOWN_STEP = -35, |
|
109 |
RATING_TREE_MINIMUM = RATING_MINIMUM, |
|
110 |
RATING_TREE_UP_STEP = 7, |
|
111 |
RATING_TREE_MAXIMUM = 220, |
|
112 |
||
113 |
RATING_TUNNEL_BRIDGE_DOWN_STEP = -250, |
|
114 |
RATING_TUNNEL_BRIDGE_MINIMUM = 0, |
|
115 |
||
116 |
RATING_INDUSTRY_DOWN_STEP = -1500, |
|
117 |
RATING_INDUSTRY_MINIMUM = RATING_MINIMUM, |
|
118 |
||
119 |
RATING_ROAD_DOWN_STEP = -50, |
|
120 |
RATING_ROAD_MINIMUM = -100, |
|
121 |
RATING_HOUSE_MINIMUM = RATING_MINIMUM, |
|
122 |
||
123 |
RATING_BRIBE_UP_STEP = 200, |
|
124 |
RATING_BRIBE_MAXIMUM = 800, |
|
1019
6363b8a4273e
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
tron
parents:
1005
diff
changeset
|
125 |
RATING_BRIBE_DOWN_TO = -50 // XXX SHOULD BE SOMETHING LOWER? |
1005 | 126 |
}; |
127 |
||
2958
3f8946daf55f
(svn r3520) Remove unused parameters from some functions
tron
parents:
2817
diff
changeset
|
128 |
bool CheckforTownRating(uint32 flags, Town *t, byte type); |
0 | 129 |
|
3346
96c5db77aa83
(svn r4130) - CodeChange: Add proper semantics for TownID for such variables instead of using the general uint16-type. We probably need to change GetTown() and IsTownIndex() as well to use TownID.
Darkvater
parents:
2958
diff
changeset
|
130 |
VARDEF TownID *_town_sort; |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
835
diff
changeset
|
131 |
|
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
132 |
extern MemoryPool _town_pool; |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
133 |
|
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
134 |
/** |
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1260
diff
changeset
|
135 |
* Check if a Town really exists. |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1260
diff
changeset
|
136 |
*/ |
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2186
diff
changeset
|
137 |
static inline bool IsValidTown(const Town* town) |
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1260
diff
changeset
|
138 |
{ |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1260
diff
changeset
|
139 |
return town->xy != 0; /* XXX: Replace by INVALID_TILE someday */ |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1260
diff
changeset
|
140 |
} |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1260
diff
changeset
|
141 |
|
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1260
diff
changeset
|
142 |
/** |
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
143 |
* Get the pointer to the town with index 'index' |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
144 |
*/ |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
835
diff
changeset
|
145 |
static inline Town *GetTown(uint index) |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
835
diff
changeset
|
146 |
{ |
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
147 |
return (Town*)GetItemFromPool(&_town_pool, index); |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
835
diff
changeset
|
148 |
} |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
835
diff
changeset
|
149 |
|
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
150 |
/** |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
151 |
* Get the current size of the TownPool |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
152 |
*/ |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
153 |
static inline uint16 GetTownPoolSize(void) |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
154 |
{ |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
155 |
return _town_pool.total_items; |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
156 |
} |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
835
diff
changeset
|
157 |
|
1784
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1377
diff
changeset
|
158 |
static inline bool IsTownIndex(uint index) |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1377
diff
changeset
|
159 |
{ |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1377
diff
changeset
|
160 |
return index < GetTownPoolSize(); |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1377
diff
changeset
|
161 |
} |
6eb3ab1bc33c
(svn r2288) - CodeChange: protected the next batch of commands (41 so far, out of 115).
Darkvater
parents:
1377
diff
changeset
|
162 |
|
1260
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
163 |
#define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1 < GetTownPoolSize()) ? GetTown(t->index + 1) : NULL) |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
164 |
#define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0) |
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
165 |
|
c60e76928e5c
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1220
diff
changeset
|
166 |
VARDEF uint _total_towns; // For the AI: the amount of towns active |
0 | 167 |
|
168 |
VARDEF bool _town_sort_dirty; |
|
169 |
VARDEF byte _town_sort_order; |
|
170 |
||
171 |
VARDEF Town *_cleared_town; |
|
172 |
VARDEF int _cleared_town_rating; |
|
173 |
||
174 |
#endif /* TOWN_H */ |