summaryrefslogtreecommitdiff
path: root/src/depot_base.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-17 19:10:30 +0000
committerrubidium <rubidium@openttd.org>2008-04-17 19:10:30 +0000
commit02cdf01507be4ca5d77915cd00298929ad2f7f30 (patch)
treeabfdacfc810cdcd10d4095670b1713ad27c912e4 /src/depot_base.h
parent059e94e355c9172a42b70ff20b4b8a87dd4889ae (diff)
downloadopenttd-02cdf01507be4ca5d77915cd00298929ad2f7f30.tar.xz
(svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
Diffstat (limited to 'src/depot_base.h')
-rw-r--r--src/depot_base.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/depot_base.h b/src/depot_base.h
new file mode 100644
index 000000000..e1c9e2168
--- /dev/null
+++ b/src/depot_base.h
@@ -0,0 +1,35 @@
+/* $Id$ */
+
+/** @file depot.h Base for all depots (except hangars) */
+
+#ifndef DEPOT_BASE_H
+#define DEPOT_BASE_H
+
+#include "tile_type.h"
+#include "depot_type.h"
+#include "oldpool.h"
+#include "town_type.h"
+
+DECLARE_OLD_POOL(Depot, Depot, 3, 8000)
+
+struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
+ TileIndex xy;
+ TownID town_index;
+
+ Depot(TileIndex xy = 0) : xy(xy) {}
+ ~Depot();
+
+ inline bool IsValid() const { return this->xy != 0; }
+};
+
+static inline bool IsValidDepotID(DepotID index)
+{
+ return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
+}
+
+Depot *GetDepotByTile(TileIndex tile);
+
+#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
+#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
+
+#endif /* DEPOT_BASE_H */