summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-10-28 11:51:38 +0000
committertron <tron@openttd.org>2006-10-28 11:51:38 +0000
commit16d8c2fe903bac2c703a774c62015b45720f97b8 (patch)
tree77948ee44c883c50b221db42899cab3cb1ace910
parentf5b45492d33627f8a637d25e86a77d181c9f13c7 (diff)
downloadopenttd-16d8c2fe903bac2c703a774c62015b45720f97b8.tar.xz
(svn r6984) Use the pool macros for the RoadStop pool
-rw-r--r--saveload.c2
-rw-r--r--station.h20
-rw-r--r--station_cmd.c14
3 files changed, 10 insertions, 26 deletions
diff --git a/saveload.c b/saveload.c
index de693d41d..aeb8c5256 100644
--- a/saveload.c
+++ b/saveload.c
@@ -1263,7 +1263,7 @@ static void *IntToReference(uint index, SLRefType rt)
return GetTown(index);
}
case REF_ROADSTOPS: {
- if (!AddBlockIfNeeded(&_roadstop_pool, index))
+ if (!AddBlockIfNeeded(&_RoadStop_pool, index))
error("RoadStops: failed loading savegame: too many RoadStops");
return GetRoadStop(index);
}
diff --git a/station.h b/station.h
index 6edb573d5..c2594f7e8 100644
--- a/station.h
+++ b/station.h
@@ -181,23 +181,7 @@ static inline void DeleteStation(Station *st)
/* 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;
-}
+DECLARE_POOL(RoadStop, RoadStop, 5, 2000)
/**
* Check if a RaodStop really exists.
@@ -215,7 +199,7 @@ static inline void DeleteRoadStop(RoadStop *rs)
rs->used = false;
}
-#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1 < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1) : NULL) if (IsValidRoadStop(rs))
+#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) if (IsValidRoadStop(rs))
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
/* End of stuff for ROADSTOPS */
diff --git a/station_cmd.c b/station_cmd.c
index 3afe1bff3..4860a3c88 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -71,11 +71,11 @@ static void RoadStopPoolNewBlock(uint start_item)
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
* TODO - This is just a temporary stage, this will be removed. */
- for (rs = GetRoadStop(start_item); rs != NULL; rs = (rs->index + 1 < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1) : NULL) rs->index = start_item++;
+ for (rs = GetRoadStop(start_item); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) rs->index = start_item++;
}
DEFINE_POOL(Station, Station, StationPoolNewBlock, StationPoolCleanBlock)
-MemoryPool _roadstop_pool = { "RoadStop", ROADSTOP_POOL_MAX_BLOCKS, ROADSTOP_POOL_BLOCK_SIZE_BITS, sizeof(RoadStop), &RoadStopPoolNewBlock, NULL, 0, 0, NULL };
+DEFINE_POOL(RoadStop, RoadStop, RoadStopPoolNewBlock, NULL)
extern void UpdateAirplanesOnNewStation(Station *st);
@@ -168,7 +168,7 @@ RoadStop *AllocateRoadStop(void)
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
* TODO - This is just a temporary stage, this will be removed. */
- for (rs = GetRoadStop(0); rs != NULL; rs = (rs->index + 1 < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1) : NULL) {
+ for (rs = GetRoadStop(0); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) {
if (!IsValidRoadStop(rs)) {
RoadStopID index = rs->index;
@@ -180,7 +180,7 @@ RoadStop *AllocateRoadStop(void)
}
/* Check if we can add a block to the pool */
- if (AddBlockToPool(&_roadstop_pool)) return AllocateRoadStop();
+ if (AddBlockToPool(&_RoadStop_pool)) return AllocateRoadStop();
return NULL;
}
@@ -2879,8 +2879,8 @@ void InitializeStations(void)
AddBlockToPool(&_Station_pool);
/* Clean the roadstop pool and create 1 block in it */
- CleanPool(&_roadstop_pool);
- AddBlockToPool(&_roadstop_pool);
+ CleanPool(&_RoadStop_pool);
+ AddBlockToPool(&_RoadStop_pool);
_station_tick_ctr = 0;
@@ -3114,7 +3114,7 @@ static void Load_ROADSTOP(void)
while ((index = SlIterateArray()) != -1) {
RoadStop *rs;
- if (!AddBlockIfNeeded(&_roadstop_pool, index))
+ if (!AddBlockIfNeeded(&_RoadStop_pool, index))
error("RoadStops: failed loading savegame: too many RoadStops");
rs = GetRoadStop(index);