summaryrefslogtreecommitdiff
path: root/industry.h
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-02-02 17:30:29 +0000
committertruelight <truelight@openttd.org>2005-02-02 17:30:29 +0000
commit83a889d6787dbb5899c8eec663634d36fb1c8108 (patch)
treef37dce29ebc098007022941531aab37cff480e31 /industry.h
parentab3ed5c43121cc8adefc0c6bbcf9ef0d1203d3ff (diff)
downloadopenttd-83a889d6787dbb5899c8eec663634d36fb1c8108.tar.xz
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
1kx1k maps should now be much faster, and give more than just oil-stuff ;)
Diffstat (limited to 'industry.h')
-rw-r--r--industry.h30
1 files changed, 21 insertions, 9 deletions
diff --git a/industry.h b/industry.h
index daca10888..7fac15f28 100644
--- a/industry.h
+++ b/industry.h
@@ -1,6 +1,8 @@
#ifndef INDUSTRY_H
#define INDUSTRY_H
+#include "pool.h"
+
struct Industry {
TileIndex xy;
byte width; /* swapped order of w/h with town */
@@ -27,22 +29,32 @@ struct Industry {
uint16 index;
};
-VARDEF int _total_industries; // For the AI: the amount of industries active
-
-VARDEF Industry _industries[250];
-VARDEF uint _industries_size;
-
-VARDEF uint16 *_industry_sort;
+extern MemoryPool _industry_pool;
+/**
+ * Get the pointer to the industry with index 'index'
+ */
static inline Industry *GetIndustry(uint index)
{
- assert(index < _industries_size);
- return &_industries[index];
+ return (Industry*)GetItemFromPool(&_industry_pool, index);
+}
+
+/**
+ * Get the current size of the IndustryPool
+ */
+static inline uint16 GetIndustryPoolSize(void)
+{
+ return _industry_pool.total_items;
}
-#define FOR_ALL_INDUSTRIES(i) for(i = _industries; i != &_industries[_industries_size]; i++)
+#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1 < GetIndustryPoolSize()) ? GetIndustry(i->index + 1) : NULL)
+#define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0)
+
+VARDEF int _total_industries; // For the AI: the amount of industries active
+VARDEF uint16 *_industry_sort;
VARDEF bool _industry_sort_dirty;
+
void DeleteIndustry(Industry *is);
enum {