summaryrefslogtreecommitdiff
path: root/engine.h
diff options
context:
space:
mode:
Diffstat (limited to 'engine.h')
-rw-r--r--engine.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/engine.h b/engine.h
index f82ca90c5..42131b368 100644
--- a/engine.h
+++ b/engine.h
@@ -224,7 +224,7 @@ static inline const RoadVehicleInfo* RoadVehInfo(EngineID e)
* it.
*/
struct EngineRenew {
- uint16 index;
+ EngineRenewID index;
EngineID from;
EngineID to;
struct EngineRenew *next;
@@ -240,6 +240,25 @@ typedef struct EngineRenew EngineRenew;
extern MemoryPool _engine_renew_pool;
/**
+ * Get the current size of the EngineRenewPool
+ */
+static inline uint16 GetEngineRenewPoolSize(void)
+{
+ return _engine_renew_pool.total_items;
+}
+
+/**
+ * Check if a EngineRenew really exists.
+ */
+static inline bool IsValidEngineRenew(const EngineRenew *er)
+{
+ return er->from != INVALID_ENGINE;
+}
+
+#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1 < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1) : NULL) if (er->from != INVALID_ENGINE) if (IsValidEngineRenew(er))
+#define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0)
+
+/**
* DO NOT USE outside of engine.c. Is
* placed here so the only exception to this rule, the saveload code, can use
* it.