(svn r6149) -Codechange: DeleteTown removes a town from the pool

-Codechange: DestroyTown is called by DeleteTown to remove all things where a town depends on.
  Last 2 changes to prepare for new pool system. Not pretty now, will be soon.
This commit is contained in:
truelight
2006-08-26 18:05:05 +00:00
parent b7ecdc85d8
commit bb9f29ae1f
2 changed files with 45 additions and 43 deletions

9
town.h
View File

@@ -81,7 +81,6 @@ uint32 GetWorldPopulation(void);
void UpdateTownVirtCoord(Town *t);
void InitializeTown(void);
void ShowTownViewWindow(TownID town);
void DeleteTown(Town *t);
void ExpandTown(Town *t);
Town *CreateRandomTown(uint attempts, uint size_mode);
@@ -218,6 +217,14 @@ static inline bool IsValidTownID(uint index)
return index < GetTownPoolSize() && IsValidTown(GetTown(index));
}
void DestroyTown(Town *t);
static inline void DeleteTown(Town *t)
{
DestroyTown(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(t) FOR_ALL_TOWNS_FROM(t, 0)