summaryrefslogtreecommitdiff
path: root/engine.h
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-08-22 16:22:07 +0000
committertruelight <truelight@openttd.org>2006-08-22 16:22:07 +0000
commitc0f352670ac91977145a3a9df44e5cabfb9c49b6 (patch)
tree5ded094cc8b54037f0c938fc2c0e2c7efe4b07c9 /engine.h
parenta4d7fa19c7164d2cc7b8d9cc975cc5463f5de694 (diff)
downloadopenttd-c0f352670ac91977145a3a9df44e5cabfb9c49b6.tar.xz
(svn r6049) -Codechange: forgot EngineRenew in r6047
-Codechange: cleaned up the EngineRenew code a bit (coding style mostly) -Codechange: forgot the correct comment in station_cmd -Codechange: move pool-stuff to engine.h, like we always do
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.