author | truelight |
Fri, 20 Aug 2004 09:32:32 +0000 | |
changeset 84 | 1e0721c29bad |
parent 0 | 29654efe3188 |
child 145 | 6e5468217504 |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef PLAYER_H |
2 |
#define PLAYER_H |
|
3 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
4 |
#include "aystar.h" |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
5 |
|
0 | 6 |
typedef struct PlayerEconomyEntry { |
7 |
int32 income; |
|
8 |
int32 expenses; |
|
9 |
int32 delivered_cargo; |
|
10 |
int32 performance_history; |
|
11 |
int32 company_value; |
|
12 |
} PlayerEconomyEntry; |
|
13 |
||
14 |
typedef struct AiBuildRec { |
|
15 |
TileIndex spec_tile; |
|
16 |
TileIndex use_tile; |
|
17 |
byte rand_rng; |
|
18 |
byte cur_building_rule; |
|
19 |
byte unk6; |
|
20 |
byte unk7; |
|
21 |
byte buildcmd_a; |
|
22 |
byte buildcmd_b; |
|
23 |
byte direction; |
|
24 |
byte cargo; |
|
25 |
} AiBuildRec; |
|
26 |
||
27 |
typedef struct PlayerAI { |
|
28 |
byte state; |
|
29 |
byte tick; // Used to determine how often to move |
|
30 |
uint16 state_counter; |
|
31 |
uint16 timeout_counter; |
|
32 |
||
33 |
byte state_mode; |
|
34 |
byte banned_tile_count; |
|
35 |
byte railtype_to_use; |
|
36 |
||
37 |
byte cargo_type; |
|
38 |
byte num_wagons; |
|
39 |
byte build_kind; |
|
40 |
byte num_build_rec; |
|
41 |
byte num_loco_to_build; |
|
42 |
byte num_want_fullload; |
|
43 |
||
44 |
byte route_type_mask; |
|
45 |
||
46 |
TileIndex start_tile_a; |
|
47 |
TileIndex cur_tile_a; |
|
48 |
byte cur_dir_a; |
|
49 |
byte start_dir_a; |
|
50 |
||
51 |
TileIndex start_tile_b; |
|
52 |
TileIndex cur_tile_b; |
|
53 |
byte cur_dir_b; |
|
54 |
byte start_dir_b; |
|
55 |
||
56 |
Vehicle *cur_veh; /* only used by some states */ |
|
57 |
||
58 |
AiBuildRec src, dst, mid1, mid2; |
|
59 |
||
60 |
VehicleID wagon_list[9]; |
|
61 |
byte order_list_blocks[20]; |
|
62 |
||
63 |
TileIndex banned_tiles[16]; |
|
64 |
byte banned_val[16]; |
|
65 |
} PlayerAI; |
|
66 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
67 |
typedef struct Ai_PathFinderInfo { |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
75 |
TileIndex route[500]; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
76 |
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
|
77 |
int route_length; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
78 |
int position; // Current position in the build-path, needed to build the path |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
79 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
80 |
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
|
81 |
} Ai_PathFinderInfo; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
82 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
83 |
typedef struct PlayerAiNew { |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
84 |
uint8 state; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
85 |
uint tick; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
86 |
uint idle; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
87 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
88 |
int temp; // A value used in more then one function, but it just temporary |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
89 |
// The use is pretty simple: with this we can 'think' about stuff |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
90 |
// in more then one tick, and more then one AI. A static will not |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
91 |
// 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
|
92 |
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
|
93 |
// long we are trying something, and just abort if it takes too long |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
94 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
95 |
// Pathfinder stuff |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
96 |
Ai_PathFinderInfo path_info; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
97 |
AyStar *pathfinder; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
98 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
99 |
// Route stuff |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
100 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
101 |
byte cargo; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
102 |
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
|
103 |
int new_cost; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
104 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
105 |
byte action; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
106 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
107 |
uint last_id; // here is stored the last id of the searched city/industry |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
108 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
109 |
TileIndex from_tile; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
110 |
TileIndex to_tile; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
111 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
112 |
byte from_direction; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
113 |
byte to_direction; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
114 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
115 |
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
|
116 |
bool to_deliver; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
117 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
118 |
TileIndex depot_tile; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
119 |
byte depot_direction; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
120 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
121 |
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
|
122 |
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
|
123 |
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
|
124 |
VehicleID veh_main_id; // The ID of the first vehicle, for shared copy |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
125 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
126 |
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
|
127 |
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
|
128 |
int to_ic; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
129 |
byte to_type; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
130 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
131 |
} PlayerAiNew; |
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
132 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
133 |
|
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
134 |
|
0 | 135 |
typedef struct Player { |
136 |
uint32 name_2; |
|
137 |
uint16 name_1; |
|
138 |
||
139 |
uint16 president_name_1; |
|
140 |
uint32 president_name_2; |
|
141 |
||
142 |
uint32 face; |
|
143 |
||
144 |
int32 player_money; |
|
145 |
int32 current_loan; |
|
146 |
int64 money64; // internal 64-bit version of the money. the 32-bit field will be clamped to plus minus 2 billion |
|
147 |
||
148 |
byte player_color; |
|
149 |
byte player_money_fraction; |
|
150 |
byte max_railtype; |
|
151 |
byte block_preview; |
|
152 |
byte index; |
|
153 |
||
154 |
uint16 cargo_types; /* which cargo types were transported the last year */ |
|
155 |
||
156 |
TileIndex location_of_house; |
|
157 |
TileIndex last_build_coordinate; |
|
158 |
||
159 |
byte share_owners[4]; |
|
160 |
||
161 |
byte inaugurated_year; |
|
162 |
byte num_valid_stat_ent; |
|
163 |
||
164 |
byte quarters_of_bankrupcy; |
|
165 |
byte bankrupt_asked; // which players were asked about buying it? |
|
166 |
int16 bankrupt_timeout; |
|
167 |
int32 bankrupt_value; |
|
168 |
||
169 |
bool is_active; |
|
170 |
byte is_ai; |
|
171 |
PlayerAI ai; |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
0
diff
changeset
|
172 |
PlayerAiNew ainew; |
0 | 173 |
|
174 |
int64 yearly_expenses[3][13]; |
|
175 |
PlayerEconomyEntry cur_economy; |
|
176 |
PlayerEconomyEntry old_economy[24]; |
|
177 |
} Player; |
|
178 |
||
179 |
void ChangeOwnershipOfPlayerItems(byte old_player, byte new_player); |
|
180 |
void GetNameOfOwner(byte owner, uint tile); |
|
181 |
uint32 CalculateCompanyValue(Player *p); |
|
182 |
void InvalidatePlayerWindows(Player *p); |
|
183 |
void AiDoGameLoop(Player *p); |
|
184 |
void UpdatePlayerMoney32(Player *p); |
|
185 |
#define DEREF_PLAYER(i) (&_players[i]) |
|
186 |
#define FOR_ALL_PLAYERS(p) for(p=_players; p != endof(_players); p++) |
|
187 |
||
188 |
#define MAX_PLAYERS 8 |
|
189 |
VARDEF Player _players[MAX_PLAYERS]; |
|
190 |
||
191 |
#define IS_HUMAN_PLAYER(p) (!DEREF_PLAYER((byte)(p))->is_ai) |
|
192 |
#define IS_INTERACTIVE_PLAYER(p) (((byte)p) == _local_player) |
|
193 |
||
194 |
#endif /* PLAYER_H */ |