diff options
author | rubidium <rubidium@openttd.org> | 2007-08-02 22:32:47 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-08-02 22:32:47 +0000 |
commit | 5016f5497ccacd0837d37d5099433b3d7728838b (patch) | |
tree | 8f1dd8ff82a55b059fa648e4164794c687df1b47 /src/engine.h | |
parent | b15c0efaa951425d74e8a9ca4104da72a81fe50c (diff) | |
download | openttd-5016f5497ccacd0837d37d5099433b3d7728838b.tar.xz |
(svn r10757) -Codechange: make the engine renew struct use the pool item class as super class.
Diffstat (limited to 'src/engine.h')
-rw-r--r-- | src/engine.h | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/engine.h b/src/engine.h index cd238b8a6..6ee7d18c4 100644 --- a/src/engine.h +++ b/src/engine.h @@ -262,40 +262,32 @@ static inline const RoadVehicleInfo* RoadVehInfo(EngineID e) * Engine Replacement stuff ************************************************************************/ +struct EngineRenew; /** - * Struct to store engine replacements. DO NOT USE outside of engine.c. Is + * 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 * it. */ -struct EngineRenew { - EngineRenewID index; - EngineID from; - EngineID to; - EngineRenew *next; - GroupID group_id; -}; +DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000) /** - * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is + * 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. */ -DECLARE_OLD_POOL(EngineRenew, EngineRenew, 3, 8000) +struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> { + EngineID from; + EngineID to; + EngineRenew *next; + GroupID group_id; -/** - * Check if a EngineRenew really exists. - */ -static inline bool IsValidEngineRenew(const EngineRenew *er) -{ - return er->from != INVALID_ENGINE; -} + EngineRenew(EngineID from = INVALID_ENGINE, EngineID to = INVALID_ENGINE) : from(from), to(to), next(NULL) {} + ~EngineRenew() { this->from = INVALID_ENGINE; } -static inline void DeleteEngineRenew(EngineRenew *er) -{ - er->from = INVALID_ENGINE; -} + 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->from != INVALID_ENGINE) if (IsValidEngineRenew(er)) +#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) |