summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-05-16 23:44:36 +0000
committersmatz <smatz@openttd.org>2009-05-16 23:44:36 +0000
commited1e54bd84074412ea9f273b7cd86aed42d844ce (patch)
tree4a5ab5dbd304f9a53f8f0065bc6965b1680ded78
parent6221d74644922ea4bbba3ed9cd8bbec42398f77b (diff)
downloadopenttd-ed1e54bd84074412ea9f273b7cd86aed42d844ce.tar.xz
(svn r16326) -Codechange: replace GetPoolItemPoolSize() by PoolItem::GetPoolSize()
-rw-r--r--src/ai/ai_core.cpp2
-rw-r--r--src/autoreplace_base.h2
-rw-r--r--src/cargopacket.h2
-rw-r--r--src/cheat_gui.cpp2
-rw-r--r--src/company_base.h4
-rw-r--r--src/company_cmd.cpp2
-rw-r--r--src/depot_base.h4
-rw-r--r--src/engine.cpp2
-rw-r--r--src/engine_base.h4
-rw-r--r--src/group.h4
-rw-r--r--src/group_cmd.cpp2
-rw-r--r--src/industry.h6
-rw-r--r--src/network/core/tcp_game.h4
-rw-r--r--src/network/network_base.h4
-rw-r--r--src/network/network_chat_gui.cpp2
-rw-r--r--src/newgrf.cpp10
-rw-r--r--src/oldpool.h20
-rw-r--r--src/order_base.h10
-rw-r--r--src/saveload/oldloader_sl.cpp2
-rw-r--r--src/saveload/vehicle_sl.cpp2
-rw-r--r--src/signs_base.h6
-rw-r--r--src/station_base.h10
-rw-r--r--src/town.h6
-rw-r--r--src/vehicle_base.h8
-rw-r--r--src/waypoint.h4
-rw-r--r--src/waypoint_cmd.cpp4
26 files changed, 66 insertions, 62 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index 625c707a9..16ad01452 100644
--- 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) {
diff --git a/src/autoreplace_base.h b/src/autoreplace_base.h
index 2c704b70a..500f9595a 100644
--- a/src/autoreplace_base.h
+++ b/src/autoreplace_base.h
@@ -34,7 +34,7 @@ struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> {
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 */
diff --git a/src/cargopacket.h b/src/cargopacket.h
index 68efb8557..941e6da8a 100644
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -63,7 +63,7 @@ struct CargoPacket : PoolItem<CargoPacket, CargoPacketID, &_CargoPacket_pool> {
* @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
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp
index def295b20..8b3843617 100644
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -43,7 +43,7 @@ static int32 ClickMoneyCheat(int32 p1, int32 p2)
*/
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;
diff --git a/src/company_base.h b/src/company_base.h
index e1ab9c9ca..edffdc684 100644
--- a/src/company_base.h
+++ b/src/company_base.h
@@ -87,10 +87,10 @@ struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
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()
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 6e75e5428..358122efc 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -457,7 +457,7 @@ Company *DoStartupNewCompany(bool is_ai)
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;
}
diff --git a/src/depot_base.h b/src/depot_base.h
index 9bd5908e1..0e1c39163 100644
--- a/src/depot_base.h
+++ b/src/depot_base.h
@@ -24,12 +24,12 @@ struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
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 */
diff --git a/src/engine.cpp b/src/engine.cpp
index aa7e29c32..0f641d016 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -356,7 +356,7 @@ EngineID EngineOverrideManager::GetID(VehicleType type, uint16 grf_local_id, uin
*/
void SetCachedEngineCounts()
{
- uint engines = GetEnginePoolSize();
+ uint engines = Engine::GetPoolSize();
/* Set up the engine count for all companies */
Company *c;
diff --git a/src/engine_base.h b/src/engine_base.h
index 8974f09f8..0f6d70f90 100644
--- a/src/engine_base.h
+++ b/src/engine_base.h
@@ -84,10 +84,10 @@ extern EngineOverrideManager _engine_mngr;
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)
diff --git a/src/group.h b/src/group.h
index 618d1407f..84efd6e0e 100644
--- a/src/group.h
+++ b/src/group.h
@@ -32,7 +32,7 @@ struct Group : PoolItem<Group, GroupID, &_Group_pool> {
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 @@ static inline bool IsAllGroupID(GroupID id_g)
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)
/**
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp
index 6834596fb..371881a08 100644
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -47,7 +47,7 @@ Group::Group(Owner owner)
{
this->owner = owner;
- if (this->IsValid()) this->num_engines = CallocT<uint16>(GetEnginePoolSize());
+ if (this->IsValid()) this->num_engines = CallocT<uint16>(Engine::GetPoolSize());
}
Group::~Group()
diff --git a/src/industry.h b/src/industry.h
index d06764429..69af3f436 100644
--- a/src/industry.h
+++ b/src/industry.h
@@ -272,7 +272,7 @@ void SetIndustryDailyChanges();
*/
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 @@ static inline IndustryID GetMaxIndustryIndex()
* _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 @@ static inline Industry *GetRandomIndustry()
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;
diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h
index e1224c5e2..48abc996d 100644
--- a/src/network/core/tcp_game.h
+++ b/src/network/core/tcp_game.h
@@ -110,10 +110,10 @@ public:
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 */
diff --git a/src/network/network_base.h b/src/network/network_base.h
index 3892db7d3..3044de7a1 100644
--- a/src/network/network_base.h
+++ b/src/network/network_base.h
@@ -29,10 +29,10 @@ struct NetworkClientInfo : PoolItem<NetworkClientInfo, ClientIndex, &_NetworkCli
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 */
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index c0559af65..17e17e32c 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -303,7 +303,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
/* 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;
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 9ee16ba94..e81681ebc 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -378,7 +378,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
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 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
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 @@ static void ResetNewGRFData()
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));
diff --git a/src/oldpool.h b/src/oldpool.h
index 14e31a1bd..50bbdfe6e 100644
--- a/src/oldpool.h
+++ b/src/oldpool.h
@@ -279,12 +279,21 @@ struct PoolItem {
/**
* 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 @@ public:
};
-#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 @@ public:
#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 */
diff --git a/src/order_base.h b/src/order_base.h
index b743a26fa..1c6566194 100644
--- a/src/order_base.h
+++ b/src/order_base.h
@@ -250,12 +250,12 @@ static inline VehicleOrderID GetMaxOrderIndex()
* _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 @@ public:
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 */
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index b668828c0..0dce4a5ae 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -1362,7 +1362,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
}
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);
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index 695b2c831..2058bd819 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -208,7 +208,7 @@ void UpdateOldAircraft()
*/
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;
diff --git a/src/signs_base.h b/src/signs_base.h
index cf1f99005..88e57d330 100644
--- a/src/signs_base.h
+++ b/src/signs_base.h
@@ -38,15 +38,15 @@ static inline SignID GetMaxSignIndex()
* _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 */
diff --git a/src/station_base.h b/src/station_base.h
index 756d4721d..bbaebbb65 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -211,26 +211,26 @@ static inline StationID GetMaxStationIndex()
* _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 */
diff --git a/src/town.h b/src/town.h
index 71f65f552..bc746fb83 100644
--- a/src/town.h
+++ b/src/town.h
@@ -302,7 +302,7 @@ TileIndexDiff GetHouseNorthPart(HouseID &house);
*/
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 @@ static inline TownID GetMaxTownIndex()
* _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 @@ static inline Town *GetRandomTown()
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;
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index a1d451d32..9d611c01a 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -649,15 +649,15 @@ static inline VehicleID GetMaxVehicleIndex()
* _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 uint GetNumVehicles()
*/
static inline bool IsValidVehicleID(uint index)
{
- return index < GetVehiclePoolSize() && Vehicle::Get(index)->IsValid();
+ return index < Vehicle::GetPoolSize() && Vehicle::Get(index)->IsValid();
}
diff --git a/src/waypoint.h b/src/waypoint.h
index c33910564..fe80b2ba9 100644
--- a/src/waypoint.h
+++ b/src/waypoint.h
@@ -42,10 +42,10 @@ struct Waypoint : PoolItem<Waypoint, WaypointID, &_Waypoint_pool> {
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)
diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp
index a8f50e13e..e47310bfd 100644
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -69,7 +69,7 @@ static void MakeDefaultWaypointName(Waypoint *wp)
* 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 @@ static void MakeDefaultWaypointName(Waypoint *wp)
}
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...