author | celestar |
Sat, 15 Jan 2005 09:28:08 +0000 | |
changeset 1020 | 1223cd937174 |
parent 956 | d72a565cc672 |
child 1024 | 9b06b01490a4 |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef VEHICLE_H |
2 |
#define VEHICLE_H |
|
3 |
||
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
4 |
#include "vehicle_gui.h" |
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
156
diff
changeset
|
5 |
|
956
d72a565cc672
(svn r1448) -Fix: The current_order of a vehicle is now correctly saved (caused
truelight
parents:
954
diff
changeset
|
6 |
/* If you change this, keep in mind that it is saved on 3 places: |
d72a565cc672
(svn r1448) -Fix: The current_order of a vehicle is now correctly saved (caused
truelight
parents:
954
diff
changeset
|
7 |
- Load_ORDR, all the global orders |
d72a565cc672
(svn r1448) -Fix: The current_order of a vehicle is now correctly saved (caused
truelight
parents:
954
diff
changeset
|
8 |
- Vehicle -> current_order |
d72a565cc672
(svn r1448) -Fix: The current_order of a vehicle is now correctly saved (caused
truelight
parents:
954
diff
changeset
|
9 |
- REF_SHEDULE (all REFs are currently limited to 16 bits!!) */ |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
10 |
typedef struct Order { |
941
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
11 |
uint8 type; |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
12 |
uint8 flags; |
817
4f9377b7fd2b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
812
diff
changeset
|
13 |
uint16 station; |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
14 |
} Order; |
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
15 |
|
941
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
16 |
static inline uint32 PackOrder(const Order *order) |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
17 |
{ |
941
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
18 |
return order->station << 16 | order->flags << 8 | order->type; |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
19 |
} |
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
20 |
|
941
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
21 |
static inline Order UnpackOrder(uint32 packed) |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
22 |
{ |
567
bb9c38b29d25
(svn r978) Fixed an endianess issue with the new Order system. Thanks to Bjarni, Oskar and Tron
Celestar
parents:
555
diff
changeset
|
23 |
Order order; |
941
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
24 |
order.type = (packed & 0x000000FF); |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
25 |
order.flags = (packed & 0x0000FF00) >> 8; |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
26 |
order.station = (packed & 0xFFFF0000) >> 16; |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
27 |
return order; |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
28 |
} |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
29 |
|
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
30 |
static inline Order UnpackVersion4Order(uint16 packed) |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
31 |
{ |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
32 |
Order order; |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
33 |
order.type = (packed & 0x000F); |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
34 |
order.flags = (packed & 0x00F0) >> 4; |
4a695e126035
(svn r1429) Change: bumped savegame to revision 5.
truelight
parents:
938
diff
changeset
|
35 |
order.station = (packed & 0xFF00) >> 8; |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
36 |
return order; |
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
37 |
} |
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
38 |
|
577 | 39 |
Order UnpackOldOrder(uint16 packed); |
40 |
||
41 |
||
0 | 42 |
typedef struct VehicleRail { |
43 |
uint16 last_speed; // NOSAVE: only used in UI |
|
44 |
uint16 crash_anim_pos; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
45 |
uint16 days_since_order_progr; |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
46 |
|
0 | 47 |
uint16 cached_weight; // cached power and weight for the vehicle. |
48 |
uint32 cached_power; // no need to save those, they are recomputed on load. |
|
49 |
||
50 |
// NOSAVE: for wagon override - id of the first engine in train |
|
51 |
// 0xffff == not in train |
|
52 |
uint16 first_engine; |
|
53 |
||
54 |
byte track; |
|
55 |
byte force_proceed; |
|
56 |
byte railtype; |
|
57 |
||
58 |
byte flags; |
|
59 |
} VehicleRail; |
|
60 |
||
61 |
enum { |
|
954
4d052517a993
(svn r1445) -Fix: reversing a train also reverses the UP and DOWN status for the
truelight
parents:
941
diff
changeset
|
62 |
VRF_REVERSING = 0, |
0 | 63 |
|
64 |
// used to calculate if train is going up or down |
|
954
4d052517a993
(svn r1445) -Fix: reversing a train also reverses the UP and DOWN status for the
truelight
parents:
941
diff
changeset
|
65 |
VRF_GOINGUP = 1, |
4d052517a993
(svn r1445) -Fix: reversing a train also reverses the UP and DOWN status for the
truelight
parents:
941
diff
changeset
|
66 |
VRF_GOINGDOWN = 2, |
0 | 67 |
}; |
68 |
||
69 |
typedef struct VehicleAir { |
|
70 |
uint16 crashed_counter; |
|
71 |
byte pos; |
|
72 |
byte previous_pos; |
|
817
4f9377b7fd2b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
812
diff
changeset
|
73 |
uint16 targetairport; |
0 | 74 |
byte state; |
75 |
} VehicleAir; |
|
76 |
||
77 |
typedef struct VehicleRoad { |
|
78 |
byte state; |
|
79 |
byte frame; |
|
80 |
uint16 unk2; |
|
81 |
byte overtaking; |
|
82 |
byte overtaking_ctr; |
|
83 |
uint16 crashed_ctr; |
|
84 |
byte reverse_ctr; |
|
85 |
} VehicleRoad; |
|
86 |
||
87 |
typedef struct VehicleSpecial { |
|
88 |
uint16 unk0; |
|
89 |
byte unk2; |
|
90 |
} VehicleSpecial; |
|
91 |
||
92 |
typedef struct VehicleDisaster { |
|
93 |
uint16 image_override; |
|
94 |
uint16 unk2; |
|
95 |
} VehicleDisaster; |
|
96 |
||
97 |
typedef struct VehicleShip { |
|
98 |
byte state; |
|
99 |
} VehicleShip; |
|
100 |
||
101 |
// not used ATM |
|
102 |
struct WorldSprite { |
|
103 |
struct WorldSprite *next; // next sprite in hash chain |
|
104 |
uint16 image; // sprite number for this vehicle |
|
105 |
||
106 |
// screen coordinates |
|
107 |
int16 left, top, right, bottom; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
108 |
|
0 | 109 |
// world coordinates |
110 |
int16 x; |
|
111 |
int16 y; |
|
112 |
byte z; |
|
113 |
||
114 |
int8 x_offs; // x offset for vehicle sprite |
|
115 |
int8 y_offs; // y offset for vehicle sprite |
|
116 |
||
117 |
byte width; // width of vehicle sprite |
|
118 |
byte height; // height of vehicle sprite |
|
119 |
byte depth; // depth of vehicle sprite |
|
120 |
||
121 |
byte flags; // draw flags |
|
122 |
}; |
|
123 |
||
124 |
struct Vehicle { |
|
125 |
byte type; // type, ie roadven,train,ship,aircraft,special |
|
22 | 126 |
byte subtype; // subtype (for trains, 0 == loco, 4 wagon ??) |
0 | 127 |
|
128 |
uint16 index; // NOSAVE: Index in vehicle array |
|
129 |
||
130 |
Vehicle *next; // next |
|
131 |
||
132 |
StringID string_id; // Displayed string |
|
133 |
||
134 |
byte unitnumber; // unit number, for display purposes only |
|
135 |
byte owner; // which player owns the vehicle? |
|
136 |
||
137 |
TileIndex tile; // Current tile index |
|
138 |
TileIndex dest_tile; // Heading for this tile |
|
139 |
||
140 |
int16 x_pos; // coordinates |
|
141 |
int16 y_pos; |
|
142 |
byte z_pos; |
|
143 |
byte direction; // facing |
|
144 |
||
145 |
byte spritenum; // currently displayed sprite index |
|
146 |
// 0xfd == custom sprite, 0xfe == custom second head sprite |
|
147 |
// 0xff == reserved for another custom sprite |
|
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
395
diff
changeset
|
148 |
uint16 cur_image; // sprite number for this vehicle |
0 | 149 |
byte sprite_width;// width of vehicle sprite |
150 |
byte sprite_height;// height of vehicle sprite |
|
151 |
byte z_height; // z-height of vehicle sprite |
|
152 |
int8 x_offs; // x offset for vehicle sprite |
|
153 |
int8 y_offs; // y offset for vehicle sprite |
|
154 |
uint16 engine_type; |
|
155 |
||
445
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
395
diff
changeset
|
156 |
// for randomized variational spritegroups |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
395
diff
changeset
|
157 |
// bitmask used to resolve them; parts of it get reseeded when triggers |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
395
diff
changeset
|
158 |
// of corresponding spritegroups get matched |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
395
diff
changeset
|
159 |
byte random_bits; |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
395
diff
changeset
|
160 |
byte waiting_triggers; // triggers to be yet matched |
0e3fa3da3899
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
395
diff
changeset
|
161 |
|
0 | 162 |
uint16 max_speed; // maximum speed |
163 |
uint16 cur_speed; // current speed |
|
164 |
byte subspeed; // fractional speed |
|
165 |
byte acceleration; // used by train & aircraft |
|
166 |
byte progress; |
|
167 |
||
168 |
byte vehstatus; // Status |
|
817
4f9377b7fd2b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
812
diff
changeset
|
169 |
uint16 last_station_visited; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
170 |
|
0 | 171 |
byte cargo_type; // type of cargo this vehicle is carrying |
172 |
byte cargo_days; // how many days have the pieces been in transit |
|
173 |
byte cargo_source;// source of cargo |
|
174 |
uint16 cargo_cap; // total capacity |
|
175 |
uint16 cargo_count;// how many pieces are used |
|
176 |
||
177 |
byte day_counter; // increased by one for each day |
|
178 |
byte tick_counter;// increased by one for each tick |
|
179 |
||
180 |
// related to the current order |
|
181 |
byte cur_order_index; |
|
182 |
byte num_orders; |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
183 |
Order current_order; |
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
184 |
Order *schedule_ptr; |
0 | 185 |
|
186 |
// Boundaries for the current position in the world and a next hash link. |
|
187 |
// NOSAVE: All of those can be updated with VehiclePositionChanged() |
|
849
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
188 |
int32 left_coord; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
189 |
int32 top_coord; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
190 |
int32 right_coord; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
842
diff
changeset
|
191 |
int32 bottom_coord; |
0 | 192 |
uint16 next_hash; |
193 |
||
194 |
// Related to age and service time |
|
195 |
uint16 age; // Age in days |
|
196 |
uint16 max_age; // Maximum age |
|
197 |
uint16 date_of_last_service; |
|
198 |
uint16 service_interval; |
|
199 |
uint16 reliability; |
|
200 |
uint16 reliability_spd_dec; |
|
201 |
byte breakdown_ctr; |
|
202 |
byte breakdown_delay; |
|
203 |
byte breakdowns_since_last_service; |
|
204 |
byte breakdown_chance; |
|
205 |
byte build_year; |
|
206 |
||
207 |
uint16 load_unload_time_rem; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
208 |
|
0 | 209 |
int32 profit_this_year; |
210 |
int32 profit_last_year; |
|
211 |
uint32 value; |
|
212 |
||
213 |
union { |
|
214 |
VehicleRail rail; |
|
215 |
VehicleAir air; |
|
216 |
VehicleRoad road; |
|
217 |
VehicleSpecial special; |
|
218 |
VehicleDisaster disaster; |
|
219 |
VehicleShip ship; |
|
220 |
} u; |
|
221 |
}; |
|
222 |
||
223 |
#define is_custom_sprite(x) (x >= 0xfd) |
|
224 |
#define is_custom_firsthead_sprite(x) (x == 0xfd) |
|
225 |
#define is_custom_secondhead_sprite(x) (x == 0xfe) |
|
226 |
||
227 |
struct Depot { |
|
228 |
TileIndex xy; |
|
229 |
uint16 town_index; |
|
230 |
}; |
|
231 |
||
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
232 |
// train waypoint |
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
233 |
struct Waypoint { |
0 | 234 |
TileIndex xy; |
235 |
uint16 town_or_string; // if this is 0xC000, it's a string id, otherwise a town. |
|
236 |
ViewportSign sign; |
|
237 |
uint16 build_date; |
|
238 |
byte stat_id; |
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
239 |
byte deleted; // this is a delete counter. when it reaches 0, the waypoint struct is deleted. |
0 | 240 |
}; |
241 |
||
242 |
enum { |
|
243 |
VEH_Train = 0x10, |
|
244 |
VEH_Road = 0x11, |
|
245 |
VEH_Ship = 0x12, |
|
246 |
VEH_Aircraft = 0x13, |
|
247 |
VEH_Special = 0x14, |
|
248 |
VEH_Disaster = 0x15, |
|
249 |
}; |
|
250 |
||
251 |
/* Order types */ |
|
252 |
enum { |
|
253 |
OT_NOTHING = 0, |
|
254 |
OT_GOTO_STATION = 1, |
|
255 |
OT_GOTO_DEPOT = 2, |
|
256 |
OT_LOADING = 3, |
|
257 |
OT_LEAVESTATION = 4, |
|
258 |
OT_DUMMY = 5, |
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
259 |
OT_GOTO_WAYPOINT = 6, |
0 | 260 |
}; |
261 |
||
262 |
/* Order flags */ |
|
263 |
enum { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
264 |
OF_UNLOAD = 0x2, |
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
265 |
OF_FULL_LOAD = 0x4, // Also used when to force an aircraft into a depot |
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
266 |
OF_NON_STOP = 0x8 |
0 | 267 |
}; |
268 |
||
269 |
||
270 |
enum VehStatus { |
|
271 |
VS_HIDDEN = 1, |
|
272 |
VS_STOPPED = 2, |
|
273 |
VS_UNCLICKABLE = 4, |
|
274 |
VS_DEFPAL = 0x8, |
|
275 |
VS_TRAIN_SLOWING = 0x10, |
|
276 |
VS_DISASTER = 0x20, |
|
277 |
VS_AIRCRAFT_BROKEN = 0x40, |
|
278 |
VS_CRASHED = 0x80, |
|
279 |
}; |
|
280 |
||
281 |
||
282 |
||
283 |
/* Effect vehicle types */ |
|
284 |
enum { |
|
285 |
EV_INDUSTRYSMOKE = 0, |
|
286 |
EV_STEAM_SMOKE = 1, |
|
287 |
||
288 |
EV_SMOKE_1 = 2, |
|
289 |
EV_SMOKE_2 = 3, |
|
290 |
EV_SMOKE_3 = 4, |
|
291 |
||
292 |
EV_CRASHED_SMOKE = 5, |
|
293 |
EV_BREAKDOWN_SMOKE = 6, |
|
294 |
||
295 |
EV_DEMOLISH = 7, |
|
296 |
EV_ROADWORK = 8, |
|
297 |
||
298 |
EV_INDUSTRY_SMOKE = 9, |
|
299 |
||
300 |
}; |
|
301 |
||
302 |
typedef void VehicleTickProc(Vehicle *v); |
|
303 |
typedef void *VehicleFromPosProc(Vehicle *v, void *data); |
|
304 |
||
305 |
typedef struct { |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
306 |
VehicleID clone; |
0 | 307 |
byte orderindex; |
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
308 |
Order order[41]; |
0 | 309 |
uint16 service_interval; |
310 |
char name[32]; |
|
311 |
} BackuppedOrders; |
|
312 |
||
578
86e352980acd
(svn r998) now vehicles are serviced both when entering and when leaving depots to prevent that vehicles might need service when leaving after a long stay (ln--)
bjarni
parents:
577
diff
changeset
|
313 |
void VehicleServiceInDepot(Vehicle *v); |
0 | 314 |
void BackupVehicleOrders(Vehicle *v, BackuppedOrders *order); |
315 |
void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *order); |
|
316 |
Vehicle *AllocateVehicle(); |
|
317 |
Vehicle *ForceAllocateVehicle(); |
|
318 |
Vehicle *ForceAllocateSpecialVehicle(); |
|
319 |
void UpdateVehiclePosHash(Vehicle *v, int x, int y); |
|
320 |
void InitializeVehicles(); |
|
321 |
void VehiclePositionChanged(Vehicle *v); |
|
322 |
void AfterLoadVehicles(); |
|
323 |
Vehicle *GetLastVehicleInChain(Vehicle *v); |
|
324 |
Vehicle *GetPrevVehicleInChain(Vehicle *v); |
|
325 |
Vehicle *GetFirstVehicleInChain(Vehicle *v); |
|
326 |
int CountVehiclesInChain(Vehicle *v); |
|
327 |
void DeleteVehicle(Vehicle *v); |
|
328 |
void DeleteVehicleChain(Vehicle *v); |
|
329 |
void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc); |
|
330 |
void CallVehicleTicks(); |
|
331 |
void DeleteVehicleSchedule(Vehicle *v); |
|
332 |
Vehicle *IsScheduleShared(Vehicle *v); |
|
333 |
||
334 |
Depot *AllocateDepot(); |
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
335 |
Waypoint *AllocateWaypoint(); |
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
336 |
void UpdateWaypointSign(Waypoint *cp); |
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
337 |
void RedrawWaypointSign(Waypoint *cp); |
0 | 338 |
|
339 |
void InitializeTrains(); |
|
340 |
bool IsTrainDepotTile(TileIndex tile); |
|
341 |
bool IsRoadDepotTile(TileIndex tile); |
|
342 |
||
343 |
bool CanFillVehicle(Vehicle *v); |
|
344 |
||
345 |
void ViewportAddVehicles(DrawPixelInfo *dpi); |
|
346 |
||
347 |
void TrainEnterDepot(Vehicle *v, uint tile); |
|
348 |
||
349 |
/* train_cmd.h */ |
|
350 |
int GetTrainImage(Vehicle *v, byte direction); |
|
351 |
int GetAircraftImage(Vehicle *v, byte direction); |
|
352 |
int GetRoadVehImage(Vehicle *v, byte direction); |
|
353 |
int GetShipImage(Vehicle *v, byte direction); |
|
354 |
||
355 |
Vehicle *CreateEffectVehicle(int x, int y, int z, int type); |
|
356 |
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, int type); |
|
357 |
Vehicle *CreateEffectVehicleRel(Vehicle *v, int x, int y, int z, int type); |
|
358 |
||
359 |
uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y); |
|
360 |
||
361 |
void VehicleInTheWayErrMsg(Vehicle *v); |
|
362 |
Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z); |
|
363 |
uint GetVehicleOutOfTunnelTile(Vehicle *v); |
|
364 |
||
365 |
bool UpdateSignalsOnSegment(uint tile, byte direction); |
|
366 |
void SetSignalsOnBothDir(uint tile, byte track); |
|
367 |
||
368 |
Vehicle *CheckClickOnVehicle(ViewPort *vp, int x, int y); |
|
369 |
//uint GetVehicleWeight(Vehicle *v); |
|
370 |
||
371 |
void DecreaseVehicleValue(Vehicle *v); |
|
372 |
void CheckVehicleBreakdown(Vehicle *v); |
|
373 |
void AgeVehicle(Vehicle *v); |
|
842 | 374 |
void MaybeReplaceVehicle(Vehicle *v); |
0 | 375 |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
376 |
void DeleteCommandFromVehicleSchedule(Order cmd); |
0 | 377 |
|
378 |
void BeginVehicleMove(Vehicle *v); |
|
379 |
void EndVehicleMove(Vehicle *v); |
|
380 |
||
381 |
bool IsAircraftHangarTile(TileIndex tile); |
|
382 |
void ShowAircraftViewWindow(Vehicle *v); |
|
383 |
||
384 |
void InvalidateVehicleOrderWidget(Vehicle *v); |
|
385 |
||
386 |
bool IsShipDepotTile(TileIndex tile); |
|
387 |
uint GetFreeUnitNumber(byte type); |
|
388 |
||
389 |
int LoadUnloadVehicle(Vehicle *v); |
|
390 |
int GetDepotByTile(uint tile); |
|
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
391 |
uint GetWaypointByTile(uint tile); |
0 | 392 |
|
393 |
void DoDeleteDepot(uint tile); |
|
394 |
||
395 |
void UpdateTrainAcceleration(Vehicle *v); |
|
396 |
int32 GetTrainRunningCost(Vehicle *v); |
|
397 |
||
398 |
int CheckStoppedInDepot(Vehicle *v); |
|
399 |
||
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
400 |
int ScheduleHasDepotOrders(const Order *schedule); |
19
6080d2b6a959
(svn r20) Feature: warning when a vehicle has invalid orders (celestar)
dominik
parents:
0
diff
changeset
|
401 |
int CheckOrders(Vehicle *v); |
0 | 402 |
|
593 | 403 |
bool VehicleNeedsService(const Vehicle *v); |
404 |
||
1020
1223cd937174
(svn r1521) -Fix: Ship Vehicle Lists are now redrawn correctly
celestar
parents:
956
diff
changeset
|
405 |
void InvalidateAircraftWindows(const Vehicle *v); |
1223cd937174
(svn r1521) -Fix: Ship Vehicle Lists are now redrawn correctly
celestar
parents:
956
diff
changeset
|
406 |
void InvalidateShipWindows(const Vehicle *v); |
1223cd937174
(svn r1521) -Fix: Ship Vehicle Lists are now redrawn correctly
celestar
parents:
956
diff
changeset
|
407 |
|
0 | 408 |
typedef struct GetNewVehiclePosResult { |
409 |
int x,y; |
|
410 |
uint old_tile; |
|
411 |
uint new_tile; |
|
412 |
} GetNewVehiclePosResult; |
|
413 |
||
414 |
/* returns true if staying in the same tile */ |
|
415 |
bool GetNewVehiclePos(Vehicle *v, GetNewVehiclePosResult *gp); |
|
416 |
byte GetDirectionTowards(Vehicle *v, int x, int y); |
|
417 |
||
418 |
#define BEGIN_ENUM_WAGONS(v) do { |
|
419 |
#define END_ENUM_WAGONS(v) } while ( (v=v->next) != NULL); |
|
420 |
||
421 |
/* vehicle.c */ |
|
422 |
enum { |
|
423 |
NUM_NORMAL_VEHICLES = 2048, |
|
424 |
NUM_SPECIAL_VEHICLES = 512, |
|
425 |
NUM_VEHICLES = NUM_NORMAL_VEHICLES + NUM_SPECIAL_VEHICLES |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
426 |
}; |
0 | 427 |
|
428 |
VARDEF Vehicle _vehicles[NUM_VEHICLES]; |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
429 |
VARDEF uint _vehicles_size; |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
430 |
|
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
431 |
VARDEF SortStruct *_vehicle_sort; |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
432 |
|
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
433 |
static inline Vehicle *GetVehicle(uint index) |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
434 |
{ |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
435 |
assert(index < _vehicles_size); |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
436 |
return &_vehicles[index]; |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
437 |
} |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
438 |
|
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
439 |
#define FOR_ALL_VEHICLES(v) for(v = _vehicles; v != &_vehicles[_vehicles_size]; v++) |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
849
diff
changeset
|
440 |
#define FOR_ALL_VEHICLES_FROM(v, from) for(v = GetVehicle(from); v != &_vehicles[_vehicles_size]; v++) |
0 | 441 |
|
555
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
442 |
VARDEF Order _order_array[5000]; |
eec6c0294435
(svn r955) Replace uint16 for orders with struct Order
tron
parents:
445
diff
changeset
|
443 |
VARDEF Order *_ptr_to_next_order; |
0 | 444 |
|
445 |
VARDEF Depot _depots[255]; |
|
446 |
||
395
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
447 |
// 128 waypoints |
4c990f33dab7
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
193
diff
changeset
|
448 |
VARDEF Waypoint _waypoints[128]; |
0 | 449 |
|
450 |
// NOSAVE: Can be regenerated by inspecting the vehicles. |
|
451 |
VARDEF VehicleID _vehicle_position_hash[0x1000]; |
|
452 |
||
453 |
// NOSAVE: Return values from various commands. |
|
454 |
VARDEF VehicleID _new_train_id; |
|
455 |
VARDEF VehicleID _new_wagon_id; |
|
456 |
VARDEF VehicleID _new_aircraft_id; |
|
457 |
VARDEF VehicleID _new_ship_id; |
|
458 |
VARDEF VehicleID _new_roadveh_id; |
|
459 |
VARDEF uint16 _aircraft_refit_capacity; |
|
460 |
VARDEF byte _cmd_build_rail_veh_score; |
|
461 |
VARDEF byte _cmd_build_rail_veh_var1; |
|
462 |
||
463 |
// NOSAVE: Player specific info |
|
464 |
VARDEF TileIndex _last_built_train_depot_tile; |
|
465 |
VARDEF TileIndex _last_built_road_depot_tile; |
|
466 |
VARDEF TileIndex _last_built_aircraft_depot_tile; |
|
467 |
VARDEF TileIndex _last_built_ship_depot_tile; |
|
468 |
VARDEF TileIndex _backup_orders_tile; |
|
469 |
VARDEF BackuppedOrders _backup_orders_data[1]; |
|
470 |
||
471 |
// for each player, for each vehicle type, keep a list of the vehicles. |
|
472 |
//VARDEF Vehicle *_vehicle_arr[8][4]; |
|
473 |
||
474 |
#define INVALID_VEHICLE 0xffff |
|
475 |
||
156
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
476 |
#define MIN_SERVINT_PERCENT 5 |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
477 |
#define MAX_SERVINT_PERCENT 90 |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
478 |
#define MIN_SERVINT_DAYS 30 |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
479 |
#define MAX_SERVINT_DAYS 800 |
8fef5e5752d6
(svn r157) -Feature: [1009708] Percent-based service intervals. Send a vehicle to depot after it has lost X% of its reliability (mivlad)
darkvater
parents:
22
diff
changeset
|
480 |
|
755
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
593
diff
changeset
|
481 |
/* A lot of code calls for the invalidation of the status bar, which is widget 5. |
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
593
diff
changeset
|
482 |
* Best is to have a virtual value for it when it needs to change again */ |
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
593
diff
changeset
|
483 |
#define STATUS_BAR 5 |
823358e83abf
(svn r1211) -Feature: Introduce sticky windows to all vehicle windows...Just make sure you do not sticky more than 23 at a time. Also a lot of places in the code invalidated the 'status bar' of the vehicle, referring to it as widget 4. This is now widget 5 and has been #definitized
darkvater
parents:
593
diff
changeset
|
484 |
|
0 | 485 |
#endif /* VEHICLE_H */ |