diff --git a/src/vehicle.h b/src/vehicle.h --- a/src/vehicle.h +++ b/src/vehicle.h @@ -219,7 +219,8 @@ struct Vehicle; DECLARE_OLD_POOL(Vehicle, Vehicle, 9, 125) struct SaveLoad; -extern const SaveLoad *GetVehicleDescription(VehicleType vt); +const SaveLoad *GetVehicleDescription(VehicleType vt); +void AfterLoadVehicles(); struct Vehicle : PoolItem { VehicleTypeByte type; ///< Type of vehicle @@ -227,10 +228,12 @@ struct Vehicle : PoolItemnext = next; } + void SetNext(Vehicle *next); /** * Get the next vehicle of this vehicle. @@ -480,6 +483,19 @@ public: * @return the next vehicle or NULL when there isn't a next vehicle. */ inline Vehicle *Next() const { return this->next; } + + /** + * Get the previous vehicle of this vehicle. + * @note articulated parts are also counted as vehicles. + * @return the previous vehicle or NULL when there isn't a previous vehicle. + */ + inline Vehicle *Previous() const { return this->previous; } + + /** + * Get the first vehicle of this vehicle chain. + * @return the first vehicle of the chain. + */ + inline Vehicle *First() const { return this->first; } }; /** @@ -556,10 +572,7 @@ typedef void *VehicleFromPosProc(Vehicle void VehicleServiceInDepot(Vehicle *v); void VehiclePositionChanged(Vehicle *v); -void AfterLoadVehicles(); Vehicle *GetLastVehicleInChain(Vehicle *v); -Vehicle *GetPrevVehicleInChain(const Vehicle *v); -Vehicle *GetFirstVehicleInChain(const Vehicle *v); uint CountVehiclesInChain(const Vehicle *v); bool IsEngineCountable(const Vehicle *v); void DeleteVehicleChain(Vehicle *v);