(svn r16326) -Codechange: replace GetPoolItemPoolSize() by PoolItem::GetPoolSize()

This commit is contained in:
smatz 2009-05-16 23:44:36 +00:00
parent 6221d74644
commit ed1e54bd84
26 changed files with 66 additions and 62 deletions

View File

@ -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) {

View File

@ -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 */

View File

@ -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

View File

@ -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;

View File

@ -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()

View File

@ -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;
}

View File

@ -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 */

View File

@ -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;

View File

@ -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)

View File

@ -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)
/**

View File

@ -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()

View File

@ -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;

View File

@ -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 */

View File

@ -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 */

View File

@ -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;

View File

@ -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));

View File

@ -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 */

View File

@ -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 */

View File

@ -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);

View File

@ -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;

View File

@ -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 */

View File

@ -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 */

View File

@ -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;

View File

@ -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();
}

View File

@ -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)

View File

@ -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...