30 * @return Returns true if vehicle is a front engine |
30 * @return Returns true if vehicle is a front engine |
31 */ |
31 */ |
32 static inline bool IsFrontEngine(const Vehicle *v) |
32 static inline bool IsFrontEngine(const Vehicle *v) |
33 { |
33 { |
34 assert(v->type == VEH_TRAIN); |
34 assert(v->type == VEH_TRAIN); |
35 return HASBIT(v->subtype, Train_Front); |
35 return HasBit(v->subtype, Train_Front); |
36 } |
36 } |
37 |
37 |
38 /** Set front engine state |
38 /** Set front engine state |
39 * @param v vehicle to change |
39 * @param v vehicle to change |
40 */ |
40 */ |
41 static inline void SetFrontEngine(Vehicle *v) |
41 static inline void SetFrontEngine(Vehicle *v) |
42 { |
42 { |
43 assert(v->type == VEH_TRAIN); |
43 assert(v->type == VEH_TRAIN); |
44 SETBIT(v->subtype, Train_Front); |
44 SetBit(v->subtype, Train_Front); |
45 } |
45 } |
46 |
46 |
47 /** Remove the front engine state |
47 /** Remove the front engine state |
48 * @param v vehicle to change |
48 * @param v vehicle to change |
49 */ |
49 */ |
50 static inline void ClearFrontEngine(Vehicle *v) |
50 static inline void ClearFrontEngine(Vehicle *v) |
51 { |
51 { |
52 assert(v->type == VEH_TRAIN); |
52 assert(v->type == VEH_TRAIN); |
53 CLRBIT(v->subtype, Train_Front); |
53 ClrBit(v->subtype, Train_Front); |
54 } |
54 } |
55 |
55 |
56 /** Check if a vehicle is an articulated part of an engine |
56 /** Check if a vehicle is an articulated part of an engine |
57 * @param v vehicle to check |
57 * @param v vehicle to check |
58 * @return Returns true if vehicle is an articulated part |
58 * @return Returns true if vehicle is an articulated part |
59 */ |
59 */ |
60 static inline bool IsArticulatedPart(const Vehicle *v) |
60 static inline bool IsArticulatedPart(const Vehicle *v) |
61 { |
61 { |
62 assert(v->type == VEH_TRAIN); |
62 assert(v->type == VEH_TRAIN); |
63 return HASBIT(v->subtype, Train_Articulated_Part); |
63 return HasBit(v->subtype, Train_Articulated_Part); |
64 } |
64 } |
65 |
65 |
66 /** Set a vehicle to be an articulated part |
66 /** Set a vehicle to be an articulated part |
67 * @param v vehicle to change |
67 * @param v vehicle to change |
68 */ |
68 */ |
69 static inline void SetArticulatedPart(Vehicle *v) |
69 static inline void SetArticulatedPart(Vehicle *v) |
70 { |
70 { |
71 assert(v->type == VEH_TRAIN); |
71 assert(v->type == VEH_TRAIN); |
72 SETBIT(v->subtype, Train_Articulated_Part); |
72 SetBit(v->subtype, Train_Articulated_Part); |
73 } |
73 } |
74 |
74 |
75 /** Clear a vehicle from being an articulated part |
75 /** Clear a vehicle from being an articulated part |
76 * @param v vehicle to change |
76 * @param v vehicle to change |
77 */ |
77 */ |
78 static inline void ClearArticulatedPart(Vehicle *v) |
78 static inline void ClearArticulatedPart(Vehicle *v) |
79 { |
79 { |
80 assert(v->type == VEH_TRAIN); |
80 assert(v->type == VEH_TRAIN); |
81 CLRBIT(v->subtype, Train_Articulated_Part); |
81 ClrBit(v->subtype, Train_Articulated_Part); |
82 } |
82 } |
83 |
83 |
84 /** Check if a vehicle is a wagon |
84 /** Check if a vehicle is a wagon |
85 * @param v vehicle to check |
85 * @param v vehicle to check |
86 * @return Returns true if vehicle is a wagon |
86 * @return Returns true if vehicle is a wagon |
87 */ |
87 */ |
88 static inline bool IsTrainWagon(const Vehicle *v) |
88 static inline bool IsTrainWagon(const Vehicle *v) |
89 { |
89 { |
90 assert(v->type == VEH_TRAIN); |
90 assert(v->type == VEH_TRAIN); |
91 return HASBIT(v->subtype, Train_Wagon); |
91 return HasBit(v->subtype, Train_Wagon); |
92 } |
92 } |
93 |
93 |
94 /** Set a vehicle to be a wagon |
94 /** Set a vehicle to be a wagon |
95 * @param v vehicle to change |
95 * @param v vehicle to change |
96 */ |
96 */ |
97 static inline void SetTrainWagon(Vehicle *v) |
97 static inline void SetTrainWagon(Vehicle *v) |
98 { |
98 { |
99 assert(v->type == VEH_TRAIN); |
99 assert(v->type == VEH_TRAIN); |
100 SETBIT(v->subtype, Train_Wagon); |
100 SetBit(v->subtype, Train_Wagon); |
101 } |
101 } |
102 |
102 |
103 /** Clear wagon property |
103 /** Clear wagon property |
104 * @param v vehicle to change |
104 * @param v vehicle to change |
105 */ |
105 */ |
106 static inline void ClearTrainWagon(Vehicle *v) |
106 static inline void ClearTrainWagon(Vehicle *v) |
107 { |
107 { |
108 assert(v->type == VEH_TRAIN); |
108 assert(v->type == VEH_TRAIN); |
109 CLRBIT(v->subtype, Train_Wagon); |
109 ClrBit(v->subtype, Train_Wagon); |
110 } |
110 } |
111 |
111 |
112 /** Check if a vehicle is an engine (can be first in a train) |
112 /** Check if a vehicle is an engine (can be first in a train) |
113 * @param v vehicle to check |
113 * @param v vehicle to check |
114 * @return Returns true if vehicle is an engine |
114 * @return Returns true if vehicle is an engine |
115 */ |
115 */ |
116 static inline bool IsTrainEngine(const Vehicle *v) |
116 static inline bool IsTrainEngine(const Vehicle *v) |
117 { |
117 { |
118 assert(v->type == VEH_TRAIN); |
118 assert(v->type == VEH_TRAIN); |
119 return HASBIT(v->subtype, Train_Engine); |
119 return HasBit(v->subtype, Train_Engine); |
120 } |
120 } |
121 |
121 |
122 /** Set engine status |
122 /** Set engine status |
123 * @param v vehicle to change |
123 * @param v vehicle to change |
124 */ |
124 */ |
125 static inline void SetTrainEngine(Vehicle *v) |
125 static inline void SetTrainEngine(Vehicle *v) |
126 { |
126 { |
127 assert(v->type == VEH_TRAIN); |
127 assert(v->type == VEH_TRAIN); |
128 SETBIT(v->subtype, Train_Engine); |
128 SetBit(v->subtype, Train_Engine); |
129 } |
129 } |
130 |
130 |
131 /** Clear engine status |
131 /** Clear engine status |
132 * @param v vehicle to change |
132 * @param v vehicle to change |
133 */ |
133 */ |
134 static inline void ClearTrainEngine(Vehicle *v) |
134 static inline void ClearTrainEngine(Vehicle *v) |
135 { |
135 { |
136 assert(v->type == VEH_TRAIN); |
136 assert(v->type == VEH_TRAIN); |
137 CLRBIT(v->subtype, Train_Engine); |
137 ClrBit(v->subtype, Train_Engine); |
138 } |
138 } |
139 |
139 |
140 /** Check if a vehicle is a free wagon (got no engine in front of it) |
140 /** Check if a vehicle is a free wagon (got no engine in front of it) |
141 * @param v vehicle to check |
141 * @param v vehicle to check |
142 * @return Returns true if vehicle is a free wagon |
142 * @return Returns true if vehicle is a free wagon |
143 */ |
143 */ |
144 static inline bool IsFreeWagon(const Vehicle *v) |
144 static inline bool IsFreeWagon(const Vehicle *v) |
145 { |
145 { |
146 assert(v->type == VEH_TRAIN); |
146 assert(v->type == VEH_TRAIN); |
147 return HASBIT(v->subtype, Train_Free_Wagon); |
147 return HasBit(v->subtype, Train_Free_Wagon); |
148 } |
148 } |
149 |
149 |
150 /** Set if a vehicle is a free wagon |
150 /** Set if a vehicle is a free wagon |
151 * @param v vehicle to change |
151 * @param v vehicle to change |
152 */ |
152 */ |
153 static inline void SetFreeWagon(Vehicle *v) |
153 static inline void SetFreeWagon(Vehicle *v) |
154 { |
154 { |
155 assert(v->type == VEH_TRAIN); |
155 assert(v->type == VEH_TRAIN); |
156 SETBIT(v->subtype, Train_Free_Wagon); |
156 SetBit(v->subtype, Train_Free_Wagon); |
157 } |
157 } |
158 |
158 |
159 /** Clear a vehicle from being a free wagon |
159 /** Clear a vehicle from being a free wagon |
160 * @param v vehicle to change |
160 * @param v vehicle to change |
161 */ |
161 */ |
162 static inline void ClearFreeWagon(Vehicle *v) |
162 static inline void ClearFreeWagon(Vehicle *v) |
163 { |
163 { |
164 assert(v->type == VEH_TRAIN); |
164 assert(v->type == VEH_TRAIN); |
165 CLRBIT(v->subtype, Train_Free_Wagon); |
165 ClrBit(v->subtype, Train_Free_Wagon); |
166 } |
166 } |
167 |
167 |
168 /** Check if a vehicle is a multiheaded engine |
168 /** Check if a vehicle is a multiheaded engine |
169 * @param v vehicle to check |
169 * @param v vehicle to check |
170 * @return Returns true if vehicle is a multiheaded engine |
170 * @return Returns true if vehicle is a multiheaded engine |
171 */ |
171 */ |
172 static inline bool IsMultiheaded(const Vehicle *v) |
172 static inline bool IsMultiheaded(const Vehicle *v) |
173 { |
173 { |
174 assert(v->type == VEH_TRAIN); |
174 assert(v->type == VEH_TRAIN); |
175 return HASBIT(v->subtype, Train_Multiheaded); |
175 return HasBit(v->subtype, Train_Multiheaded); |
176 } |
176 } |
177 |
177 |
178 /** Set if a vehicle is a multiheaded engine |
178 /** Set if a vehicle is a multiheaded engine |
179 * @param v vehicle to change |
179 * @param v vehicle to change |
180 */ |
180 */ |
181 static inline void SetMultiheaded(Vehicle *v) |
181 static inline void SetMultiheaded(Vehicle *v) |
182 { |
182 { |
183 assert(v->type == VEH_TRAIN); |
183 assert(v->type == VEH_TRAIN); |
184 SETBIT(v->subtype, Train_Multiheaded); |
184 SetBit(v->subtype, Train_Multiheaded); |
185 } |
185 } |
186 |
186 |
187 /** Clear multiheaded engine property |
187 /** Clear multiheaded engine property |
188 * @param v vehicle to change |
188 * @param v vehicle to change |
189 */ |
189 */ |
190 static inline void ClearMultiheaded(Vehicle *v) |
190 static inline void ClearMultiheaded(Vehicle *v) |
191 { |
191 { |
192 assert(v->type == VEH_TRAIN); |
192 assert(v->type == VEH_TRAIN); |
193 CLRBIT(v->subtype, Train_Multiheaded); |
193 ClrBit(v->subtype, Train_Multiheaded); |
194 } |
194 } |
195 |
195 |
196 /** Check if an engine has an articulated part. |
196 /** Check if an engine has an articulated part. |
197 * @param v Vehicle. |
197 * @param v Vehicle. |
198 * @return True if the engine has an articulated part. |
198 * @return True if the engine has an articulated part. |