(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.
This commit is contained in:
truelight
2006-08-22 20:41:26 +00:00
parent 2e0d16026b
commit 5fd9aeb12b
18 changed files with 94 additions and 34 deletions

14
town.h
View File

@@ -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;