summaryrefslogtreecommitdiff
path: root/src/engine.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-02 22:32:47 +0000
committerrubidium <rubidium@openttd.org>2007-08-02 22:32:47 +0000
commitc1d167ae14e810e6820a0b98635ede09027a0947 (patch)
tree8f1dd8ff82a55b059fa648e4164794c687df1b47 /src/engine.h
parent99da45988a70436692c5062e50b4239e4d948f66 (diff)
downloadopenttd-c1d167ae14e810e6820a0b98635ede09027a0947.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.h36
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)