diff options
author | truelight <truelight@openttd.org> | 2005-02-04 15:31:30 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-02-04 15:31:30 +0000 |
commit | 10adda0d739203e0933d89d5c7d3bcb10b67fe51 (patch) | |
tree | cafae3f0441df07e0ca55f81e311d585b1fe5df2 /station.h | |
parent | 4f5255c36eb39744a0fb0ceda0364ff8d4d3524f (diff) | |
download | openttd-10adda0d739203e0933d89d5c7d3bcb10b67fe51.tar.xz |
(svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
Diffstat (limited to 'station.h')
-rw-r--r-- | station.h | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -125,9 +125,6 @@ TileIndex GetStationTileForVehicle(const Vehicle *v, const Station *st); void ShowStationViewWindow(int station); void UpdateAllStationVirtCoord(void); -VARDEF RoadStop _roadstops[NUM_ROAD_STOPS * 2]; -VARDEF uint _roadstops_size; - VARDEF SortStruct *_station_sort; extern MemoryPool _station_pool; @@ -151,6 +148,33 @@ static inline uint16 GetStationPoolSize(void) #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) + +/* Stuff for ROADSTOPS */ + +extern MemoryPool _roadstop_pool; + +/** + * Get the pointer to the roadstop with index 'index' + */ +static inline RoadStop *GetRoadStop(uint index) +{ + return (RoadStop*)GetItemFromPool(&_roadstop_pool, index); +} + +/** + * Get the current size of the RoadStoptPool + */ +static inline uint16 GetRoadStopPoolSize(void) +{ + return _roadstop_pool.total_items; +} + +#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1 < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1) : NULL) +#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0) + +/* End of stuff for ROADSTOPS */ + + VARDEF bool _station_sort_dirty[MAX_PLAYERS]; VARDEF bool _global_station_sort_dirty; @@ -238,7 +262,7 @@ RoadStop * GetRoadStopByTile(TileIndex tile, RoadStopType type); inline int GetRoadStopType(TileIndex tile); uint GetNumRoadStops(const Station *st, RoadStopType type); RoadStop * GetPrimaryRoadStop(const Station *st, RoadStopType type); -RoadStop * GetFirstFreeRoadStop( void ); +RoadStop * AllocateRoadStop( void ); static inline bool IsTrainStationTile(uint tile) { return IsTileType(tile, MP_STATION) && IS_BYTE_INSIDE(_map5[tile], 0, 8); |