223 assert(v->type == VEH_TRAIN); |
223 assert(v->type == VEH_TRAIN); |
224 while (EngineHasArticPart(v)) v = GetNextArticPart(v); |
224 while (EngineHasArticPart(v)) v = GetNextArticPart(v); |
225 return v; |
225 return v; |
226 } |
226 } |
227 |
227 |
|
228 /** Tell if we are dealing with the rear end of a multiheaded engine. |
|
229 * @param v Vehicle. |
|
230 * @return True if the engine is the rear part of a dualheaded engine. |
|
231 */ |
|
232 static inline bool IsRearDualheaded(const Vehicle *v) |
|
233 { |
|
234 assert(v->type == VEH_TRAIN); |
|
235 return (IsMultiheaded(v) && !IsTrainEngine(v)); |
|
236 } |
|
237 |
228 /** Get the next real (non-articulated part) vehicle in the consist. |
238 /** Get the next real (non-articulated part) vehicle in the consist. |
229 * @param v Vehicle. |
239 * @param v Vehicle. |
230 * @return Next vehicle in the consist. |
240 * @return Next vehicle in the consist. |
231 */ |
241 */ |
232 static inline Vehicle *GetNextVehicle(const Vehicle *v) |
242 static inline Vehicle *GetNextVehicle(const Vehicle *v) |
234 assert(v->type == VEH_TRAIN); |
244 assert(v->type == VEH_TRAIN); |
235 while (EngineHasArticPart(v)) v = GetNextArticPart(v); |
245 while (EngineHasArticPart(v)) v = GetNextArticPart(v); |
236 |
246 |
237 /* v now contains the last artic part in the engine */ |
247 /* v now contains the last artic part in the engine */ |
238 return v->Next(); |
248 return v->Next(); |
|
249 } |
|
250 |
|
251 /** Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist. |
|
252 * @param v Vehicle. |
|
253 * @return Next vehicle in the consist. |
|
254 */ |
|
255 static inline Vehicle *GetNextUnit(Vehicle *v) |
|
256 { |
|
257 assert(v->type == VEH_TRAIN); |
|
258 v = GetNextVehicle(v); |
|
259 if (v != NULL && IsRearDualheaded(v)) v = v->Next(); |
|
260 |
|
261 return v; |
239 } |
262 } |
240 |
263 |
241 void ConvertOldMultiheadToNew(); |
264 void ConvertOldMultiheadToNew(); |
242 void ConnectMultiheadedTrains(); |
265 void ConnectMultiheadedTrains(); |
243 uint CountArticulatedParts(EngineID engine_type); |
266 uint CountArticulatedParts(EngineID engine_type); |
271 void UpdateDeltaXY(Direction direction); |
294 void UpdateDeltaXY(Direction direction); |
272 ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; } |
295 ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; } |
273 WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; } |
296 WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; } |
274 void PlayLeaveStationSound() const; |
297 void PlayLeaveStationSound() const; |
275 bool IsPrimaryVehicle() const { return IsFrontEngine(this); } |
298 bool IsPrimaryVehicle() const { return IsFrontEngine(this); } |
276 bool HasFront() const { return true; } |
|
277 int GetImage(Direction direction) const; |
299 int GetImage(Direction direction) const; |
278 int GetDisplaySpeed() const { return this->cur_speed * 10 / 16; } |
300 int GetDisplaySpeed() const { return this->u.rail.last_speed * 10 / 16; } |
279 int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; } |
301 int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; } |
280 Money GetRunningCost() const; |
302 Money GetRunningCost() const; |
281 bool IsInDepot() const { return CheckTrainInDepot(this, false) != -1; } |
303 bool IsInDepot() const { return CheckTrainInDepot(this, false) != -1; } |
282 bool IsStoppedInDepot() const { return CheckTrainStoppedInDepot(this) >= 0; } |
304 bool IsStoppedInDepot() const { return CheckTrainStoppedInDepot(this) >= 0; } |
283 void Tick(); |
305 void Tick(); |