From 5fd9aeb12b75a3971e86e5b7d1701115f57fbc12 Mon Sep 17 00:00:00 2001 From: truelight Date: Tue, 22 Aug 2006 20:41:26 +0000 Subject: (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that). It isn't the best name, but we couldn't find any better. This unifies the pool-system even more. --- town.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'town.h') diff --git a/town.h b/town.h index 4bccadb1b..122a373dc 100644 --- a/town.h +++ b/town.h @@ -179,6 +179,18 @@ static inline uint16 GetTownPoolSize(void) return _town_pool.total_items; } +VARDEF uint _total_towns; + +static inline TownID GetTownArraySize(void) +{ + /* TODO - This isn't the real content of the function, but + * with the new pool-system this will be replaced with one that + * _really_ returns the highest index + 1. Now it just returns + * the next safe value we are sure about everything is below. + */ + return _total_towns + 1; +} + static inline bool IsValidTownID(uint index) { return index < GetTownPoolSize() && IsValidTown(GetTown(index)); @@ -187,8 +199,6 @@ static inline bool IsValidTownID(uint index) #define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1 < GetTownPoolSize()) ? GetTown(t->index + 1) : NULL) if (IsValidTown(t)) #define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0) -VARDEF uint _total_towns; // For the AI: the amount of towns active - VARDEF bool _town_sort_dirty; VARDEF byte _town_sort_order; -- cgit v1.2.3-54-g00ecf