diff options
author | truelight <truelight@openttd.org> | 2005-02-03 17:22:35 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-02-03 17:22:35 +0000 |
commit | 1938a73c90db32244162a927e51c1903fed779f9 (patch) | |
tree | be17b2ce20037210425d4757c66ffc50cccc6d77 /station.h | |
parent | f1d4a85f5989e65998c326864fa59dadf9065e47 (diff) | |
download | openttd-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.h | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -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; |