diff -r 31fcaa5375a1 -r e72987579514 src/engine.h --- a/src/engine.h Fri Aug 03 19:16:36 2007 +0000 +++ b/src/engine.h Fri Aug 03 22:09:42 2007 +0000 @@ -45,7 +45,7 @@ // kind of visual effect to generate for a vehicle (default, steam, diesel, electric). // Same goes for the callback result, which atm is only used to check if a wagon is powered. byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor - byte tractive_effort; ///< Tractive effort coefficient + byte tractive_effort; ///< Tractive effort coefficient byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles }; @@ -262,19 +262,7 @@ * Engine Replacement stuff ************************************************************************/ -/** - * Struct to store engine replacements. DO NOT USE outside of engine.c. Is - * placed here so the only exception to this rule, the saveload code, can use - * it. - */ -struct EngineRenew { - EngineRenewID index; - EngineID from; - EngineID to; - EngineRenew *next; - GroupID group_id; -}; - +struct EngineRenew; /** * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is * placed here so the only exception to this rule, the saveload code, can use @@ -283,19 +271,23 @@ DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000) /** - * Check if a EngineRenew really exists. + * Struct to store engine replacements. DO NOT USE outside of engine.c. Is + * placed here so the only exception to this rule, the saveload code, can use + * it. */ -static inline bool IsValidEngineRenew(const EngineRenew *er) -{ - return er->from != INVALID_ENGINE; -} +struct EngineRenew : PoolItem { + EngineID from; + EngineID to; + EngineRenew *next; + GroupID group_id; -static inline void DeleteEngineRenew(EngineRenew *er) -{ - er->from = INVALID_ENGINE; -} + EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {} + ~EngineRenew() { this->from = INVALID_ENGINE; } -#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->from != INVALID_ENGINE) if (IsValidEngineRenew(er)) + bool IsValid() const { return this->from != INVALID_ENGINE; } +}; + +#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->IsValid()) #define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0) @@ -309,7 +301,7 @@ * @param erl The renewlist for a given player. * @return The new renewlist for the player. */ -void RemoveAllEngineReplacement(EngineRenewList* erl); +void RemoveAllEngineReplacement(EngineRenewList *erl); /** * Retrieve the engine replacement in a given renewlist for an original engine type. @@ -328,7 +320,7 @@ * @param flags The calling command flags. * @return 0 on success, CMD_ERROR on failure. */ -CommandCost AddEngineReplacement(EngineRenewList* erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags); +CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags); /** * Remove an engine replacement from a given renewlist. @@ -337,7 +329,7 @@ * @param flags The calling command flags. * @return 0 on success, CMD_ERROR on failure. */ -CommandCost RemoveEngineReplacement(EngineRenewList* erl, EngineID engine, GroupID group, uint32 flags); +CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags); /** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists * @param type The type of engine