245 |
245 |
246 /* v now contains the last artic part in the engine */ |
246 /* v now contains the last artic part in the engine */ |
247 return v->Next(); |
247 return v->Next(); |
248 } |
248 } |
249 |
249 |
|
250 /** Get the previous real (non-articulated part) vehicle in the consist. |
|
251 * @param w Vehicle. |
|
252 * @return Previous vehicle in the consist. |
|
253 */ |
|
254 static inline Vehicle *GetPrevVehicle(const Vehicle *w) |
|
255 { |
|
256 assert(w->type == VEH_TRAIN); |
|
257 |
|
258 Vehicle *v = w->Previous(); |
|
259 while (v != NULL && IsArticulatedPart(v)) v = v->Previous(); |
|
260 |
|
261 return v; |
|
262 } |
|
263 |
250 /** Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist. |
264 /** Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist. |
251 * @param v Vehicle. |
265 * @param v Vehicle. |
252 * @return Next vehicle in the consist. |
266 * @return Next vehicle in the consist. |
253 */ |
267 */ |
254 static inline Vehicle *GetNextUnit(Vehicle *v) |
268 static inline Vehicle *GetNextUnit(Vehicle *v) |
255 { |
269 { |
256 assert(v->type == VEH_TRAIN); |
270 assert(v->type == VEH_TRAIN); |
257 v = GetNextVehicle(v); |
271 v = GetNextVehicle(v); |
258 if (v != NULL && IsRearDualheaded(v)) v = GetNextVehicle(v); |
272 if (v != NULL && IsRearDualheaded(v)) v = GetNextVehicle(v); |
|
273 |
|
274 return v; |
|
275 } |
|
276 |
|
277 /** Get the previous real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist. |
|
278 * @param v Vehicle. |
|
279 * @return Previous vehicle in the consist. |
|
280 */ |
|
281 static inline Vehicle *GetPrevUnit(Vehicle *v) |
|
282 { |
|
283 assert(v->type == VEH_TRAIN); |
|
284 v = GetPrevVehicle(v); |
|
285 if (v != NULL && IsRearDualheaded(v)) v = GetPrevVehicle(v); |
259 |
286 |
260 return v; |
287 return v; |
261 } |
288 } |
262 |
289 |
263 void ConvertOldMultiheadToNew(); |
290 void ConvertOldMultiheadToNew(); |