From 3e326085fa69da20e0a81182cbea4466016eb566 Mon Sep 17 00:00:00 2001 From: maedhros Date: Mon, 11 Jun 2007 14:00:16 +0000 Subject: (svn r10097) -Feature: Add support for articulated road vehicles, or callbacks 11 and 17 for road vehicles for those who prefer the technical explanation. --- src/roadveh.h | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'src/roadveh.h') diff --git a/src/roadveh.h b/src/roadveh.h index f3c2f46d8..6547d7442 100644 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -8,6 +8,42 @@ #include "vehicle.h" +enum RoadVehicleSubType { + RVST_FRONT, + RVST_ARTIC_PART, +}; + +static inline bool IsRoadVehFront(const Vehicle *v) +{ + assert(v->type == VEH_ROAD); + return v->subtype == RVST_FRONT; +} + +static inline void SetRoadVehFront(Vehicle *v) +{ + assert(v->type == VEH_ROAD); + v->subtype = RVST_FRONT; +} + +static inline bool IsRoadVehArticPart(const Vehicle *v) +{ + assert(v->type == VEH_ROAD); + return v->subtype == RVST_ARTIC_PART; +} + +static inline void SetRoadVehArticPart(Vehicle *v) +{ + assert(v->type == VEH_ROAD); + v->subtype = RVST_ARTIC_PART; +} + +static inline bool RoadVehHasArticPart(const Vehicle *v) +{ + assert(v->type == VEH_ROAD); + return v->next != NULL && IsRoadVehArticPart(v->next); +} + + static inline bool IsRoadVehInDepot(const Vehicle* v) { assert(v->type == VEH_ROAD); @@ -43,7 +79,12 @@ struct RoadVehicle : public Vehicle { void UpdateDeltaXY(Direction direction); ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; } WindowClass GetVehicleListWindowClass() const { return WC_ROADVEH_LIST; } - bool IsPrimaryVehicle() const { return true; } + bool IsPrimaryVehicle() const { return IsRoadVehFront(this); } + bool HasFront() const { return true; } }; +byte GetRoadVehLength(const Vehicle *v); + +void RoadVehUpdateCache(Vehicle *v); + #endif /* ROADVEH_H */ -- cgit v1.2.3-54-g00ecf