From 77eaefb61c9d1cbd4e6347e3fc042565a5b7572e Mon Sep 17 00:00:00 2001 From: smatz Date: Thu, 2 Jul 2009 00:17:27 +0000 Subject: (svn r16720) -Codechange: make Set/ClearFrontEngine(), Set/ClearArticulatedPart(), Set/ClearWagon(), Set/ClearEngine(), Set/ClearFreeWagon() and Set/ClearMultiheaded() members of Train --- src/train.h | 171 ++++++++++++++++++++++-------------------------------------- 1 file changed, 63 insertions(+), 108 deletions(-) (limited to 'src/train.h') diff --git a/src/train.h b/src/train.h index ef4b06167..4476bb7ff 100644 --- a/src/train.h +++ b/src/train.h @@ -51,114 +51,6 @@ enum TrainSubtype { TS_MULTIHEADED = 5, ///< Engine is a multiheaded }; -/** Set front engine state - * @param v vehicle to change - */ -static inline void SetFrontEngine(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - SetBit(v->subtype, TS_FRONT); -} - -/** Remove the front engine state - * @param v vehicle to change - */ -static inline void ClearFrontEngine(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - ClrBit(v->subtype, TS_FRONT); -} - -/** Set a vehicle to be an articulated part - * @param v vehicle to change - */ -static inline void SetArticulatedPart(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - SetBit(v->subtype, TS_ARTICULATED_PART); -} - -/** Clear a vehicle from being an articulated part - * @param v vehicle to change - */ -static inline void ClearArticulatedPart(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - ClrBit(v->subtype, TS_ARTICULATED_PART); -} - -/** Set a vehicle to be a wagon - * @param v vehicle to change - */ -static inline void SetTrainWagon(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - SetBit(v->subtype, TS_WAGON); -} - -/** Clear wagon property - * @param v vehicle to change - */ -static inline void ClearTrainWagon(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - ClrBit(v->subtype, TS_WAGON); -} - -/** Set engine status - * @param v vehicle to change - */ -static inline void SetTrainEngine(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - SetBit(v->subtype, TS_ENGINE); -} - -/** Clear engine status - * @param v vehicle to change - */ -static inline void ClearTrainEngine(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - ClrBit(v->subtype, TS_ENGINE); -} - -/** Set if a vehicle is a free wagon - * @param v vehicle to change - */ -static inline void SetFreeWagon(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - SetBit(v->subtype, TS_FREE_WAGON); -} - -/** Clear a vehicle from being a free wagon - * @param v vehicle to change - */ -static inline void ClearFreeWagon(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - ClrBit(v->subtype, TS_FREE_WAGON); -} - - -/** Set if a vehicle is a multiheaded engine - * @param v vehicle to change - */ -static inline void SetMultiheaded(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - SetBit(v->subtype, TS_MULTIHEADED); -} - -/** Clear multiheaded engine property - * @param v vehicle to change - */ -static inline void ClearMultiheaded(Vehicle *v) -{ - assert(v->type == VEH_TRAIN); - ClrBit(v->subtype, TS_MULTIHEADED); -} void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2); void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2); @@ -257,6 +149,69 @@ struct Train : public SpecializedVehicle { TileIndex GetOrderStationLocation(StationID station); bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse); + /** + * Set front engine state + */ + FORCEINLINE void SetFrontEngine() { SetBit(this->subtype, TS_FRONT); } + + /** + * Remove the front engine state + */ + FORCEINLINE void ClearFrontEngine() { ClrBit(this->subtype, TS_FRONT); } + + /** + * Set a vehicle to be an articulated part + */ + FORCEINLINE void SetArticulatedPart() { SetBit(this->subtype, TS_ARTICULATED_PART); } + + /** + * Clear a vehicle from being an articulated part + */ + FORCEINLINE void ClearArticulatedPart() { ClrBit(this->subtype, TS_ARTICULATED_PART); } + + /** + * Set a vehicle to be a wagon + */ + FORCEINLINE void SetWagon() { SetBit(this->subtype, TS_WAGON); } + + /** + * Clear wagon property + */ + FORCEINLINE void ClearWagon() { ClrBit(this->subtype, TS_WAGON); } + + /** + * Set engine status + * @param v vehicle to change + */ + FORCEINLINE void SetEngine() { SetBit(this->subtype, TS_ENGINE); } + + /** + * Clear engine status + */ + FORCEINLINE void ClearEngine() { ClrBit(this->subtype, TS_ENGINE); } + + /** + * Set if a vehicle is a free wagon + */ + FORCEINLINE void SetFreeWagon() { SetBit(this->subtype, TS_FREE_WAGON); } + + /** + * Clear a vehicle from being a free wagon + * @param v vehicle to change + */ + FORCEINLINE void ClearFreeWagon() { ClrBit(this->subtype, TS_FREE_WAGON); } + + /** + * Set if a vehicle is a multiheaded engine + */ + FORCEINLINE void SetMultiheaded() { SetBit(this->subtype, TS_MULTIHEADED); } + + /** + * Clear multiheaded engine property + */ + FORCEINLINE void ClearMultiheaded() { ClrBit(this->subtype, TS_MULTIHEADED); } + + /** * Check if train is a front engine * @return Returns true if train is a front engine -- cgit v1.2.3-54-g00ecf