author | tron |
Fri, 29 Jul 2005 18:22:04 +0000 | |
changeset 2230 | e461b07aead7 |
parent 2186 | db48cf29b983 |
child 2293 | b48192aec903 |
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
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
7 |
#include "rail.h" |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
8 |
|
0 | 9 |
typedef struct PlayerEconomyEntry { |
10 |
int32 income; |
|
11 |
int32 expenses; |
|
12 |
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
|
13 |
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
|
14 |
int64 company_value; |
0 | 15 |
} PlayerEconomyEntry; |
16 |
||
17 |
typedef struct AiBuildRec { |
|
18 |
TileIndex spec_tile; |
|
19 |
TileIndex use_tile; |
|
20 |
byte rand_rng; |
|
21 |
byte cur_building_rule; |
|
22 |
byte unk6; |
|
23 |
byte unk7; |
|
24 |
byte buildcmd_a; |
|
25 |
byte buildcmd_b; |
|
26 |
byte direction; |
|
27 |
byte cargo; |
|
28 |
} AiBuildRec; |
|
29 |
||
30 |
typedef struct PlayerAI { |
|
31 |
byte state; |
|
32 |
byte tick; // Used to determine how often to move |
|
1576
cbe6fd677ef4
(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
|
33 |
uint32 state_counter; // Can hold tile index! |
0 | 34 |
uint16 timeout_counter; |
35 |
||
36 |
byte state_mode; |
|
37 |
byte banned_tile_count; |
|
38 |
byte railtype_to_use; |
|
39 |
||
40 |
byte cargo_type; |
|
41 |
byte num_wagons; |
|
42 |
byte build_kind; |
|
43 |
byte num_build_rec; |
|
44 |
byte num_loco_to_build; |
|
45 |
byte num_want_fullload; |
|
46 |
||
47 |
byte route_type_mask; |
|
48 |
||
49 |
TileIndex start_tile_a; |
|
50 |
TileIndex cur_tile_a; |
|
51 |
byte cur_dir_a; |
|
52 |
byte start_dir_a; |
|
145 | 53 |
|
0 | 54 |
TileIndex start_tile_b; |
55 |
TileIndex cur_tile_b; |
|
56 |
byte cur_dir_b; |
|
57 |
byte start_dir_b; |
|
58 |
||
59 |
Vehicle *cur_veh; /* only used by some states */ |
|
145 | 60 |
|
0 | 61 |
AiBuildRec src, dst, mid1, mid2; |
145 | 62 |
|
0 | 63 |
VehicleID wagon_list[9]; |
64 |
byte order_list_blocks[20]; |
|
145 | 65 |
|
0 | 66 |
TileIndex banned_tiles[16]; |
67 |
byte banned_val[16]; |
|
68 |
} PlayerAI; |
|
69 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
70 |
typedef struct Ai_PathFinderInfo { |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
78 |
TileIndex route[500]; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
79 |
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
|
80 |
int route_length; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
81 |
int position; // Current position in the build-path, needed to build the path |
145 | 82 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
83 |
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
|
84 |
} Ai_PathFinderInfo; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
85 |
|
145 | 86 |
// The amount of memory reserved for the AI-special-vehicles |
87 |
#define AI_MAX_SPECIAL_VEHICLES 100 |
|
88 |
||
89 |
typedef struct Ai_SpecialVehicle { |
|
90 |
VehicleID veh_id; |
|
91 |
uint32 flag; |
|
92 |
} Ai_SpecialVehicle; |
|
93 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
94 |
typedef struct PlayerAiNew { |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
95 |
uint8 state; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
96 |
uint tick; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
97 |
uint idle; |
145 | 98 |
|
826 | 99 |
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
|
100 |
// The use is pretty simple: with this we can 'think' about stuff |
826 | 101 |
// 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
|
102 |
// 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
|
103 |
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
|
104 |
// long we are trying something, and just abort if it takes too long |
145 | 105 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
106 |
// Pathfinder stuff |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
107 |
Ai_PathFinderInfo path_info; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
108 |
AyStar *pathfinder; |
145 | 109 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
110 |
// Route stuff |
145 | 111 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
112 |
byte cargo; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
113 |
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
|
114 |
int new_cost; |
145 | 115 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
116 |
byte action; |
145 | 117 |
|
990
d2872f4948c1
(svn r1488) -Fix: fixed some spelling mistakes (tnx to Tron)
truelight
parents:
983
diff
changeset
|
118 |
int last_id; // here is stored the last id of the searched city/industry |
145 | 119 |
uint last_vehiclecheck_date; // Used in CheckVehicle |
120 |
Ai_SpecialVehicle special_vehicles[AI_MAX_SPECIAL_VEHICLES]; // Some vehicles have some special flags |
|
121 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
122 |
TileIndex from_tile; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
123 |
TileIndex to_tile; |
145 | 124 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
125 |
byte from_direction; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
126 |
byte to_direction; |
145 | 127 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
128 |
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
|
129 |
bool to_deliver; |
145 | 130 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
131 |
TileIndex depot_tile; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
132 |
byte depot_direction; |
145 | 133 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
134 |
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
|
135 |
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
|
136 |
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
|
137 |
VehicleID veh_main_id; // The ID of the first vehicle, for shared copy |
145 | 138 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
139 |
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
|
140 |
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
|
141 |
int to_ic; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
142 |
byte to_type; |
145 | 143 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
144 |
} PlayerAiNew; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
145 |
|
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 |
|
0 | 148 |
typedef struct Player { |
149 |
uint32 name_2; |
|
150 |
uint16 name_1; |
|
151 |
||
152 |
uint16 president_name_1; |
|
153 |
uint32 president_name_2; |
|
154 |
||
155 |
uint32 face; |
|
156 |
||
157 |
int32 player_money; |
|
158 |
int32 current_loan; |
|
159 |
int64 money64; // internal 64-bit version of the money. the 32-bit field will be clamped to plus minus 2 billion |
|
160 |
||
161 |
byte player_color; |
|
162 |
byte player_money_fraction; |
|
2147
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
163 |
byte avail_railtypes; |
0 | 164 |
byte block_preview; |
1786
7cfd46c3fcc4
(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
|
165 |
PlayerID index; |
0 | 166 |
|
167 |
uint16 cargo_types; /* which cargo types were transported the last year */ |
|
168 |
||
169 |
TileIndex location_of_house; |
|
170 |
TileIndex last_build_coordinate; |
|
145 | 171 |
|
0 | 172 |
byte share_owners[4]; |
145 | 173 |
|
0 | 174 |
byte inaugurated_year; |
175 |
byte num_valid_stat_ent; |
|
145 | 176 |
|
0 | 177 |
byte quarters_of_bankrupcy; |
178 |
byte bankrupt_asked; // which players were asked about buying it? |
|
179 |
int16 bankrupt_timeout; |
|
180 |
int32 bankrupt_value; |
|
181 |
||
182 |
bool is_active; |
|
183 |
byte is_ai; |
|
184 |
PlayerAI ai; |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
185 |
PlayerAiNew ainew; |
145 | 186 |
|
0 | 187 |
int64 yearly_expenses[3][13]; |
188 |
PlayerEconomyEntry cur_economy; |
|
189 |
PlayerEconomyEntry old_economy[24]; |
|
190 |
} Player; |
|
191 |
||
192 |
void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player); |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1962
diff
changeset
|
193 |
void GetNameOfOwner(byte owner, TileIndex tile); |
200
03b8104d1479
(svn r201) -Fix: [1025836] Company values bigger dan int32 were put to negative
truelight
parents:
147
diff
changeset
|
194 |
int64 CalculateCompanyValue(Player *p); |
0 | 195 |
void InvalidatePlayerWindows(Player *p); |
196 |
void AiDoGameLoop(Player *p); |
|
197 |
void UpdatePlayerMoney32(Player *p); |
|
198 |
#define FOR_ALL_PLAYERS(p) for(p=_players; p != endof(_players); p++) |
|
199 |
||
2154
f86c59e73a16
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
200 |
extern PlayerID _current_player; |
f86c59e73a16
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
201 |
|
0 | 202 |
#define MAX_PLAYERS 8 |
203 |
VARDEF Player _players[MAX_PLAYERS]; |
|
2154
f86c59e73a16
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
204 |
// NOSAVE: can be determined from player structs |
f86c59e73a16
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
205 |
VARDEF byte _player_colors[MAX_PLAYERS]; |
0 | 206 |
|
1767
cda2e9ac430a
(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
|
207 |
static inline Player* GetPlayer(uint i) |
cda2e9ac430a
(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
|
208 |
{ |
cda2e9ac430a
(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
|
209 |
assert(i < lengthof(_players)); |
cda2e9ac430a
(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
|
210 |
return &_players[i]; |
cda2e9ac430a
(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
|
211 |
} |
cda2e9ac430a
(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
|
212 |
|
2147
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
213 |
/** Returns the number of rail types the player can build |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
214 |
* @param *p Player in question |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
215 |
*/ |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
216 |
static inline int GetNumRailtypes(Player *p) |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
217 |
{ |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
218 |
int num = 0; |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
219 |
int i; |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
220 |
|
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
221 |
for (i = 0; i < (int)sizeof(p->avail_railtypes) * 8; i++) |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
222 |
if (HASBIT(p->avail_railtypes, i)) num++; |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
223 |
|
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
224 |
assert(num <= RAILTYPE_END); |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
225 |
return num; |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
226 |
} |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
227 |
|
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
228 |
byte GetPlayerRailtypes(int p); |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
229 |
|
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
230 |
/** Finds out if a Player has a certain railtype available |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
231 |
*/ |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
232 |
static inline bool HasRailtypeAvail(Player *p, RailType Railtype) |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
233 |
{ |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
234 |
return HASBIT(p->avail_railtypes, Railtype); |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
235 |
} |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
236 |
|
2154
f86c59e73a16
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
237 |
/* Validate functions for rail building */ |
f86c59e73a16
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
238 |
static inline bool ValParamRailtype(uint32 rail) { return HASBIT(GetPlayer(_current_player)->avail_railtypes, rail);} |
f86c59e73a16
(svn r2664) Remove depedency on player.h from variables.h
tron
parents:
2147
diff
changeset
|
239 |
|
2147
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
240 |
/** Returns the "best" railtype a player can build. |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
241 |
* As the AI doesn't know what the BEST one is, we |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
242 |
* have our own priority list here. When adding |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
243 |
* new railtypes, modify this function |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
244 |
* @param p the player "in action" |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
245 |
* @return The "best" railtype a player has available |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
246 |
*/ |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
247 |
static inline byte GetBestRailtype(Player *p) |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
248 |
{ |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
249 |
if (HasRailtypeAvail(p, RAILTYPE_MAGLEV)) return RAILTYPE_MAGLEV; |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
250 |
if (HasRailtypeAvail(p, RAILTYPE_MONO)) return RAILTYPE_MONO; |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
251 |
return RAILTYPE_RAIL; |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
252 |
} |
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
1977
diff
changeset
|
253 |
|
1962
8254df1b359b
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1786
diff
changeset
|
254 |
#define IS_HUMAN_PLAYER(p) (!GetPlayer((byte)(p))->is_ai) |
0 | 255 |
#define IS_INTERACTIVE_PLAYER(p) (((byte)p) == _local_player) |
256 |
||
983
4765bf636f6b
(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 |
typedef struct HighScore { |
4765bf636f6b
(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 |
char company[100]; |
4765bf636f6b
(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
|
259 |
StringID title; |
4765bf636f6b
(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 |
uint16 score; |
4765bf636f6b
(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 |
} HighScore; |
4765bf636f6b
(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
|
262 |
|
998
c90459c24842
(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 |
VARDEF HighScore _highscore_table[5][5]; // 4 difficulty-settings (+ network); top 5 |
983
4765bf636f6b
(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 |
void SaveToHighScore(void); |
4765bf636f6b
(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
|
265 |
void LoadFromHighScore(void); |
998
c90459c24842
(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
|
266 |
int8 SaveHighScoreValue(const Player *p); |
c90459c24842
(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
|
267 |
int8 SaveHighScoreValueNetwork(void); |
983
4765bf636f6b
(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
|
268 |
|
0 | 269 |
#endif /* PLAYER_H */ |