changeset 11923:ee96e716b842 draft

(svn r16326) -Codechange: replace GetPoolItemPoolSize() by PoolItem::GetPoolSize()
author smatz <smatz@openttd.org>
date Sat, 16 May 2009 23:44:36 +0000
parents 0a4b63f3f3c3
children fccc9cea27a7
files src/ai/ai_core.cpp src/autoreplace_base.h src/cargopacket.h src/cheat_gui.cpp src/company_base.h src/company_cmd.cpp src/depot_base.h src/engine.cpp src/engine_base.h src/group.h src/group_cmd.cpp src/industry.h src/network/core/tcp_game.h src/network/network_base.h src/network/network_chat_gui.cpp src/newgrf.cpp src/oldpool.h src/order_base.h src/saveload/oldloader_sl.cpp src/saveload/vehicle_sl.cpp src/signs_base.h src/station_base.h src/town.h src/vehicle_base.h src/waypoint.h src/waypoint_cmd.cpp
diffstat 26 files changed, 66 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -104,7 +104,7 @@
 /* static */ void AI::KillAll()
 {
 	/* It might happen there are no companies .. than we have nothing to loop */
-	if (GetCompanyPoolSize() == 0) return;
+	if (Company::GetPoolSize() == 0) return;
 
 	const Company *c;
 	FOR_ALL_COMPANIES(c) {
--- a/src/autoreplace_base.h
+++ b/src/autoreplace_base.h
@@ -34,7 +34,7 @@
 	inline bool IsValid() const { return this->from != INVALID_ENGINE; }
 };
 
-#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = EngineRenew::Get(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? EngineRenew::Get(er->index + 1U) : NULL) if (er->IsValid())
+#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = EngineRenew::Get(start); er != NULL; er = (er->index + 1U < EngineRenew::GetPoolSize()) ? EngineRenew::Get(er->index + 1U) : NULL) if (er->IsValid())
 #define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0)
 
 #endif /* AUTOREPLACE_BASE_H */
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -63,7 +63,7 @@
  * @param cp    the variable used as "iterator"
  * @param start the cargo packet ID of the first packet to iterate over
  */
-#define FOR_ALL_CARGOPACKETS_FROM(cp, start) for (cp = CargoPacket::Get(start); cp != NULL; cp = (cp->index + 1U < GetCargoPacketPoolSize()) ? CargoPacket::Get(cp->index + 1U) : NULL) if (cp->IsValid())
+#define FOR_ALL_CARGOPACKETS_FROM(cp, start) for (cp = CargoPacket::Get(start); cp != NULL; cp = (cp->index + 1U < CargoPacket::GetPoolSize()) ? CargoPacket::Get(cp->index + 1U) : NULL) if (cp->IsValid())
 
 /**
  * Iterate over all _valid_ cargo packets from the begin of the pool
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -43,7 +43,7 @@
  */
 static int32 ClickChangeCompanyCheat(int32 p1, int32 p2)
 {
-	while ((uint)p1 < GetCompanyPoolSize()) {
+	while ((uint)p1 < Company::GetPoolSize()) {
 		if (IsValidCompanyID((CompanyID)p1)) {
 			SetLocalCompany((CompanyID)p1);
 			return _local_company;
--- a/src/company_base.h
+++ b/src/company_base.h
@@ -87,10 +87,10 @@
 
 static inline bool IsValidCompanyID(CompanyID company)
 {
-	return company < MAX_COMPANIES && (uint)company < GetCompanyPoolSize() && Company::Get(company)->IsValid();
+	return company < MAX_COMPANIES && (uint)company < Company::GetPoolSize() && Company::Get(company)->IsValid();
 }
 
-#define FOR_ALL_COMPANIES_FROM(d, start) for (d = Company::Get(start); d != NULL; d = (d->index + 1U < GetCompanyPoolSize()) ? Company::Get(d->index + 1U) : NULL) if (d->IsValid())
+#define FOR_ALL_COMPANIES_FROM(d, start) for (d = Company::Get(start); d != NULL; d = (d->index + 1U < Company::GetPoolSize()) ? Company::Get(d->index + 1U) : NULL) if (d->IsValid())
 #define FOR_ALL_COMPANIES(d) FOR_ALL_COMPANIES_FROM(d, 0)
 
 static inline byte ActiveCompanyCount()
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -457,7 +457,7 @@
 
 	if (is_ai && (!_networking || _network_server)) AI::StartNew(c->index);
 
-	c->num_engines = CallocT<uint16>(GetEnginePoolSize());
+	c->num_engines = CallocT<uint16>(Engine::GetPoolSize());
 
 	return c;
 }
--- a/src/depot_base.h
+++ b/src/depot_base.h
@@ -24,12 +24,12 @@
 
 static inline bool IsValidDepotID(DepotID index)
 {
-	return index < GetDepotPoolSize() && Depot::Get(index)->IsValid();
+	return index < Depot::GetPoolSize() && Depot::Get(index)->IsValid();
 }
 
 Depot *GetDepotByTile(TileIndex tile);
 
-#define FOR_ALL_DEPOTS_FROM(d, start) for (d = Depot::Get(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? Depot::Get(d->index + 1U) : NULL) if (d->IsValid())
+#define FOR_ALL_DEPOTS_FROM(d, start) for (d = Depot::Get(start); d != NULL; d = (d->index + 1U < Depot::GetPoolSize()) ? Depot::Get(d->index + 1U) : NULL) if (d->IsValid())
 #define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
 
 #endif /* DEPOT_BASE_H */
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -356,7 +356,7 @@
  */
 void SetCachedEngineCounts()
 {
-	uint engines = GetEnginePoolSize();
+	uint engines = Engine::GetPoolSize();
 
 	/* Set up the engine count for all companies */
 	Company *c;
--- a/src/engine_base.h
+++ b/src/engine_base.h
@@ -84,10 +84,10 @@
 
 static inline bool IsEngineIndex(uint index)
 {
-	return index < GetEnginePoolSize();
+	return index < Engine::GetPoolSize();
 }
 
-#define FOR_ALL_ENGINES_FROM(e, start) for (e = Engine::Get(start); e != NULL; e = (e->index + 1U < GetEnginePoolSize()) ? Engine::Get(e->index + 1U) : NULL) if (e->IsValid())
+#define FOR_ALL_ENGINES_FROM(e, start) for (e = Engine::Get(start); e != NULL; e = (e->index + 1U < Engine::GetPoolSize()) ? Engine::Get(e->index + 1U) : NULL) if (e->IsValid())
 #define FOR_ALL_ENGINES(e) FOR_ALL_ENGINES_FROM(e, 0)
 
 #define FOR_ALL_ENGINES_OF_TYPE(e, engine_type) FOR_ALL_ENGINES(e) if (e->type == engine_type)
--- a/src/group.h
+++ b/src/group.h
@@ -32,7 +32,7 @@
 
 static inline bool IsValidGroupID(GroupID index)
 {
-	return index < GetGroupPoolSize() && Group::Get(index)->IsValid();
+	return index < Group::GetPoolSize() && Group::Get(index)->IsValid();
 }
 
 static inline bool IsDefaultGroupID(GroupID index)
@@ -50,7 +50,7 @@
 	return id_g == ALL_GROUP;
 }
 
-#define FOR_ALL_GROUPS_FROM(g, start) for (g = Group::Get(start); g != NULL; g = (g->index + 1U < GetGroupPoolSize()) ? Group::Get(g->index + 1) : NULL) if (g->IsValid())
+#define FOR_ALL_GROUPS_FROM(g, start) for (g = Group::Get(start); g != NULL; g = (g->index + 1U < Group::GetPoolSize()) ? Group::Get(g->index + 1) : NULL) if (g->IsValid())
 #define FOR_ALL_GROUPS(g) FOR_ALL_GROUPS_FROM(g, 0)
 
 /**
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -47,7 +47,7 @@
 {
 	this->owner = owner;
 
-	if (this->IsValid()) this->num_engines = CallocT<uint16>(GetEnginePoolSize());
+	if (this->IsValid()) this->num_engines = CallocT<uint16>(Engine::GetPoolSize());
 }
 
 Group::~Group()
--- a/src/industry.h
+++ b/src/industry.h
@@ -272,7 +272,7 @@
  */
 static inline bool IsValidIndustryID(IndustryID index)
 {
-	return index < GetIndustryPoolSize() && Industry::Get(index)->IsValid();
+	return index < Industry::GetPoolSize() && Industry::Get(index)->IsValid();
 }
 
 
@@ -283,7 +283,7 @@
 	 *  _really_ returns the highest index. Now it just returns
 	 *  the next safe value we are sure about everything is below.
 	 */
-	return GetIndustryPoolSize() - 1;
+	return Industry::GetPoolSize() - 1;
 }
 
 extern int _total_industries;  // general counter
@@ -355,7 +355,7 @@
 	return Industry::Get(index);
 }
 
-#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = Industry::Get(start); i != NULL; i = (i->index + 1U < GetIndustryPoolSize()) ? Industry::Get(i->index + 1U) : NULL) if (i->IsValid())
+#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = Industry::Get(start); i != NULL; i = (i->index + 1U < Industry::GetPoolSize()) ? Industry::Get(i->index + 1U) : NULL) if (i->IsValid())
 #define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0)
 
 static const uint8 IT_INVALID = 255;
--- a/src/network/core/tcp_game.h
+++ b/src/network/core/tcp_game.h
@@ -110,10 +110,10 @@
 
 static inline bool IsValidNetworkClientSocketIndex(ClientIndex index)
 {
-	return (uint)index < GetNetworkClientSocketPoolSize() && NetworkClientSocket::Get(index)->IsValid();
+	return (uint)index < NetworkClientSocket::GetPoolSize() && NetworkClientSocket::Get(index)->IsValid();
 }
 
-#define FOR_ALL_CLIENT_SOCKETS_FROM(d, start) for (d = NetworkClientSocket::Get(start); d != NULL; d = (d->index + 1U < GetNetworkClientSocketPoolSize()) ? NetworkClientSocket::Get(d->index + 1U) : NULL) if (d->IsValid())
+#define FOR_ALL_CLIENT_SOCKETS_FROM(d, start) for (d = NetworkClientSocket::Get(start); d != NULL; d = (d->index + 1U < NetworkClientSocket::GetPoolSize()) ? NetworkClientSocket::Get(d->index + 1U) : NULL) if (d->IsValid())
 #define FOR_ALL_CLIENT_SOCKETS(d) FOR_ALL_CLIENT_SOCKETS_FROM(d, 0)
 
 #endif /* ENABLE_NETWORK */
--- a/src/network/network_base.h
+++ b/src/network/network_base.h
@@ -29,10 +29,10 @@
 
 static inline bool IsValidNetworkClientInfoIndex(ClientIndex index)
 {
-	return (uint)index < GetNetworkClientInfoPoolSize() && NetworkClientInfo::Get(index)->IsValid();
+	return (uint)index < NetworkClientInfo::GetPoolSize() && NetworkClientInfo::Get(index)->IsValid();
 }
 
-#define FOR_ALL_CLIENT_INFOS_FROM(d, start) for (d = NetworkClientInfo::Get(start); d != NULL; d = (d->index + 1U < GetNetworkClientInfoPoolSize()) ? NetworkClientInfo::Get(d->index + 1U) : NULL) if (d->IsValid())
+#define FOR_ALL_CLIENT_INFOS_FROM(d, start) for (d = NetworkClientInfo::Get(start); d != NULL; d = (d->index + 1U < NetworkClientInfo::GetPoolSize()) ? NetworkClientInfo::Get(d->index + 1U) : NULL) if (d->IsValid())
 #define FOR_ALL_CLIENT_INFOS(d) FOR_ALL_CLIENT_INFOS_FROM(d, 0)
 
 #endif /* ENABLE_NETWORK */
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -303,7 +303,7 @@
 
 		/* First, try clients */
 		if (*item < MAX_CLIENT_SLOTS) {
-			if (*item < GetNetworkClientInfoPoolSize()) {
+			if (*item < NetworkClientInfo::GetPoolSize()) {
 				/* Skip inactive clients */
 				NetworkClientInfo *ci;
 				FOR_ALL_CLIENT_INFOS_FROM(ci, *item) break;
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -378,7 +378,7 @@
 
 	if (static_access) return NULL;
 
-	uint engine_pool_size = GetEnginePoolSize();
+	uint engine_pool_size = Engine::GetPoolSize();
 
 	/* ... it's not, so create a new one based off an existing engine */
 	Engine *e = new Engine(type, internal_id);
@@ -392,12 +392,12 @@
 	eid->internal_id     = internal_id;
 	eid->substitute_id   = min(internal_id, _engine_counts[type]); // substitute_id == _engine_counts[subtype] means "no substitute"
 
-	if (engine_pool_size != GetEnginePoolSize()) {
+	if (engine_pool_size != Engine::GetPoolSize()) {
 		/* Resize temporary engine data ... */
-		_gted = ReallocT(_gted, GetEnginePoolSize());
+		_gted = ReallocT(_gted, Engine::GetPoolSize());
 
 		/* and blank the new block. */
-		size_t len = (GetEnginePoolSize() - engine_pool_size) * sizeof(*_gted);
+		size_t len = (Engine::GetPoolSize() - engine_pool_size) * sizeof(*_gted);
 		memset(_gted + engine_pool_size, 0, len);
 	}
 
@@ -5575,7 +5575,7 @@
 	ResetRailTypes();
 
 	/* Allocate temporary refit/cargo class data */
-	_gted = CallocT<GRFTempEngineData>(GetEnginePoolSize());
+	_gted = CallocT<GRFTempEngineData>(Engine::GetPoolSize());
 
 	/* Reset GRM reservations */
 	memset(&_grm_engines, 0, sizeof(_grm_engines));
--- a/src/oldpool.h
+++ b/src/oldpool.h
@@ -279,12 +279,21 @@
 
 	/**
 	 * Get item with given index
+	 * @param index item to get
 	 */
 	static FORCEINLINE T *Get(uint index)
 	{
 		return Tpool->Get(index);
 	}
 
+	/**
+	 * Returns size of the pool (in number of items)
+	 */
+	static FORCEINLINE uint GetPoolSize()
+	{
+		return Tpool->GetSize();
+	}
+
 private:
 	static T *AllocateSafeRaw(uint &first);
 
@@ -333,14 +342,9 @@
 	};
 
 
-#define OLD_POOL_ACCESSORS(name, type) \
-	static inline uint Get##name##PoolSize()  { return _##name##_pool.GetSize(); }
-
-
 #define DECLARE_OLD_POOL(name, type, block_size_bits, max_blocks) \
 	OLD_POOL_ENUM(name, type, block_size_bits, max_blocks) \
-	extern OldMemoryPool<type> _##name##_pool; \
-	OLD_POOL_ACCESSORS(name, type)
+	extern OldMemoryPool<type> _##name##_pool;
 
 
 #define DEFINE_OLD_POOL(name, type, new_block_proc, clean_block_proc) \
@@ -359,7 +363,7 @@
 #define STATIC_OLD_POOL(name, type, block_size_bits, max_blocks, new_block_proc, clean_block_proc) \
 	OLD_POOL_ENUM(name, type, block_size_bits, max_blocks) \
 	static DEFINE_OLD_POOL(name, type, new_block_proc, clean_block_proc) \
-	OLD_POOL_ACCESSORS(name, type) \
-	static inline type *Get##name(uint index) { return _##name##_pool.Get(index); }
+	static inline type *Get##name(uint index) { return _##name##_pool.Get(index); } \
+	static inline uint Get##name##PoolSize()  { return _##name##_pool.GetSize(); }
 
 #endif /* OLDPOOL_H */
--- a/src/order_base.h
+++ b/src/order_base.h
@@ -250,12 +250,12 @@
 	 *  _really_ returns the highest index. Now it just returns
 	 *  the next safe value we are sure about everything is below.
 	 */
-	return GetOrderPoolSize() - 1;
+	return Order::GetPoolSize() - 1;
 }
 
 static inline VehicleOrderID GetNumOrders()
 {
-	return GetOrderPoolSize();
+	return Order::GetPoolSize();
 }
 
 /** Shared order list linking together the linked list of orders and the list
@@ -423,17 +423,17 @@
 
 static inline bool IsValidOrderListID(uint index)
 {
-	return index < GetOrderListPoolSize() && OrderList::Get(index)->IsValid();
+	return index < OrderList::GetPoolSize() && OrderList::Get(index)->IsValid();
 }
 
-#define FOR_ALL_ORDERS_FROM(order, start) for (order = Order::Get(start); order != NULL; order = (order->index + 1U < GetOrderPoolSize()) ? Order::Get(order->index + 1U) : NULL) if (order->IsValid())
+#define FOR_ALL_ORDERS_FROM(order, start) for (order = Order::Get(start); order != NULL; order = (order->index + 1U < Order::GetPoolSize()) ? Order::Get(order->index + 1U) : NULL) if (order->IsValid())
 #define FOR_ALL_ORDERS(order) FOR_ALL_ORDERS_FROM(order, 0)
 
 
 #define FOR_VEHICLE_ORDERS(v, order) for (order = (v->orders.list == NULL) ? NULL : v->orders.list->GetFirstOrder(); order != NULL; order = order->next)
 
 
-#define FOR_ALL_ORDER_LISTS_FROM(ol, start) for (ol = OrderList::Get(start); ol != NULL; ol = (ol->index + 1U < GetOrderListPoolSize()) ? OrderList::Get(ol->index + 1U) : NULL) if (ol->IsValid())
+#define FOR_ALL_ORDER_LISTS_FROM(ol, start) for (ol = OrderList::Get(start); ol != NULL; ol = (ol->index + 1U < OrderList::GetPoolSize()) ? OrderList::Get(ol->index + 1U) : NULL) if (ol->IsValid())
 #define FOR_ALL_ORDER_LISTS(ol) FOR_ALL_ORDER_LISTS_FROM(ol, 0)
 
 #endif /* ORDER_H */
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -1362,7 +1362,7 @@
 		}
 		v->current_order.AssignOrder(UnpackOldOrder(_old_order));
 
-		if (_old_next_ptr != 0xFFFF) v->next = GetVehiclePoolSize() <= _old_next_ptr ? new (_old_next_ptr) InvalidVehicle() : Vehicle::Get(_old_next_ptr);
+		if (_old_next_ptr != 0xFFFF) v->next = Vehicle::GetPoolSize() <= _old_next_ptr ? new (_old_next_ptr) InvalidVehicle() : Vehicle::Get(_old_next_ptr);
 
 		if (_cargo_count != 0) {
 			CargoPacket *cp = new CargoPacket((_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, _cargo_count);
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -208,7 +208,7 @@
  */
 static void CheckValidVehicles()
 {
-	uint total_engines = GetEnginePoolSize();
+	uint total_engines = Engine::GetPoolSize();
 	EngineID first_engine[4] = { INVALID_ENGINE, INVALID_ENGINE, INVALID_ENGINE, INVALID_ENGINE };
 
 	Engine *e;
--- a/src/signs_base.h
+++ b/src/signs_base.h
@@ -38,15 +38,15 @@
 	 *  _really_ returns the highest index. Now it just returns
 	 *  the next safe value we are sure about everything is below.
 	 */
-	return GetSignPoolSize() - 1;
+	return Sign::GetPoolSize() - 1;
 }
 
 static inline bool IsValidSignID(uint index)
 {
-	return index < GetSignPoolSize() && Sign::Get(index)->IsValid();
+	return index < Sign::GetPoolSize() && Sign::Get(index)->IsValid();
 }
 
-#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = Sign::Get(start); ss != NULL; ss = (ss->index + 1U < GetSignPoolSize()) ? Sign::Get(ss->index + 1U) : NULL) if (ss->IsValid())
+#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = Sign::Get(start); ss != NULL; ss = (ss->index + 1U < Sign::GetPoolSize()) ? Sign::Get(ss->index + 1U) : NULL) if (ss->IsValid())
 #define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
 
 #endif /* SIGNS_BASE_H */
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -211,26 +211,26 @@
 	 *  _really_ returns the highest index. Now it just returns
 	 *  the next safe value we are sure about everything is below.
 	 */
-	return GetStationPoolSize() - 1;
+	return Station::GetPoolSize() - 1;
 }
 
 static inline uint GetNumStations()
 {
-	return GetStationPoolSize();
+	return Station::GetPoolSize();
 }
 
 static inline bool IsValidStationID(StationID index)
 {
-	return index < GetStationPoolSize() && Station::Get(index)->IsValid();
+	return index < Station::GetPoolSize() && Station::Get(index)->IsValid();
 }
 
-#define FOR_ALL_STATIONS_FROM(st, start) for (st = Station::Get(start); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? Station::Get(st->index + 1U) : NULL) if (st->IsValid())
+#define FOR_ALL_STATIONS_FROM(st, start) for (st = Station::Get(start); st != NULL; st = (st->index + 1U < Station::GetPoolSize()) ? Station::Get(st->index + 1U) : NULL) if (st->IsValid())
 #define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0)
 
 
 /* Stuff for ROADSTOPS */
 
-#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = RoadStop::Get(start); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? RoadStop::Get(rs->index + 1U) : NULL) if (rs->IsValid())
+#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = RoadStop::Get(start); rs != NULL; rs = (rs->index + 1U < RoadStop::GetPoolSize()) ? RoadStop::Get(rs->index + 1U) : NULL) if (rs->IsValid())
 #define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
 
 /* End of stuff for ROADSTOPS */
--- a/src/town.h
+++ b/src/town.h
@@ -302,7 +302,7 @@
  */
 static inline bool IsValidTownID(TownID index)
 {
-	return index < GetTownPoolSize() && Town::Get(index)->IsValid();
+	return index < Town::GetPoolSize() && Town::Get(index)->IsValid();
 }
 
 static inline TownID GetMaxTownIndex()
@@ -312,7 +312,7 @@
 	 *  _really_ returns the highest index. Now it just returns
 	 *  the next safe value we are sure about everything is below.
 	 */
-	return GetTownPoolSize() - 1;
+	return Town::GetPoolSize() - 1;
 }
 
 static inline uint GetNumTowns()
@@ -346,7 +346,7 @@
 
 Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX);
 
-#define FOR_ALL_TOWNS_FROM(t, start) for (t = Town::Get(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? Town::Get(t->index + 1U) : NULL) if (t->IsValid())
+#define FOR_ALL_TOWNS_FROM(t, start) for (t = Town::Get(start); t != NULL; t = (t->index + 1U < Town::GetPoolSize()) ? Town::Get(t->index + 1U) : NULL) if (t->IsValid())
 #define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0)
 
 extern Town *_cleared_town;
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -649,15 +649,15 @@
 	 *  _really_ returns the highest index. Now it just returns
 	 *  the next safe value we are sure about everything is below.
 	 */
-	return GetVehiclePoolSize() - 1;
+	return Vehicle::GetPoolSize() - 1;
 }
 
 static inline uint GetNumVehicles()
 {
-	return GetVehiclePoolSize();
+	return Vehicle::GetPoolSize();
 }
 
-#define FOR_ALL_VEHICLES_FROM(v, start) for (v = Vehicle::Get(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? Vehicle::Get(v->index + 1) : NULL) if (v->IsValid())
+#define FOR_ALL_VEHICLES_FROM(v, start) for (v = Vehicle::Get(start); v != NULL; v = (v->index + 1U < Vehicle::GetPoolSize()) ? Vehicle::Get(v->index + 1) : NULL) if (v->IsValid())
 #define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0)
 
 /**
@@ -667,7 +667,7 @@
  */
 static inline bool IsValidVehicleID(uint index)
 {
-	return index < GetVehiclePoolSize() && Vehicle::Get(index)->IsValid();
+	return index < Vehicle::GetPoolSize() && Vehicle::Get(index)->IsValid();
 }
 
 
--- a/src/waypoint.h
+++ b/src/waypoint.h
@@ -42,10 +42,10 @@
 
 static inline bool IsValidWaypointID(WaypointID index)
 {
-	return index < GetWaypointPoolSize() && Waypoint::Get(index)->IsValid();
+	return index < Waypoint::GetPoolSize() && Waypoint::Get(index)->IsValid();
 }
 
-#define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = Waypoint::Get(start); wp != NULL; wp = (wp->index + 1U < GetWaypointPoolSize()) ? Waypoint::Get(wp->index + 1U) : NULL) if (wp->IsValid())
+#define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = Waypoint::Get(start); wp != NULL; wp = (wp->index + 1U < Waypoint::GetPoolSize()) ? Waypoint::Get(wp->index + 1U) : NULL) if (wp->IsValid())
 #define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)
 
 
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -69,7 +69,7 @@
 	 * If it wasn't using 'used' and 'idx', it would just search for increasing 'next',
 	 * but this way it is faster */
 
-	WaypointID cid = 0; // current index, goes to GetWaypointPoolSize()-1, then wraps to 0
+	WaypointID cid = 0; // current index, goes to Waypoint::GetPoolSize()-1, then wraps to 0
 	do {
 		Waypoint *lwp = Waypoint::Get(cid);
 
@@ -99,7 +99,7 @@
 		}
 
 		cid++;
-		if (cid == GetWaypointPoolSize()) cid = 0; // wrap to zero...
+		if (cid == Waypoint::GetPoolSize()) cid = 0; // wrap to zero...
 	} while (cid != idx);
 
 	wp->town_cn = (uint16)next; // set index...