summaryrefslogtreecommitdiff
path: root/src/town.h
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-05-22 15:13:50 +0000
committersmatz <smatz@openttd.org>2009-05-22 15:13:50 +0000
commit62a7948af0ca9eb3b190a54918201e1075edcbbc (patch)
tree27a79b7850682cd43cac2462c3410ed8b567c4b2 /src/town.h
parent04723b240ebc7384954f73590be517ad2a47ce04 (diff)
downloadopenttd-62a7948af0ca9eb3b190a54918201e1075edcbbc.tar.xz
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
Diffstat (limited to 'src/town.h')
-rw-r--r--src/town.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/town.h b/src/town.h
index ead399d0c..076037881 100644
--- a/src/town.h
+++ b/src/town.h
@@ -5,7 +5,7 @@
#ifndef TOWN_H
#define TOWN_H
-#include "oldpool.h"
+#include "core/pool.hpp"
#include "core/bitmath_func.hpp"
#include "core/random_func.hpp"
#include "cargo_type.h"
@@ -100,9 +100,10 @@ struct BuildingCounts {
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY = 4; ///< value for custom town number in difficulty settings
static const uint CUSTOM_TOWN_MAX_NUMBER = 5000; ///< this is the maximum number of towns a user can specify in customisation
-DECLARE_OLD_POOL(Town, Town, 3, 8000)
+typedef Pool<Town, TownID, 64, 64000> TownPool;
+extern TownPool _town_pool;
-struct Town : PoolItem<Town, TownID, &_Town_pool> {
+struct Town : TownPool::PoolItem<&_town_pool> {
TileIndex xy;
/* Current population of people and amount of houses. */
@@ -183,13 +184,11 @@ struct Town : PoolItem<Town, TownID, &_Town_pool> {
/**
* Creates a new town
*/
- Town(TileIndex tile = INVALID_TILE);
+ Town(TileIndex tile = INVALID_TILE) : xy(tile) { }
/** Destroy the town */
~Town();
- inline bool IsValid() const { return this->xy != INVALID_TILE; }
-
void InitializeLayout(TownLayout layout);
/** Calculate the max town noise
@@ -297,9 +296,7 @@ TileIndexDiff GetHouseNorthPart(HouseID &house);
static inline uint GetNumTowns()
{
- extern uint _total_towns;
-
- return _total_towns;
+ return (uint)Town::GetNumItems();
}
/**
@@ -324,7 +321,7 @@ static inline Town *GetRandomTown()
return Town::Get(index);
}
-Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX);
+Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX, const Town *ignore = NULL);
#define FOR_ALL_TOWNS_FROM(var, start) FOR_ALL_ITEMS_FROM(Town, town_index, var, start)
#define FOR_ALL_TOWNS(var) FOR_ALL_TOWNS_FROM(var, 0)