summaryrefslogtreecommitdiff
path: root/src/depot.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-02 22:33:53 +0000
committerrubidium <rubidium@openttd.org>2007-08-02 22:33:53 +0000
commit549450d31a4676039e2663e66e23e2f5bae3f7f1 (patch)
tree04f6cea517d07342aa29326257419e2460c68a49 /src/depot.h
parent5016f5497ccacd0837d37d5099433b3d7728838b (diff)
downloadopenttd-549450d31a4676039e2663e66e23e2f5bae3f7f1.tar.xz
(svn r10758) -Codechange: make the depot struct use the pool item class as super class.
Diffstat (limited to 'src/depot.h')
-rw-r--r--src/depot.h34
1 files changed, 11 insertions, 23 deletions
diff --git a/src/depot.h b/src/depot.h
index 17e951358..1b3de1b86 100644
--- a/src/depot.h
+++ b/src/depot.h
@@ -13,38 +13,27 @@
#include "rail_map.h"
#include "water_map.h"
-struct Depot {
- TileIndex xy;
- TownID town_index;
- DepotID index;
-};
-
+struct Depot;
DECLARE_OLD_POOL(Depot, Depot, 3, 8000)
-/**
- * Check if a depot really exists.
- */
-static inline bool IsValidDepot(const Depot *depot)
-{
- return depot != NULL && depot->xy != 0;
-}
+struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
+ TileIndex xy;
+ TownID town_index;
-static inline bool IsValidDepotID(uint index)
-{
- return index < GetDepotPoolSize() && IsValidDepot(GetDepot(index));
-}
+ Depot(TileIndex xy = 0) : xy(xy) {}
+ ~Depot();
-void DestroyDepot(Depot *depot);
+ bool IsValid() const { return this->xy != 0; }
+};
-static inline void DeleteDepot(Depot *depot)
+static inline bool IsValidDepotID(DepotID index)
{
- DestroyDepot(depot);
- depot->xy = 0;
+ return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
}
void ShowDepotWindow(TileIndex tile, VehicleType type);
-#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (IsValidDepot(d))
+#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)
#define MIN_SERVINT_PERCENT 5
@@ -108,7 +97,6 @@ static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
Depot *GetDepotByTile(TileIndex tile);
void InitializeDepots();
-Depot *AllocateDepot();
void DeleteDepotHighlightOfVehicle(const Vehicle *v);