summaryrefslogtreecommitdiff
path: root/station.h
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-02-03 17:22:35 +0000
committertruelight <truelight@openttd.org>2005-02-03 17:22:35 +0000
commit1938a73c90db32244162a927e51c1903fed779f9 (patch)
treebe17b2ce20037210425d4757c66ffc50cccc6d77 /station.h
parentf1d4a85f5989e65998c326864fa59dadf9065e47 (diff)
downloadopenttd-1938a73c90db32244162a927e51c1903fed779f9.tar.xz
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
Diffstat (limited to 'station.h')
-rw-r--r--station.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/station.h b/station.h
index 7202099c6..2334be6e2 100644
--- a/station.h
+++ b/station.h
@@ -1,6 +1,7 @@
#ifndef STATION_H
#define STATION_H
+#include "pool.h"
#include "sprite.h"
#include "tile.h"
#include "vehicle.h"
@@ -125,19 +126,30 @@ void ShowStationViewWindow(int station);
void UpdateAllStationVirtCoord(void);
VARDEF RoadStop _roadstops[NUM_ROAD_STOPS * 2];
-VARDEF Station _stations[250];
VARDEF uint _roadstops_size;
-VARDEF uint _stations_size;
VARDEF SortStruct *_station_sort;
+extern MemoryPool _station_pool;
+
+/**
+ * Get the pointer to the station with index 'index'
+ */
static inline Station *GetStation(uint index)
{
- assert(index < _stations_size);
- return &_stations[index];
+ return (Station*)GetItemFromPool(&_station_pool, index);
+}
+
+/**
+ * Get the current size of the StationPool
+ */
+static inline uint16 GetStationPoolSize(void)
+{
+ return _station_pool.total_items;
}
-#define FOR_ALL_STATIONS(st) for(st = _stations; st != &_stations[_stations_size]; st++)
+#define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1 < GetStationPoolSize()) ? GetStation(st->index + 1) : NULL)
+#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0)
VARDEF bool _station_sort_dirty[MAX_PLAYERS];
VARDEF bool _global_station_sort_dirty;