author | peter1138 |
Tue, 05 Dec 2006 17:53:33 +0000 | |
changeset 5251 | 3be755f9ab99 |
parent 5247 | c3eece01af11 |
child 5352 | 82a50c80b0c4 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#ifndef VEHICLE_H |
4 |
#define VEHICLE_H |
|
5 |
||
5216
d581e4db95b6
(svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents:
5211
diff
changeset
|
6 |
#include "oldpool.h" |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
7 |
#include "order.h" |
1944
012fa5e69118
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1922
diff
changeset
|
8 |
#include "rail.h" |
577 | 9 |
|
1763
9e6f367ae02e
(svn r2267) - Codechange: Reverted the typedeffing of VehicleType (r2256), since that interfered with the saveload code.
matthijs
parents:
1752
diff
changeset
|
10 |
enum { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
11 |
VEH_Invalid = 0x00, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
12 |
VEH_Train = 0x10, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
13 |
VEH_Road = 0x11, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
14 |
VEH_Ship = 0x12, |
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
15 |
VEH_Aircraft = 0x13, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
16 |
VEH_Special = 0x14, |
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
17 |
VEH_Disaster = 0x15, |
1763
9e6f367ae02e
(svn r2267) - Codechange: Reverted the typedeffing of VehicleType (r2256), since that interfered with the saveload code.
matthijs
parents:
1752
diff
changeset
|
18 |
} ; |
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
19 |
|
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
20 |
enum VehStatus { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
21 |
VS_HIDDEN = 0x01, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
22 |
VS_STOPPED = 0x02, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
23 |
VS_UNCLICKABLE = 0x04, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
24 |
VS_DEFPAL = 0x08, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
25 |
VS_TRAIN_SLOWING = 0x10, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
26 |
VS_SHADOW = 0x20, |
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
27 |
VS_AIRCRAFT_BROKEN = 0x40, |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
28 |
VS_CRASHED = 0x80, |
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
29 |
}; |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
30 |
|
5211
651c9272ad22
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5162
diff
changeset
|
31 |
enum LoadStatus { |
651c9272ad22
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5162
diff
changeset
|
32 |
LS_LOADING_FINISHED, |
651c9272ad22
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5162
diff
changeset
|
33 |
LS_CARGO_UNLOADING, |
5251
3be755f9ab99
(svn r7377) -Fix (r7326): With gradual loading, make sure cargo is only paid for once, and always notify the station the vehicle was present. (Maedhros)
peter1138
parents:
5247
diff
changeset
|
34 |
LS_CARGO_PAID_FOR, |
5211
651c9272ad22
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5162
diff
changeset
|
35 |
}; |
651c9272ad22
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5162
diff
changeset
|
36 |
|
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
37 |
/* Effect vehicle types */ |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
38 |
typedef enum EffectVehicle { |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
39 |
EV_CHIMNEY_SMOKE = 0, |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
40 |
EV_STEAM_SMOKE = 1, |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
41 |
EV_DIESEL_SMOKE = 2, |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
42 |
EV_ELECTRIC_SPARK = 3, |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
43 |
EV_SMOKE = 4, |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
44 |
EV_EXPLOSION_LARGE = 5, |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
45 |
EV_BREAKDOWN_SMOKE = 6, |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
46 |
EV_EXPLOSION_SMALL = 7, |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
47 |
EV_BULLDOZER = 8, |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
48 |
EV_BUBBLE = 9 |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
49 |
} EffectVehicle; |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
50 |
|
0 | 51 |
typedef struct VehicleRail { |
4434
4175805666a5
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4404
diff
changeset
|
52 |
uint16 last_speed; // NOSAVE: only used in UI |
0 | 53 |
uint16 crash_anim_pos; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
54 |
uint16 days_since_order_progr; |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
55 |
|
1905
f43d9e821deb
(svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents:
1804
diff
changeset
|
56 |
// cached values, recalculated on load and each time a vehicle is added to/removed from the consist. |
f43d9e821deb
(svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents:
1804
diff
changeset
|
57 |
uint16 cached_max_speed; // max speed of the consist. (minimum of the max speed of all vehicles in the consist) |
f43d9e821deb
(svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents:
1804
diff
changeset
|
58 |
uint32 cached_power; // total power of the consist. |
1922
797081e56d13
(svn r2428) - Feature: [newgrf] Implement shorter train vehicles (Therax), and the callback that goes with it.
hackykid
parents:
1908
diff
changeset
|
59 |
uint8 cached_veh_length; // length of this vehicle in units of 1/8 of normal length, cached because this can be set by a callback |
2587
d554e2a03afa
(svn r3124) Alter train loading/unloading time to use the actual length of the train instead of the number of wagons. The actual length is cached in the first vehicle of the train.
peter1138
parents:
2579
diff
changeset
|
60 |
uint16 cached_total_length; ///< Length of the whole train, valid only for first engine. |
d554e2a03afa
(svn r3124) Alter train loading/unloading time to use the actual length of the train instead of the number of wagons. The actual length is cached in the first vehicle of the train.
peter1138
parents:
2579
diff
changeset
|
61 |
|
1905
f43d9e821deb
(svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents:
1804
diff
changeset
|
62 |
// cached values, recalculated when the cargo on a train changes (in addition to the conditions above) |
5162
f1d90a883266
(svn r7268) -Codechange: change rail vehicle cached weight from 16 to 32 bit values to avoid possible overflows.
peter1138
parents:
5116
diff
changeset
|
63 |
uint32 cached_weight; // total weight of the consist. |
f1d90a883266
(svn r7268) -Codechange: change rail vehicle cached weight from 16 to 32 bit values to avoid possible overflows.
peter1138
parents:
5116
diff
changeset
|
64 |
uint32 cached_veh_weight; // weight of the vehicle. |
2595
0bab25144829
(svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents:
2587
diff
changeset
|
65 |
/** |
0bab25144829
(svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents:
2587
diff
changeset
|
66 |
* Position/type of visual effect. |
0bab25144829
(svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents:
2587
diff
changeset
|
67 |
* bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear) |
0bab25144829
(svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents:
2587
diff
changeset
|
68 |
* bit 4 - 5 = type of effect. (0 = default for engine class, 1 = steam, 2 = diesel, 3 = electric) |
0bab25144829
(svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents:
2587
diff
changeset
|
69 |
* bit 6 = disable visual effect. |
0bab25144829
(svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents:
2587
diff
changeset
|
70 |
* bit 7 = disable powered wagons. |
0bab25144829
(svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents:
2587
diff
changeset
|
71 |
*/ |
0bab25144829
(svn r3132) -NewGRF: support positioning of rail vehicle visual effects.
peter1138
parents:
2587
diff
changeset
|
72 |
byte cached_vis_effect; |
0 | 73 |
|
74 |
// NOSAVE: for wagon override - id of the first engine in train |
|
75 |
// 0xffff == not in train |
|
1796
cae31916ae54
(svn r2300) - CodeChange: check the last number of commands, now only the refit ones remain, and some server-only commands.
Darkvater
parents:
1790
diff
changeset
|
76 |
EngineID first_engine; |
0 | 77 |
|
78 |
byte track; |
|
79 |
byte force_proceed; |
|
80 |
byte railtype; |
|
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3347
diff
changeset
|
81 |
RailTypeMask compatible_railtypes; |
0 | 82 |
|
83 |
byte flags; |
|
2008
c9d6585c96c8
(svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents:
1977
diff
changeset
|
84 |
|
2676
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2666
diff
changeset
|
85 |
// Link between the two ends of a multiheaded engine |
2ba71e034d97
(svn r3218) -Feature: Multiheaded train engines will now stay in the same train
bjarni
parents:
2666
diff
changeset
|
86 |
Vehicle *other_multiheaded_part; |
0 | 87 |
} VehicleRail; |
88 |
||
89 |
enum { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
90 |
VRF_REVERSING = 0, |
0 | 91 |
|
92 |
// used to calculate if train is going up or down |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
93 |
VRF_GOINGUP = 1, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
94 |
VRF_GOINGDOWN = 2, |
1908
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1905
diff
changeset
|
95 |
|
bc48a30aba72
(svn r2414) - Feature: [newgrf] Implement powered wagons, and the callback that goes with it.
hackykid
parents:
1905
diff
changeset
|
96 |
// used to store if a wagon is powered or not |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
97 |
VRF_POWEREDWAGON = 3, |
3256
a23d94f568b7
(svn r3944) -Feature: it's now possible to turn a single unit in a train
bjarni
parents:
3173
diff
changeset
|
98 |
|
a23d94f568b7
(svn r3944) -Feature: it's now possible to turn a single unit in a train
bjarni
parents:
3173
diff
changeset
|
99 |
// used to reverse the visible direction of the vehicle |
a23d94f568b7
(svn r3944) -Feature: it's now possible to turn a single unit in a train
bjarni
parents:
3173
diff
changeset
|
100 |
VRF_REVERSE_DIRECTION = 4, |
4870
0ee22ed51ada
(svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents:
4734
diff
changeset
|
101 |
|
0ee22ed51ada
(svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents:
4734
diff
changeset
|
102 |
// used to mark train as lost because PF can't find the route |
0ee22ed51ada
(svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents:
4734
diff
changeset
|
103 |
VRF_NO_PATH_TO_DESTINATION = 5, |
5116
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4972
diff
changeset
|
104 |
|
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4972
diff
changeset
|
105 |
// used to mark that electric train engine is allowed to run on normal rail |
2a33a74925c5
(svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents:
4972
diff
changeset
|
106 |
VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6, |
0 | 107 |
}; |
108 |
||
109 |
typedef struct VehicleAir { |
|
110 |
uint16 crashed_counter; |
|
111 |
byte pos; |
|
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3977
diff
changeset
|
112 |
byte previous_pos; |
3347
d5d8ace1bb13
(svn r4131) - CodeChange: Add proper semantics for StationID for such variables instead of using the general uint16-type. StationID was added for depots, waypoints and stations where necessary. We probably need to change GetDepot(), IsDepotIndex(), IsStationIndex(), GetWaypoint() and IsWaypointIndex() as well to use StationID.
Darkvater
parents:
3344
diff
changeset
|
113 |
StationID targetairport; |
0 | 114 |
byte state; |
115 |
} VehicleAir; |
|
116 |
||
117 |
typedef struct VehicleRoad { |
|
118 |
byte state; |
|
119 |
byte frame; |
|
3009
c477ab0f00b3
(svn r3589) - Rename u.road.unk2 to u.road.blocked_ctr
peter1138
parents:
3008
diff
changeset
|
120 |
uint16 blocked_ctr; |
0 | 121 |
byte overtaking; |
122 |
byte overtaking_ctr; |
|
123 |
uint16 crashed_ctr; |
|
124 |
byte reverse_ctr; |
|
1217
ab9f02a224ab
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1174
diff
changeset
|
125 |
struct RoadStop *slot; |
ab9f02a224ab
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1174
diff
changeset
|
126 |
byte slot_age; |
0 | 127 |
} VehicleRoad; |
128 |
||
129 |
typedef struct VehicleSpecial { |
|
130 |
uint16 unk0; |
|
131 |
byte unk2; |
|
132 |
} VehicleSpecial; |
|
133 |
||
134 |
typedef struct VehicleDisaster { |
|
135 |
uint16 image_override; |
|
136 |
uint16 unk2; |
|
137 |
} VehicleDisaster; |
|
138 |
||
139 |
typedef struct VehicleShip { |
|
140 |
byte state; |
|
141 |
} VehicleShip; |
|
142 |
||
143 |
||
144 |
struct Vehicle { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
145 |
byte type; // type, ie roadven,train,ship,aircraft,special |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
146 |
byte subtype; // subtype (Filled with values from EffectVehicles or TrainSubTypes) |
0 | 147 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
148 |
VehicleID index; // NOSAVE: Index in vehicle array |
0 | 149 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
150 |
Vehicle *next; // next |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
151 |
Vehicle *first; // NOSAVE: pointer to the first vehicle in the chain |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
152 |
Vehicle *depot_list; //NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace |
0 | 153 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
154 |
StringID string_id; // Displayed string |
0 | 155 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
156 |
UnitID unitnumber; // unit number, for display purposes only |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
157 |
PlayerID owner; // which player owns the vehicle? |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
158 |
|
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
159 |
TileIndex tile; // Current tile index |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
160 |
TileIndex dest_tile; // Heading for this tile |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
161 |
|
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
162 |
int32 x_pos; // coordinates |
1174
27e386195965
(svn r1676) Increase the size of TileIndex and TileIndexDiff to 32bits and adapt the save/load data and some other parts of the code to that change
tron
parents:
1139
diff
changeset
|
163 |
int32 y_pos; |
0 | 164 |
byte z_pos; |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
165 |
byte direction; // facing |
0 | 166 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
167 |
byte spritenum; // currently displayed sprite index |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
168 |
// 0xfd == custom sprite, 0xfe == custom second head sprite |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
169 |
// 0xff == reserved for another custom sprite |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
170 |
uint16 cur_image; // sprite number for this vehicle |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
171 |
byte sprite_width; // width of vehicle sprite |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
172 |
byte sprite_height; // height of vehicle sprite |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
173 |
byte z_height; // z-height of vehicle sprite |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
174 |
int8 x_offs; // x offset for vehicle sprite |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
175 |
int8 y_offs; // y offset for vehicle sprite |
1770
b6bda4dc6da2
(svn r2274) - Codechange: some comments, parentheses and EngineID typedef for engine_type
Darkvater
parents:
1765
diff
changeset
|
176 |
EngineID engine_type; |
0 | 177 |
|
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
|
178 |
// 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
|
179 |
// 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
|
180 |
// 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
|
181 |
byte random_bits; |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
182 |
byte waiting_triggers; // triggers to be yet matched |
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
|
183 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
184 |
uint16 max_speed; // maximum speed |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
185 |
uint16 cur_speed; // current speed |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
186 |
byte subspeed; // fractional speed |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
187 |
byte acceleration; // used by train & aircraft |
0 | 188 |
byte progress; |
4656
acffecd6f484
(svn r6532) - Feature: Add support for NewGRF sound effects. Currently sound priority isn't supported.
peter1138
parents:
4635
diff
changeset
|
189 |
uint32 motion_counter; |
0 | 190 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
191 |
byte vehstatus; // Status |
3347
d5d8ace1bb13
(svn r4131) - CodeChange: Add proper semantics for StationID for such variables instead of using the general uint16-type. StationID was added for depots, waypoints and stations where necessary. We probably need to change GetDepot(), IsDepotIndex(), IsStationIndex(), GetWaypoint() and IsWaypointIndex() as well to use StationID.
Darkvater
parents:
3344
diff
changeset
|
192 |
StationID last_station_visited; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
193 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
194 |
CargoID cargo_type; // type of cargo this vehicle is carrying |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
195 |
byte cargo_days; // how many days have the pieces been in transit |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
196 |
StationID cargo_source; // source of cargo |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
197 |
uint16 cargo_cap; // total capacity |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
198 |
uint16 cargo_count; // how many pieces are used |
3870
766d7bd6c299
(svn r4910) - NewGRF: add and initialize cargo subtype for vehicle visual variations
peter1138
parents:
3580
diff
changeset
|
199 |
byte cargo_subtype; ///< Used for livery refits (NewGRF variations) |
0 | 200 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
201 |
byte day_counter; // increased by one for each day |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
202 |
byte tick_counter; // increased by one for each tick |
0 | 203 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
204 |
/* Begin Order-stuff */ |
3173
1b75b9a6ff71
(svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents:
3172
diff
changeset
|
205 |
Order current_order; ///< The current order (+ status, like: loading) |
4391
7bfd170bfdf5
(svn r6144) -Codechange: renamed OrderID to VehicleOrderID, because it had nothing to do
truelight
parents:
4384
diff
changeset
|
206 |
VehicleOrderID cur_order_index; ///< The index to the current order |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
207 |
|
3173
1b75b9a6ff71
(svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents:
3172
diff
changeset
|
208 |
Order *orders; ///< Pointer to the first order for this vehicle |
4391
7bfd170bfdf5
(svn r6144) -Codechange: renamed OrderID to VehicleOrderID, because it had nothing to do
truelight
parents:
4384
diff
changeset
|
209 |
VehicleOrderID num_orders; ///< How many orders there are in the list |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
210 |
|
3173
1b75b9a6ff71
(svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents:
3172
diff
changeset
|
211 |
Vehicle *next_shared; ///< If not NULL, this points to the next vehicle that shared the order |
1b75b9a6ff71
(svn r3805) - [FS#62] Fix doxygen comments to refer to the correct parameter. (sulai)
peter1138
parents:
3172
diff
changeset
|
212 |
Vehicle *prev_shared; ///< If not NULL, this points to the prev vehicle that shared the order |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
213 |
/* End Order-stuff */ |
0 | 214 |
|
215 |
// Boundaries for the current position in the world and a next hash link. |
|
216 |
// 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
|
217 |
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
|
218 |
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
|
219 |
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
|
220 |
int32 bottom_coord; |
2634
16334e1a4862
(svn r3176) Use proper types, not some variants of int
tron
parents:
2630
diff
changeset
|
221 |
VehicleID next_hash; |
0 | 222 |
|
223 |
// Related to age and service time |
|
4326
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4289
diff
changeset
|
224 |
Date age; // Age in days |
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4289
diff
changeset
|
225 |
Date max_age; // Maximum age |
4289
ff1b2b915cab
(svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents:
4176
diff
changeset
|
226 |
Date date_of_last_service; |
ff1b2b915cab
(svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents:
4176
diff
changeset
|
227 |
Date service_interval; |
0 | 228 |
uint16 reliability; |
229 |
uint16 reliability_spd_dec; |
|
230 |
byte breakdown_ctr; |
|
231 |
byte breakdown_delay; |
|
232 |
byte breakdowns_since_last_service; |
|
233 |
byte breakdown_chance; |
|
4326
c2ae4dbc1074
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents:
4289
diff
changeset
|
234 |
Year build_year; |
0 | 235 |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
236 |
bool leave_depot_instantly; // NOSAVE: stores if the vehicle needs to leave the depot it just entered. Used by autoreplace |
2617
a9e1a187de99
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
bjarni
parents:
2602
diff
changeset
|
237 |
|
0 | 238 |
uint16 load_unload_time_rem; |
5211
651c9272ad22
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5162
diff
changeset
|
239 |
byte load_status; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
164
diff
changeset
|
240 |
|
0 | 241 |
int32 profit_this_year; |
242 |
int32 profit_last_year; |
|
243 |
uint32 value; |
|
244 |
||
245 |
union { |
|
246 |
VehicleRail rail; |
|
247 |
VehicleAir air; |
|
248 |
VehicleRoad road; |
|
249 |
VehicleSpecial special; |
|
250 |
VehicleDisaster disaster; |
|
251 |
VehicleShip ship; |
|
252 |
} u; |
|
253 |
}; |
|
254 |
||
1765
f8d29d5462c9
(svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents:
1763
diff
changeset
|
255 |
#define is_custom_sprite(x) (x >= 0xFD) |
f8d29d5462c9
(svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents:
1763
diff
changeset
|
256 |
#define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD) |
f8d29d5462c9
(svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents:
1763
diff
changeset
|
257 |
#define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE) |
0 | 258 |
|
259 |
typedef void *VehicleFromPosProc(Vehicle *v, void *data); |
|
260 |
||
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
|
261 |
void VehicleServiceInDepot(Vehicle *v); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1067
diff
changeset
|
262 |
Vehicle *AllocateVehicle(void); |
2601
7c94a0e394a6
(svn r3138) -Fix: [clone vehicles] fixed assert when it was possible to allocate some vehicles to clone a train, but not for all cars
bjarni
parents:
2599
diff
changeset
|
263 |
bool AllocateVehicles(Vehicle **vl, int num); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1067
diff
changeset
|
264 |
Vehicle *ForceAllocateVehicle(void); |
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1067
diff
changeset
|
265 |
Vehicle *ForceAllocateSpecialVehicle(void); |
0 | 266 |
void VehiclePositionChanged(Vehicle *v); |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1067
diff
changeset
|
267 |
void AfterLoadVehicles(void); |
0 | 268 |
Vehicle *GetLastVehicleInChain(Vehicle *v); |
1475 | 269 |
Vehicle *GetPrevVehicleInChain(const Vehicle *v); |
270 |
Vehicle *GetFirstVehicleInChain(const Vehicle *v); |
|
2630 | 271 |
uint CountVehiclesInChain(const Vehicle* v); |
4574
497540b4a75f
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
bjarni
parents:
4544
diff
changeset
|
272 |
bool IsEngineCountable(const Vehicle *v); |
0 | 273 |
void DeleteVehicleChain(Vehicle *v); |
274 |
void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc); |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1067
diff
changeset
|
275 |
void CallVehicleTicks(void); |
1605
c4630be67467
(svn r2109) -Fix: use FindVehicleOnTileZ(tile, 0) over FindVehicleBetween(tile, tile, 0)
truelight
parents:
1601
diff
changeset
|
276 |
Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z); |
0 | 277 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1067
diff
changeset
|
278 |
void InitializeTrains(void); |
2804
b932fe148d36
(svn r3352) - NewGRF: Move initialization of vehicle random_bits to DC_EXEC blocks to allow use of Random() instead of InteractiveRandom(), which will alleviate some possible network desyncs.
peter1138
parents:
2704
diff
changeset
|
279 |
byte VehicleRandomBits(void); |
0 | 280 |
|
281 |
bool CanFillVehicle(Vehicle *v); |
|
2704
dc9ae68dfd74
(svn r3248) - Codechange: Change interface of CanRefitTo() to supply the engine type directly instead of getting it from a vehicle. This allows the function to be used before vehicles are involved.
peter1138
parents:
2676
diff
changeset
|
282 |
bool CanRefitTo(EngineID engine_type, CargoID cid_to); |
3973
7624a250577b
(svn r5146) - NewGRF: Support selection of aircraft default cargo type by checking its refit mask. If aircraft can be refitted to passengers, no change happens, else the first refittable type is chosen. Also use refit capacity to determine the default capacity.
peter1138
parents:
3948
diff
changeset
|
283 |
CargoID FindFirstRefittableCargo(EngineID engine_type); |
4544
b2d5ad597e4d
(svn r6376) -Codechange: [vehicle refit] moved all refit cost calculations into GetRefitCost()
bjarni
parents:
4506
diff
changeset
|
284 |
int32 GetRefitCost(EngineID engine_type); |
0 | 285 |
|
286 |
void ViewportAddVehicles(DrawPixelInfo *dpi); |
|
287 |
||
288 |
/* train_cmd.h */ |
|
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3153
diff
changeset
|
289 |
int GetTrainImage(const Vehicle* v, Direction direction); |
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3153
diff
changeset
|
290 |
int GetAircraftImage(const Vehicle* v, Direction direction); |
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3153
diff
changeset
|
291 |
int GetRoadVehImage(const Vehicle* v, Direction direction); |
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3153
diff
changeset
|
292 |
int GetShipImage(const Vehicle* v, Direction direction); |
0 | 293 |
|
1359
8ba976aed634
(svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()
tron
parents:
1330
diff
changeset
|
294 |
Vehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicle type); |
8ba976aed634
(svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()
tron
parents:
1330
diff
changeset
|
295 |
Vehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicle type); |
8ba976aed634
(svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()
tron
parents:
1330
diff
changeset
|
296 |
Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicle type); |
0 | 297 |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1944
diff
changeset
|
298 |
uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y); |
0 | 299 |
|
3881 | 300 |
StringID VehicleInTheWayErrMsg(const Vehicle* v); |
0 | 301 |
Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z); |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3973
diff
changeset
|
302 |
TileIndex GetVehicleOutOfTunnelTile(const Vehicle *v); |
0 | 303 |
|
3172
1605cb59ccd9
(svn r3803) Change the second parameter of UpdateSignalsOnSegment() from Direction to DiagDirection as that's what it really operates on
tron
parents:
3157
diff
changeset
|
304 |
bool UpdateSignalsOnSegment(TileIndex tile, DiagDirection direction); |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1944
diff
changeset
|
305 |
void SetSignalsOnBothDir(TileIndex tile, byte track); |
0 | 306 |
|
2116 | 307 |
Vehicle *CheckClickOnVehicle(const ViewPort *vp, int x, int y); |
0 | 308 |
|
309 |
void DecreaseVehicleValue(Vehicle *v); |
|
310 |
void CheckVehicleBreakdown(Vehicle *v); |
|
311 |
void AgeVehicle(Vehicle *v); |
|
2574
382fd3f37604
(svn r3111) -Fix: [autoreplace] [ 1341783 ] Assertion failure in vehicle.c line 378
bjarni
parents:
2564
diff
changeset
|
312 |
void VehicleEnteredDepotThisTick(Vehicle *v); |
0 | 313 |
|
314 |
void BeginVehicleMove(Vehicle *v); |
|
315 |
void EndVehicleMove(Vehicle *v); |
|
316 |
||
2561
c78c3d248897
(svn r3098) static, const, uint -> TileIndex, indentation, bracing, unused return values, ... mostly related to the clone vehicle GUI
tron
parents:
2552
diff
changeset
|
317 |
void ShowAircraftViewWindow(const Vehicle* v); |
0 | 318 |
|
1282
e7a73ee62d2f
(svn r1786) -Fix: unitnumber is increased to 16bit, so now you can have up to 5000
truelight
parents:
1279
diff
changeset
|
319 |
UnitID GetFreeUnitNumber(byte type); |
0 | 320 |
|
5211
651c9272ad22
(svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents:
5162
diff
changeset
|
321 |
int LoadUnloadVehicle(Vehicle *v, bool just_arrived); |
0 | 322 |
|
1905
f43d9e821deb
(svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
hackykid
parents:
1804
diff
changeset
|
323 |
void TrainConsistChanged(Vehicle *v); |
3355
a653b8e47f27
(svn r4150) -Feature: Merged elrails into trunk. Thanks to Tron for lots of code and proofreading, thanks to peter1138 for another lot of code and ideas.
celestar
parents:
3347
diff
changeset
|
324 |
void TrainPowerChanged(Vehicle *v); |
1790
4afb4b4e4278
(svn r2294) - CodeChange: check the service interval settings when changing of all vehicle-types. To simplify things introduce GetServiceIntervalClamped() that returns the same or clamped value of the new service interval. There were some inconsistencies in the gui files so I had to change those, and const correctness kicked in, so it's a bit messy at certain points.
Darkvater
parents:
1786
diff
changeset
|
325 |
int32 GetTrainRunningCost(const Vehicle *v); |
0 | 326 |
|
1472
043304846688
(svn r1976) Cleanups - mostly indentation and fiddling with loops
tron
parents:
1359
diff
changeset
|
327 |
int CheckTrainStoppedInDepot(const Vehicle *v); |
0 | 328 |
|
593 | 329 |
bool VehicleNeedsService(const Vehicle *v); |
330 |
||
4681
7d7a89b32dd0
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4678
diff
changeset
|
331 |
uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, byte type, PlayerID owner, StationID station, OrderID order, uint16 depot_airport_index, uint16 window_type); |
4635
b9fb2f19eb64
(svn r6503) -Codechange: added a function to tell what vehicles a depot contains
bjarni
parents:
4574
diff
changeset
|
332 |
void BuildDepotVehicleList(byte type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count); |
4506
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4497
diff
changeset
|
333 |
int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id); |
4734
20770a208a04
(svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
bjarni
parents:
4725
diff
changeset
|
334 |
bool IsVehicleInDepot(const Vehicle *v); |
4725
f7284b86833f
(svn r6637) -Codechange: merged all (vehicle type)EnterDepot into VehicleEnterDepot()
bjarni
parents:
4681
diff
changeset
|
335 |
void VehicleEnterDepot(Vehicle *v); |
4506
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4497
diff
changeset
|
336 |
|
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4497
diff
changeset
|
337 |
/* Flags to add to p2 for goto depot commands */ |
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4497
diff
changeset
|
338 |
/* Note: bits 8-10 are used for VLW flags */ |
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4497
diff
changeset
|
339 |
enum { |
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4497
diff
changeset
|
340 |
DEPOT_SERVICE = (1 << 0), // The vehicle will leave the depot right after arrival (serivce only) |
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4497
diff
changeset
|
341 |
DEPOT_MASS_SEND = (1 << 1), // Tells that it's a mass send to depot command (type in VLW flag) |
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4497
diff
changeset
|
342 |
DEPOT_DONT_CANCEL = (1 << 2), // Don't cancel current goto depot command if any |
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4497
diff
changeset
|
343 |
DEPOT_LOCATE_HANGAR = (1 << 3), // Find another airport if the target one lacks a hangar |
0d8fcc0a4e49
(svn r6291) -Feature: Vehicle lists from the station window now also got the goto depot button
bjarni
parents:
4497
diff
changeset
|
344 |
}; |
4463
3a70624c40eb
(svn r6246) -Feature: added the many times requested "send all vehicle to depot" button
bjarni
parents:
4451
diff
changeset
|
345 |
|
0 | 346 |
typedef struct GetNewVehiclePosResult { |
347 |
int x,y; |
|
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1944
diff
changeset
|
348 |
TileIndex old_tile; |
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1944
diff
changeset
|
349 |
TileIndex new_tile; |
0 | 350 |
} GetNewVehiclePosResult; |
351 |
||
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
352 |
/** |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
353 |
* Returns the Trackdir on which the vehicle is currently located. |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
354 |
* Works for trains and ships. |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
355 |
* Currently works only sortof for road vehicles, since they have a fuzzy |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
356 |
* concept of being "on" a trackdir. Dunno really what it returns for a road |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
357 |
* vehicle that is halfway a tile, never really understood that part. For road |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
358 |
* vehicles that are at the beginning or end of the tile, should just return |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
359 |
* the diagonal trackdir on which they are driving. I _think_. |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
360 |
* For other vehicles types, or vehicles with no clear trackdir (such as those |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
361 |
* in depots), returns 0xFF. |
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
362 |
*/ |
1944
012fa5e69118
(svn r2450) * Codechange: Replaced all uses of the arrays in tile.h with calls to the associated wrapper functions.
matthijs
parents:
1922
diff
changeset
|
363 |
Trackdir GetVehicleTrackdir(const Vehicle* v); |
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1605
diff
changeset
|
364 |
|
0 | 365 |
/* returns true if staying in the same tile */ |
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2293
diff
changeset
|
366 |
bool GetNewVehiclePos(const Vehicle *v, GetNewVehiclePosResult *gp); |
3157
40de8616c04c
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3153
diff
changeset
|
367 |
Direction GetDirectionTowards(const Vehicle* v, int x, int y); |
0 | 368 |
|
369 |
#define BEGIN_ENUM_WAGONS(v) do { |
|
370 |
#define END_ENUM_WAGONS(v) } while ( (v=v->next) != NULL); |
|
371 |
||
5216
d581e4db95b6
(svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents:
5211
diff
changeset
|
372 |
DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125) |
1279
4f83fbde72de
(svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents:
1266
diff
changeset
|
373 |
|
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
374 |
static inline VehicleID GetMaxVehicleIndex(void) |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
375 |
{ |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
376 |
/* TODO - This isn't the real content of the function, but |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
377 |
* with the new pool-system this will be replaced with one that |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
378 |
* _really_ returns the highest index. Now it just returns |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
379 |
* the next safe value we are sure about everything is below. |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
380 |
*/ |
5247
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
381 |
return GetVehiclePoolSize() - 1; |
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
382 |
} |
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
383 |
|
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
384 |
static inline uint GetNumVehicles(void) |
c3eece01af11
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
385 |
{ |
4354
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
386 |
return GetVehiclePoolSize(); |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
387 |
} |
684ab9249dae
(svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents:
4352
diff
changeset
|
388 |
|
1279
4f83fbde72de
(svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents:
1266
diff
changeset
|
389 |
/** |
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1313
diff
changeset
|
390 |
* Check if a Vehicle really exists. |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1313
diff
changeset
|
391 |
*/ |
1770
b6bda4dc6da2
(svn r2274) - Codechange: some comments, parentheses and EngineID typedef for engine_type
Darkvater
parents:
1765
diff
changeset
|
392 |
static inline bool IsValidVehicle(const Vehicle *v) |
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1313
diff
changeset
|
393 |
{ |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1313
diff
changeset
|
394 |
return v->type != 0; |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1313
diff
changeset
|
395 |
} |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1313
diff
changeset
|
396 |
|
4404
484c76b14294
(svn r6157) -Codechange: DeleteVehicle removes a vehicle from the pool
truelight
parents:
4391
diff
changeset
|
397 |
void DestroyVehicle(Vehicle *v); |
484c76b14294
(svn r6157) -Codechange: DeleteVehicle removes a vehicle from the pool
truelight
parents:
4391
diff
changeset
|
398 |
|
484c76b14294
(svn r6157) -Codechange: DeleteVehicle removes a vehicle from the pool
truelight
parents:
4391
diff
changeset
|
399 |
static inline void DeleteVehicle(Vehicle *v) |
484c76b14294
(svn r6157) -Codechange: DeleteVehicle removes a vehicle from the pool
truelight
parents:
4391
diff
changeset
|
400 |
{ |
484c76b14294
(svn r6157) -Codechange: DeleteVehicle removes a vehicle from the pool
truelight
parents:
4391
diff
changeset
|
401 |
DestroyVehicle(v); |
484c76b14294
(svn r6157) -Codechange: DeleteVehicle removes a vehicle from the pool
truelight
parents:
4391
diff
changeset
|
402 |
v->type = 0; |
484c76b14294
(svn r6157) -Codechange: DeleteVehicle removes a vehicle from the pool
truelight
parents:
4391
diff
changeset
|
403 |
} |
484c76b14294
(svn r6157) -Codechange: DeleteVehicle removes a vehicle from the pool
truelight
parents:
4391
diff
changeset
|
404 |
|
4972 | 405 |
#define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (IsValidVehicle(v)) |
4346
3f00094f2670
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
406 |
#define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0) |
3f00094f2670
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
407 |
|
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1313
diff
changeset
|
408 |
/** |
1279
4f83fbde72de
(svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents:
1266
diff
changeset
|
409 |
* Check if an index is a vehicle-index (so between 0 and max-vehicles) |
4f83fbde72de
(svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents:
1266
diff
changeset
|
410 |
* |
4f83fbde72de
(svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents:
1266
diff
changeset
|
411 |
* @return Returns true if the vehicle-id is in range |
4f83fbde72de
(svn r1783) -Add: Dynamic vehicles (now up to 64k of vehicles)
truelight
parents:
1266
diff
changeset
|
412 |
*/ |
4352
8ddb01bc6075
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4346
diff
changeset
|
413 |
static inline bool IsValidVehicleID(uint index) |
1237
0a1ce05c3d45
(svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents:
1217
diff
changeset
|
414 |
{ |
4352
8ddb01bc6075
(svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents:
4346
diff
changeset
|
415 |
return index < GetVehiclePoolSize() && IsValidVehicle(GetVehicle(index)); |
1237
0a1ce05c3d45
(svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents:
1217
diff
changeset
|
416 |
} |
0a1ce05c3d45
(svn r1741) - Fix: added IsVehicleIndex() so it's possible to protect GetVehicle() from reading an invalid vehicle index
bjarni
parents:
1217
diff
changeset
|
417 |
|
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
418 |
/* Returns order 'index' of a vehicle or NULL when it doesn't exists */ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
419 |
static inline Order *GetVehicleOrder(const Vehicle *v, int index) |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
420 |
{ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
421 |
Order *order = v->orders; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
422 |
|
1765
f8d29d5462c9
(svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents:
1763
diff
changeset
|
423 |
if (index < 0) return NULL; |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
424 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
425 |
while (order != NULL && index-- > 0) |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
426 |
order = order->next; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
427 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
428 |
return order; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
429 |
} |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
430 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
431 |
/* Returns the last order of a vehicle, or NULL if it doesn't exists */ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
432 |
static inline Order *GetLastVehicleOrder(const Vehicle *v) |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
433 |
{ |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
434 |
Order *order = v->orders; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
435 |
|
1765
f8d29d5462c9
(svn r2269) - CodeChange: no else after return; exchange some magic 0xffff with INVALID_VEHICLE, vehicle index is of type VehicleID
Darkvater
parents:
1763
diff
changeset
|
436 |
if (order == NULL) return NULL; |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
437 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
438 |
while (order->next != NULL) |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
439 |
order = order->next; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
440 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
441 |
return order; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
442 |
} |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
443 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
444 |
/* Get the first vehicle of a shared-list, so we only have to walk forwards */ |
4494
15b8ae6bd860
(svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents:
4463
diff
changeset
|
445 |
static inline Vehicle *GetFirstVehicleFromSharedList(const Vehicle *v) |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
446 |
{ |
4494
15b8ae6bd860
(svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents:
4463
diff
changeset
|
447 |
Vehicle *u = (Vehicle *)v; |
15b8ae6bd860
(svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents:
4463
diff
changeset
|
448 |
while (u->prev_shared != NULL) u = u->prev_shared; |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
449 |
|
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
450 |
return u; |
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1020
diff
changeset
|
451 |
} |
0 | 452 |
|
453 |
// NOSAVE: Return values from various commands. |
|
2564 | 454 |
VARDEF VehicleID _new_vehicle_id; |
3008
7b519db78ce2
(svn r3588) - Refit: Use only one global to return the refit capacity rather than one per vehicle type.
peter1138
parents:
2916
diff
changeset
|
455 |
VARDEF uint16 _returned_refit_capacity; |
0 | 456 |
|
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4354
diff
changeset
|
457 |
enum { |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4354
diff
changeset
|
458 |
INVALID_VEHICLE = 0xFFFF, |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4354
diff
changeset
|
459 |
}; |
0 | 460 |
|
3105
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
461 |
/** |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
462 |
* Get the colour map for an engine. This used for unbuilt engines in the user interface. |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
463 |
* @param engine_type ID of engine |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
464 |
* @param player ID of player |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
465 |
* @return A ready-to-use palette modifier |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
466 |
*/ |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
467 |
PalSpriteID GetEnginePalette(EngineID engine_type, PlayerID player); |
3040
c3473d1fb81f
(svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
peter1138
parents:
3022
diff
changeset
|
468 |
|
3105
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
469 |
/** |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
470 |
* Get the colour map for a vehicle. |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
471 |
* @param v Vehicle to get colour map for |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
472 |
* @return A ready-to-use palette modifier |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
473 |
*/ |
4a6514d7a8ba
(svn r3701) [2cc] move vehicle/engine palette functions out of header file and document the remaining definitions
peter1138
parents:
3040
diff
changeset
|
474 |
PalSpriteID GetVehiclePalette(const Vehicle *v); |
3040
c3473d1fb81f
(svn r3620) - 2cc: Replace use of macro to determine colour map with a function call for drawing of vehicles.
peter1138
parents:
3022
diff
changeset
|
475 |
|
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
|
476 |
/* 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
|
477 |
* 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
|
478 |
#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
|
479 |
|
4494
15b8ae6bd860
(svn r6279) -Codechange (r1525): Use proper const pointers for functions that do not change them .
Darkvater
parents:
4463
diff
changeset
|
480 |
extern const uint32 _send_to_depot_proc_table[]; |
4451
66603f0f732e
(svn r6229) -Feature: Shared order lists now got a "goto depot" button
bjarni
parents:
4434
diff
changeset
|
481 |
#define CMD_SEND_TO_DEPOT(x) _send_to_depot_proc_table[ x - VEH_Train] |
66603f0f732e
(svn r6229) -Feature: Shared order lists now got a "goto depot" button
bjarni
parents:
4434
diff
changeset
|
482 |
|
0 | 483 |
#endif /* VEHICLE_H */ |