author | peter1138 |
Mon, 31 Oct 2005 12:01:41 +0000 | |
changeset 2573 | 1950c5c3aab5 |
parent 2544 | 50cb52cdeb73 |
child 2613 | b008d366ed8a |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#ifndef PLAYER_H |
4 |
#define PLAYER_H |
|
5 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
6 |
#include "aystar.h" |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
7 |
#include "rail.h" |
2573
1950c5c3aab5
(svn r3110) Replace another 256 with TOTAL_NUM_ENGINES.
peter1138
parents:
2544
diff
changeset
|
8 |
#include "engine.h" |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
9 |
|
0 | 10 |
typedef struct PlayerEconomyEntry { |
11 |
int32 income; |
|
12 |
int32 expenses; |
|
13 |
int32 delivered_cargo; |
|
147
d0c8100d18cf
(svn r148) -Feature: Company HQ can now be moved somewhere else (cost 1% of company value). Water floods HQ.
darkvater
parents:
145
diff
changeset
|
14 |
int32 performance_history; // player score (scale 0-1000) |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
147
diff
changeset
|
15 |
int64 company_value; |
0 | 16 |
} PlayerEconomyEntry; |
17 |
||
18 |
typedef struct AiBuildRec { |
|
19 |
TileIndex spec_tile; |
|
20 |
TileIndex use_tile; |
|
21 |
byte rand_rng; |
|
22 |
byte cur_building_rule; |
|
23 |
byte unk6; |
|
24 |
byte unk7; |
|
25 |
byte buildcmd_a; |
|
26 |
byte buildcmd_b; |
|
27 |
byte direction; |
|
28 |
byte cargo; |
|
29 |
} AiBuildRec; |
|
30 |
||
31 |
typedef struct PlayerAI { |
|
32 |
byte state; |
|
33 |
byte tick; // Used to determine how often to move |
|
1576
a066e33fa297
(svn r2080) - Fix: [OldAI] p->ai.state_counter was uint16 but could hold a tile index, therefore overflowing - changed that to uint32 and bumped the savegame revision to 32. It *MIGHT* close bug 1151374 - it certainly caused AI to stop building anything sometimes.
pasky
parents:
998
diff
changeset
|
34 |
uint32 state_counter; // Can hold tile index! |
0 | 35 |
uint16 timeout_counter; |
36 |
||
37 |
byte state_mode; |
|
38 |
byte banned_tile_count; |
|
39 |
byte railtype_to_use; |
|
40 |
||
41 |
byte cargo_type; |
|
42 |
byte num_wagons; |
|
43 |
byte build_kind; |
|
44 |
byte num_build_rec; |
|
45 |
byte num_loco_to_build; |
|
46 |
byte num_want_fullload; |
|
47 |
||
48 |
byte route_type_mask; |
|
49 |
||
50 |
TileIndex start_tile_a; |
|
51 |
TileIndex cur_tile_a; |
|
52 |
byte cur_dir_a; |
|
53 |
byte start_dir_a; |
|
145 | 54 |
|
0 | 55 |
TileIndex start_tile_b; |
56 |
TileIndex cur_tile_b; |
|
57 |
byte cur_dir_b; |
|
58 |
byte start_dir_b; |
|
59 |
||
60 |
Vehicle *cur_veh; /* only used by some states */ |
|
145 | 61 |
|
0 | 62 |
AiBuildRec src, dst, mid1, mid2; |
145 | 63 |
|
0 | 64 |
VehicleID wagon_list[9]; |
65 |
byte order_list_blocks[20]; |
|
145 | 66 |
|
0 | 67 |
TileIndex banned_tiles[16]; |
68 |
byte banned_val[16]; |
|
69 |
} PlayerAI; |
|
70 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
71 |
typedef struct Ai_PathFinderInfo { |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
72 |
TileIndex start_tile_tl; // tl = top-left |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
73 |
TileIndex start_tile_br; // br = bottom-right |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
74 |
TileIndex end_tile_tl; // tl = top-left |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
75 |
TileIndex end_tile_br; // br = bottom-right |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
76 |
byte start_direction; // 0 to 3 or AI_PATHFINDER_NO_DIRECTION |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
77 |
byte end_direction; // 0 to 3 or AI_PATHFINDER_NO_DIRECTION |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
78 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
79 |
TileIndex route[500]; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
80 |
byte route_extra[500]; // Some extra information about the route like bridge/tunnel |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
81 |
int route_length; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
82 |
int position; // Current position in the build-path, needed to build the path |
145 | 83 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
84 |
bool rail_or_road; // true = rail, false = road |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
85 |
} Ai_PathFinderInfo; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
86 |
|
145 | 87 |
// The amount of memory reserved for the AI-special-vehicles |
88 |
#define AI_MAX_SPECIAL_VEHICLES 100 |
|
89 |
||
90 |
typedef struct Ai_SpecialVehicle { |
|
91 |
VehicleID veh_id; |
|
92 |
uint32 flag; |
|
93 |
} Ai_SpecialVehicle; |
|
94 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
95 |
typedef struct PlayerAiNew { |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
96 |
uint8 state; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
97 |
uint tick; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
98 |
uint idle; |
145 | 99 |
|
826 | 100 |
int temp; // A value used in more than one function, but it just temporary |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
101 |
// The use is pretty simple: with this we can 'think' about stuff |
826 | 102 |
// in more than one tick, and more than one AI. A static will not |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
103 |
// do, because they are not saved. This way, the AI is almost human ;) |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
104 |
int counter; // For the same reason as temp, we have counter. It can count how |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
105 |
// long we are trying something, and just abort if it takes too long |
145 | 106 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
107 |
// Pathfinder stuff |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
108 |
Ai_PathFinderInfo path_info; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
109 |
AyStar *pathfinder; |
145 | 110 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
111 |
// Route stuff |
145 | 112 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
113 |
byte cargo; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
114 |
byte tbt; // train/bus/truck 0/1/2 AI_TRAIN/AI_BUS/AI_TRUCK |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
115 |
int new_cost; |
145 | 116 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
117 |
byte action; |
145 | 118 |
|
990
5cbf62b64f36
(svn r1488) -Fix: fixed some spelling mistakes (tnx to Tron)
truelight
parents:
983
diff
changeset
|
119 |
int last_id; // here is stored the last id of the searched city/industry |
145 | 120 |
uint last_vehiclecheck_date; // Used in CheckVehicle |
121 |
Ai_SpecialVehicle special_vehicles[AI_MAX_SPECIAL_VEHICLES]; // Some vehicles have some special flags |
|
122 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
123 |
TileIndex from_tile; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
124 |
TileIndex to_tile; |
145 | 125 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
126 |
byte from_direction; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
127 |
byte to_direction; |
145 | 128 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
129 |
bool from_deliver; // True if this is the station that GIVES cargo |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
130 |
bool to_deliver; |
145 | 131 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
132 |
TileIndex depot_tile; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
133 |
byte depot_direction; |
145 | 134 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
135 |
byte amount_veh; // How many vehicles we are going to build in this route |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
136 |
byte cur_veh; // How many vehicles did we bought? |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
137 |
VehicleID veh_id; // Used when bought a vehicle |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
138 |
VehicleID veh_main_id; // The ID of the first vehicle, for shared copy |
145 | 139 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
140 |
int from_ic; // ic = industry/city. This is the ID of them |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
141 |
byte from_type; // AI_NO_TYPE/AI_CITY/AI_INDUSTRY |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
142 |
int to_ic; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
143 |
byte to_type; |
145 | 144 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
145 |
} PlayerAiNew; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
146 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
147 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
148 |
|
0 | 149 |
typedef struct Player { |
150 |
uint32 name_2; |
|
151 |
uint16 name_1; |
|
152 |
||
153 |
uint16 president_name_1; |
|
154 |
uint32 president_name_2; |
|
155 |
||
156 |
uint32 face; |
|
157 |
||
158 |
int32 player_money; |
|
159 |
int32 current_loan; |
|
160 |
int64 money64; // internal 64-bit version of the money. the 32-bit field will be clamped to plus minus 2 billion |
|
161 |
||
162 |
byte player_color; |
|
163 |
byte player_money_fraction; |
|
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
164 |
byte avail_railtypes; |
0 | 165 |
byte block_preview; |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1767
diff
changeset
|
166 |
PlayerID index; |
0 | 167 |
|
168 |
uint16 cargo_types; /* which cargo types were transported the last year */ |
|
169 |
||
170 |
TileIndex location_of_house; |
|
171 |
TileIndex last_build_coordinate; |
|
145 | 172 |
|
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
173 |
PlayerID share_owners[4]; |
145 | 174 |
|
0 | 175 |
byte inaugurated_year; |
176 |
byte num_valid_stat_ent; |
|
145 | 177 |
|
0 | 178 |
byte quarters_of_bankrupcy; |
179 |
byte bankrupt_asked; // which players were asked about buying it? |
|
180 |
int16 bankrupt_timeout; |
|
181 |
int32 bankrupt_value; |
|
182 |
||
183 |
bool is_active; |
|
184 |
byte is_ai; |
|
185 |
PlayerAI ai; |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
186 |
PlayerAiNew ainew; |
145 | 187 |
|
0 | 188 |
int64 yearly_expenses[3][13]; |
189 |
PlayerEconomyEntry cur_economy; |
|
190 |
PlayerEconomyEntry old_economy[24]; |
|
2573
1950c5c3aab5
(svn r3110) Replace another 256 with TOTAL_NUM_ENGINES.
peter1138
parents:
2544
diff
changeset
|
191 |
EngineID engine_replacement[TOTAL_NUM_ENGINES]; |
2293
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2186
diff
changeset
|
192 |
bool engine_renew; |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2186
diff
changeset
|
193 |
int16 engine_renew_months; |
a71c210076be
(svn r2817) -Codechange: [autoreplace]: moved autoreplace and autorenew to serverside
bjarni
parents:
2186
diff
changeset
|
194 |
uint32 engine_renew_money; |
0 | 195 |
} Player; |
196 |
||
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
197 |
void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player); |
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
198 |
void GetNameOfOwner(PlayerID owner, TileIndex tile); |
2475 | 199 |
int64 CalculateCompanyValue(const Player* p); |
200 |
void InvalidatePlayerWindows(const Player* p); |
|
0 | 201 |
void UpdatePlayerMoney32(Player *p); |
202 |
#define FOR_ALL_PLAYERS(p) for(p=_players; p != endof(_players); p++) |
|
203 |
||
2425
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
204 |
VARDEF PlayerID _local_player; |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
205 |
VARDEF PlayerID _current_player; |
2154
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
206 |
|
0 | 207 |
#define MAX_PLAYERS 8 |
208 |
VARDEF Player _players[MAX_PLAYERS]; |
|
2154
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
209 |
// NOSAVE: can be determined from player structs |
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
210 |
VARDEF byte _player_colors[MAX_PLAYERS]; |
0 | 211 |
|
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
212 |
static inline Player* GetPlayer(PlayerID i) |
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1576
diff
changeset
|
213 |
{ |
2425
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
214 |
assert(i < lengthof(_players)); |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
215 |
return &_players[i]; |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
216 |
} |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
217 |
|
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
218 |
static inline bool IsLocalPlayer(void) |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
219 |
{ |
99e1e8430a28
(svn r2951) - Fix: [ 1259345 ] Changing engine in netgame opens train window for everyone
Darkvater
parents:
2293
diff
changeset
|
220 |
return _local_player == _current_player; |
1767
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1576
diff
changeset
|
221 |
} |
394867897b0a
(svn r2271) CMD_SET_PLAYER_FACE, CMD_SET_PLAYER_COLOR, CMD_INCREASE_LOAN, CMD_DECREASE_LOAN only make sense for the current player, so don't explicitly pass a player number
tron
parents:
1576
diff
changeset
|
222 |
|
2544 | 223 |
void DeletePlayerWindows(PlayerID pi); |
224 |
byte GetPlayerRailtypes(PlayerID p); |
|
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
225 |
|
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
226 |
/** Finds out if a Player has a certain railtype available |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
227 |
*/ |
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2425
diff
changeset
|
228 |
static inline bool HasRailtypeAvail(const Player *p, RailType Railtype) |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
229 |
{ |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
230 |
return HASBIT(p->avail_railtypes, Railtype); |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
231 |
} |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
232 |
|
2154
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
233 |
/* Validate functions for rail building */ |
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
234 |
static inline bool ValParamRailtype(uint32 rail) { return HASBIT(GetPlayer(_current_player)->avail_railtypes, rail);} |
63a6b880b4c0
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
235 |
|
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
236 |
/** Returns the "best" railtype a player can build. |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
237 |
* As the AI doesn't know what the BEST one is, we |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
238 |
* have our own priority list here. When adding |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
239 |
* new railtypes, modify this function |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
240 |
* @param p the player "in action" |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
241 |
* @return The "best" railtype a player has available |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
242 |
*/ |
2520
75eb66d6e371
(svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents:
2475
diff
changeset
|
243 |
static inline RailType GetBestRailtype(const Player* p) |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
244 |
{ |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
245 |
if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV; |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
246 |
if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO; |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
247 |
return RAILTYPE_RAIL; |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
248 |
} |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
249 |
|
2475 | 250 |
#define IS_HUMAN_PLAYER(p) (!GetPlayer(p)->is_ai) |
251 |
#define IS_INTERACTIVE_PLAYER(p) ((p) == _local_player) |
|
0 | 252 |
|
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
253 |
typedef struct HighScore { |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
254 |
char company[100]; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
255 |
StringID title; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
256 |
uint16 score; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
257 |
} HighScore; |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
258 |
|
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
990
diff
changeset
|
259 |
VARDEF HighScore _highscore_table[5][5]; // 4 difficulty-settings (+ network); top 5 |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
260 |
void SaveToHighScore(void); |
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
261 |
void LoadFromHighScore(void); |
998
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
990
diff
changeset
|
262 |
int8 SaveHighScoreValue(const Player *p); |
d9dc257b8949
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
990
diff
changeset
|
263 |
int8 SaveHighScoreValueNetwork(void); |
983
1be852dcdd4c
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
826
diff
changeset
|
264 |
|
0 | 265 |
#endif /* PLAYER_H */ |