File diff r7385:a7ca8f67757d → r7386:610d1afd3946
src/town.h
Show inline comments
 
@@ -72,13 +72,16 @@ typedef uint16 HouseClassID;
 

	
 
struct BuildingCounts {
 
	uint8 id_count[HOUSE_MAX];
 
	uint8 class_count[HOUSE_CLASS_MAX];
 
};
 

	
 
struct Town {
 
struct Town;
 
DECLARE_OLD_POOL(Town, Town, 3, 8000)
 

	
 
struct Town : PoolItem<Town, TownID, &_Town_pool> {
 
	TileIndex xy;
 

	
 
	/* Current population of people and amount of houses. */
 
	uint16 num_houses;
 
	uint32 population;
 

	
 
@@ -136,23 +139,32 @@ struct Town {
 
	/* Fund buildings program in action? */
 
	byte fund_buildings_months;
 

	
 
	/* Fund road reconstruction in action? */
 
	byte road_build_months;
 

	
 
	/* Index in town array */
 
	TownID index;
 

	
 
	/* If this is a larger town, and should grow more quickly. */
 
	bool larger_town;
 

	
 
	/* NOSAVE: UpdateTownRadius updates this given the house count. */
 
	uint16 radius[5];
 

	
 
	/* NOSAVE: The number of each type of building in the town. */
 
	BuildingCounts building_counts;
 

	
 
	/**
 
	 * Creates a new town
 
	 */
 
	Town(TileIndex tile = 0);
 

	
 
	/** Destroy the town */
 
	~Town();
 

	
 
	bool IsValid() const { return this->xy != 0; }
 

	
 
	void QuickFree();
 
};
 

	
 
struct HouseSpec {
 
	/* Standard properties */
 
	Year min_date;                     ///< introduction year of the house
 
	Year max_date;                     ///< last year it can be built
 
@@ -267,38 +279,26 @@ enum {
 
};
 

	
 
bool CheckforTownRating(uint32 flags, Town *t, byte type);
 

	
 
VARDEF const Town** _town_sort;
 

	
 
DECLARE_OLD_POOL(Town, Town, 3, 8000)
 

	
 
static inline HouseSpec *GetHouseSpecs(HouseID house_id)
 
{
 
	assert(house_id < HOUSE_MAX);
 
	return &_house_specs[house_id];
 
}
 

	
 
/**
 
 * Check if a Town really exists.
 
 * @param town to inquiry
 
 * @return true if it exists
 
 */
 
static inline bool IsValidTown(const Town* town)
 
{
 
	return town->xy != 0;
 
}
 

	
 
/**
 
 * Check if a TownID is valid.
 
 * @param index to inquiry in the pool of town
 
 * @return true if it exists
 
 */
 
static inline bool IsValidTownID(TownID index)
 
{
 
	return index < GetTownPoolSize() && IsValidTown(GetTown(index));
 
	return index < GetTownPoolSize() && GetTown(index)->IsValid();
 
}
 

	
 
VARDEF uint _total_towns;
 

	
 
static inline TownID GetMaxTownIndex()
 
{
 
@@ -334,23 +334,15 @@ static inline Town *GetRandomTown()
 
		}
 
	}
 

	
 
	return GetTown(index);
 
}
 

	
 
void DestroyTown(Town *t);
 

	
 
static inline void DeleteTown(Town *t)
 
{
 
	DestroyTown(t);
 
	t->xy = 0;
 
}
 

	
 
Town* CalcClosestTownFromTile(TileIndex tile, uint threshold);
 

	
 
#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_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? GetTown(t->index + 1U) : NULL) if (t->IsValid())
 
#define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0)
 

	
 
VARDEF bool _town_sort_dirty;
 
VARDEF byte _town_sort_order;
 

	
 
VARDEF Town *_cleared_town;