Codechange: replace INVALID_X with XID::Invalid() for PoolIDs

This commit is contained in:
Rubidium
2025-02-16 19:29:53 +01:00
committed by rubidium42
parent d13b0e0813
commit fd4adc55e3
157 changed files with 744 additions and 772 deletions

View File

@@ -96,7 +96,7 @@ public:
std::vector<BaseEdge> edges; ///< Sorted list of outgoing edges from this node.
BaseNode(TileIndex xy = INVALID_TILE, StationID st = INVALID_STATION, uint demand = 0);
BaseNode(TileIndex xy = INVALID_TILE, StationID st = StationID::Invalid(), uint demand = 0);
/**
* Update the node's supply and set last_update to the current date.

View File

@@ -561,7 +561,7 @@ void LinkGraphLegendWindow::SetOverlay(std::shared_ptr<LinkGraphOverlay> overlay
{
this->overlay = overlay;
CompanyMask companies = this->overlay->GetCompanyMask();
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; ++c) {
for (CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
if (!this->IsWidgetDisabled(WID_LGL_COMPANY_FIRST + c)) {
this->SetWidgetLoweredState(WID_LGL_COMPANY_FIRST + c, companies.Test(c));
}
@@ -658,7 +658,7 @@ bool LinkGraphLegendWindow::OnTooltip([[maybe_unused]] Point, WidgetID widget, T
void LinkGraphLegendWindow::UpdateOverlayCompanies()
{
CompanyMask mask;
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; ++c) {
for (CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
if (this->IsWidgetDisabled(WID_LGL_COMPANY_FIRST + c)) continue;
if (!this->IsWidgetLowered(WID_LGL_COMPANY_FIRST + c)) continue;
mask.Set(c);
@@ -688,7 +688,7 @@ void LinkGraphLegendWindow::OnClick([[maybe_unused]] Point pt, WidgetID widget,
this->UpdateOverlayCompanies();
}
} else if (widget == WID_LGL_COMPANIES_ALL || widget == WID_LGL_COMPANIES_NONE) {
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; ++c) {
for (CompanyID c = CompanyID::Begin(); c < MAX_COMPANIES; ++c) {
if (this->IsWidgetDisabled(WID_LGL_COMPANY_FIRST + c)) continue;
this->SetWidgetLoweredState(WID_LGL_COMPANY_FIRST + c, widget == WID_LGL_COMPANIES_ALL);
}
@@ -719,7 +719,7 @@ void LinkGraphLegendWindow::OnInvalidateData([[maybe_unused]] int data, [[maybe_
}
/* Disable the companies who are not active */
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; ++i) {
for (CompanyID i = CompanyID::Begin(); i < MAX_COMPANIES; ++i) {
this->SetWidgetDisabledState(WID_LGL_COMPANY_FIRST + i, !Company::IsValidID(i));
}
}

View File

@@ -13,10 +13,7 @@
#include "../core/pool_type.hpp"
using LinkGraphID = PoolID<uint16_t, struct LinkGraphIDTag, 0xFFFF, 0xFFFF>;
static constexpr LinkGraphID INVALID_LINK_GRAPH = LinkGraphID::Invalid();
using LinkGraphJobID = PoolID<uint16_t, struct LinkGraphJobIDTag, 0xFFFF, 0xFFFF>;
static constexpr LinkGraphJobID INVALID_LINK_GRAPH_JOB = LinkGraphJobID::Invalid();
typedef uint16_t NodeID;
static const NodeID INVALID_NODE = UINT16_MAX;

View File

@@ -156,7 +156,7 @@ LinkGraphJob::~LinkGraphJob()
it->second.Invalidate();
++it;
} else {
FlowStat shares(INVALID_STATION, 1);
FlowStat shares(StationID::Invalid(), 1);
it->second.SwapShares(shares);
geflows.erase(it++);
for (FlowStat::SharesMap::const_iterator shares_it(shares.GetShares()->begin());

View File

@@ -35,7 +35,7 @@
HopSet seen_hops;
LinkRefresher refresher(v, &seen_hops, allow_merge, is_full_loading);
refresher.RefreshLinks(first, first, v->last_loading_station != INVALID_STATION ? 1 << HAS_CARGO : 0);
refresher.RefreshLinks(first, first, v->last_loading_station != StationID::Invalid() ? 1 << HAS_CARGO : 0);
}
/**
@@ -200,7 +200,7 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next)
{
StationID next_station = next->GetDestination().ToStationID();
Station *st = Station::GetIfValid(cur->GetDestination().ToStationID());
if (st != nullptr && next_station != INVALID_STATION && next_station != st->index) {
if (st != nullptr && next_station != StationID::Invalid() && next_station != st->index) {
Station *st_to = Station::Get(next_station);
for (CargoType c = 0; c < NUM_CARGO; c++) {
/* Refresh the link and give it a minimum capacity. */