(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
-Codechange: use IsValidXXX where ever possible Note: both changes to prepare for new pool system, which needs those changes. For every pool there are 2 ugly lines, which will be removed when done implementing new pool system. Based on FS#13 by blathijs, partly implemented.
This commit is contained in:
4
town.h
4
town.h
@@ -160,7 +160,7 @@ extern MemoryPool _town_pool;
|
||||
*/
|
||||
static inline bool IsValidTown(const Town* town)
|
||||
{
|
||||
return town->xy != 0; /* XXX: Replace by INVALID_TILE someday */
|
||||
return town->xy != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +184,7 @@ static inline bool IsTownIndex(uint index)
|
||||
return index < GetTownPoolSize();
|
||||
}
|
||||
|
||||
#define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1 < GetTownPoolSize()) ? GetTown(t->index + 1) : NULL)
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user