(svn r6986) Use the pool macros for the Town pool

This commit is contained in:
tron
2006-10-28 11:55:29 +00:00
parent 02ae75b380
commit e397b721cd
5 changed files with 12 additions and 34 deletions

20
town.h
View File

@@ -152,7 +152,7 @@ bool CheckforTownRating(uint32 flags, Town *t, byte type);
VARDEF const Town** _town_sort;
extern MemoryPool _town_pool;
DECLARE_POOL(Town, Town, 3, 8000)
/**
* Check if a Town really exists.
@@ -162,22 +162,6 @@ static inline bool IsValidTown(const Town* town)
return town->xy != 0;
}
/**
* Get the pointer to the town with index 'index'
*/
static inline Town *GetTown(uint index)
{
return (Town*)GetItemFromPool(&_town_pool, index);
}
/**
* Get the current size of the TownPool
*/
static inline uint16 GetTownPoolSize(void)
{
return _town_pool.total_items;
}
VARDEF uint _total_towns;
static inline TownID GetTownArraySize(void)
@@ -225,7 +209,7 @@ static inline void DeleteTown(Town *t)
t->xy = 0;
}
#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_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? GetTown(t->index + 1U) : NULL) if (IsValidTown(t))
#define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0)
VARDEF bool _town_sort_dirty;