diff --git a/src/ground_vehicle.hpp b/src/ground_vehicle.hpp --- a/src/ground_vehicle.hpp +++ b/src/ground_vehicle.hpp @@ -149,6 +149,19 @@ struct GroundVehicle : public Specialize this->UpdateViewport(true, turned); return old_z; } + + /** + * Enum to handle ground vehicle subtypes. + * Do not access it directly unless you have to. Use the subtype access functions. + */ + enum GroundVehicleSubtypeFlags { + GVSF_FRONT = 0, ///< Leading engine of a consist. + GVSF_ARTICULATED_PART = 1, ///< Articulated part of an engine. + GVSF_WAGON = 2, ///< Wagon (not used for road vehicles). + GVSF_ENGINE = 3, ///< Engine that can be front engine, but might be placed behind another engine (not used for road vehicles). + GVSF_FREE_WAGON = 4, ///< First in a wagon chain (in depot) (not used for road vehicles). + GVSF_MULTIHEADED = 5, ///< Engine is multiheaded (not used for road vehicles). + }; }; #endif /* GROUND_VEHICLE_HPP */ diff --git a/src/train.h b/src/train.h --- a/src/train.h +++ b/src/train.h @@ -138,109 +138,95 @@ struct Train : public GroundVehiclesubtype, TS_FRONT); } + FORCEINLINE void SetFrontEngine() { SetBit(this->subtype, GVSF_FRONT); } /** * Remove the front engine state */ - FORCEINLINE void ClearFrontEngine() { ClrBit(this->subtype, TS_FRONT); } + FORCEINLINE void ClearFrontEngine() { ClrBit(this->subtype, GVSF_FRONT); } /** * Set a vehicle to be an articulated part */ - FORCEINLINE void SetArticulatedPart() { SetBit(this->subtype, TS_ARTICULATED_PART); } + FORCEINLINE void SetArticulatedPart() { SetBit(this->subtype, GVSF_ARTICULATED_PART); } /** * Clear a vehicle from being an articulated part */ - FORCEINLINE void ClearArticulatedPart() { ClrBit(this->subtype, TS_ARTICULATED_PART); } + FORCEINLINE void ClearArticulatedPart() { ClrBit(this->subtype, GVSF_ARTICULATED_PART); } /** * Set a vehicle to be a wagon */ - FORCEINLINE void SetWagon() { SetBit(this->subtype, TS_WAGON); } + FORCEINLINE void SetWagon() { SetBit(this->subtype, GVSF_WAGON); } /** * Clear wagon property */ - FORCEINLINE void ClearWagon() { ClrBit(this->subtype, TS_WAGON); } + FORCEINLINE void ClearWagon() { ClrBit(this->subtype, GVSF_WAGON); } /** * Set engine status */ - FORCEINLINE void SetEngine() { SetBit(this->subtype, TS_ENGINE); } + FORCEINLINE void SetEngine() { SetBit(this->subtype, GVSF_ENGINE); } /** * Clear engine status */ - FORCEINLINE void ClearEngine() { ClrBit(this->subtype, TS_ENGINE); } + FORCEINLINE void ClearEngine() { ClrBit(this->subtype, GVSF_ENGINE); } /** * Set if a vehicle is a free wagon */ - FORCEINLINE void SetFreeWagon() { SetBit(this->subtype, TS_FREE_WAGON); } + FORCEINLINE void SetFreeWagon() { SetBit(this->subtype, GVSF_FREE_WAGON); } /** * Clear a vehicle from being a free wagon */ - FORCEINLINE void ClearFreeWagon() { ClrBit(this->subtype, TS_FREE_WAGON); } + FORCEINLINE void ClearFreeWagon() { ClrBit(this->subtype, GVSF_FREE_WAGON); } /** * Set if a vehicle is a multiheaded engine */ - FORCEINLINE void SetMultiheaded() { SetBit(this->subtype, TS_MULTIHEADED); } + FORCEINLINE void SetMultiheaded() { SetBit(this->subtype, GVSF_MULTIHEADED); } /** * Clear multiheaded engine property */ - FORCEINLINE void ClearMultiheaded() { ClrBit(this->subtype, TS_MULTIHEADED); } + FORCEINLINE void ClearMultiheaded() { ClrBit(this->subtype, GVSF_MULTIHEADED); } /** * Check if train is a front engine * @return Returns true if train is a front engine */ - FORCEINLINE bool IsFrontEngine() const { return HasBit(this->subtype, TS_FRONT); } + FORCEINLINE bool IsFrontEngine() const { return HasBit(this->subtype, GVSF_FRONT); } /** * Check if train is a free wagon (got no engine in front of it) * @return Returns true if train is a free wagon */ - FORCEINLINE bool IsFreeWagon() const { return HasBit(this->subtype, TS_FREE_WAGON); } + FORCEINLINE bool IsFreeWagon() const { return HasBit(this->subtype, GVSF_FREE_WAGON); } /** * Check if a vehicle is an engine (can be first in a train) * @return Returns true if vehicle is an engine */ - FORCEINLINE bool IsEngine() const { return HasBit(this->subtype, TS_ENGINE); } + FORCEINLINE bool IsEngine() const { return HasBit(this->subtype, GVSF_ENGINE); } /** * Check if a train is a wagon * @return Returns true if vehicle is a wagon */ - FORCEINLINE bool IsWagon() const { return HasBit(this->subtype, TS_WAGON); } + FORCEINLINE bool IsWagon() const { return HasBit(this->subtype, GVSF_WAGON); } /** * Check if train is a multiheaded engine * @return Returns true if vehicle is a multiheaded engine */ - FORCEINLINE bool IsMultiheaded() const { return HasBit(this->subtype, TS_MULTIHEADED); } + FORCEINLINE bool IsMultiheaded() const { return HasBit(this->subtype, GVSF_MULTIHEADED); } /** * Tell if we are dealing with the rear end of a multiheaded engine. @@ -252,7 +238,7 @@ struct Train : public GroundVehiclesubtype, TS_ARTICULATED_PART); } + FORCEINLINE bool IsArticulatedPart() const { return HasBit(this->subtype, GVSF_ARTICULATED_PART); } /** * Check if an engine has an articulated part.