10
10
#include "vehicle_base.h"
14
* enum to handle train subtypes
13
/** enum to handle train subtypes
15
14
* Do not access it directly unless you have to. Use the access functions below
16
15
* This is an enum to tell what bit to access as it is a bitmask
19
17
enum TrainSubtype {
20
18
TS_FRONT = 0, ///< Leading engine of a train
21
19
TS_ARTICULATED_PART = 1, ///< Articulated part of an engine
249
247
return v->Next();
250
/** Get the previous real (non-articulated part) vehicle in the consist.
252
* @return Previous vehicle in the consist.
254
static inline Vehicle *GetPrevVehicle(const Vehicle *w)
256
assert(w->type == VEH_TRAIN);
258
Vehicle *v = w->Previous();
259
while (v != NULL && IsArticulatedPart(v)) v = v->Previous();
252
264
/** Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist.
253
265
* @param v Vehicle.
254
266
* @return Next vehicle in the consist.
256
static inline Vehicle *GetNextUnit(Vehicle *v)
258
assert(v->type == VEH_TRAIN);
259
v = GetNextVehicle(v);
260
if (v != NULL && IsRearDualheaded(v)) v = v->Next();
265
void ConvertOldMultiheadToNew();
266
void ConnectMultiheadedTrains();
267
uint CountArticulatedParts(EngineID engine_type);
269
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped);
268
static inline Vehicle *GetNextUnit(const Vehicle *v)
270
assert(v->type == VEH_TRAIN);
271
Vehicle *w = GetNextVehicle(v);
272
if (w != NULL && IsRearDualheaded(w)) w = GetNextVehicle(w);
277
/** Get the previous real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist.
279
* @return Previous vehicle in the consist.
281
static inline Vehicle *GetPrevUnit(const Vehicle *v)
283
assert(v->type == VEH_TRAIN);
284
Vehicle *w = GetPrevVehicle(v);
285
if (w != NULL && IsRearDualheaded(w)) w = GetPrevVehicle(w);
270
290
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2);
271
291
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2);
275
295
int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped);
276
296
int CheckTrainStoppedInDepot(const Vehicle *v);
277
void UpdateTrainAcceleration(Vehicle* v);
297
void UpdateTrainAcceleration(Vehicle *v);
278
298
void CheckTrainsLengths();
300
void FreeTrainTrackReservation(const Vehicle *v, TileIndex origin = INVALID_TILE, Trackdir orig_td = INVALID_TRACKDIR);
301
bool TryPathReserve(Vehicle *v, bool mark_as_stuck = false, bool first_tile_okay = false);
281
304
* This class 'wraps' Vehicle; you do not actually instantiate this class.
282
305
* You create a Vehicle using AllocateVehicle, so it is added to the pool
296
319
void MarkDirty();
297
320
void UpdateDeltaXY(Direction direction);
298
321
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
299
WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; }
300
322
void PlayLeaveStationSound() const;
301
323
bool IsPrimaryVehicle() const { return IsFrontEngine(this); }
302
int GetImage(Direction direction) const;
303
int GetDisplaySpeed() const { return this->u.rail.last_speed * 10 / 16; }
304
int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed * 10 / 16; }
324
SpriteID GetImage(Direction direction) const;
325
int GetDisplaySpeed() const { return this->u.rail.last_speed; }
326
int GetDisplayMaxSpeed() const { return this->u.rail.cached_max_speed; }
305
327
Money GetRunningCost() const;
306
328
bool IsInDepot() const { return CheckTrainInDepot(this, false) != -1; }
307
329
bool IsStoppedInDepot() const { return CheckTrainStoppedInDepot(this) >= 0; }
332
TileIndex GetOrderStationLocation(StationID station);
333
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
312
336
#endif /* TRAIN_H */