From 5199881a8d053a698a8628b3950be58113287166 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 7 Apr 2023 10:12:29 +0100 Subject: [PATCH] Codechange: Use correct type for linkgraph company mask. --- src/linkgraph/linkgraph_gui.cpp | 4 ++-- src/linkgraph/linkgraph_gui.h | 8 ++++---- src/smallmap_gui.cpp | 2 +- src/smallmap_gui.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index b000ae5cc3..bf8e21ef7d 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -444,7 +444,7 @@ void LinkGraphOverlay::SetCargoMask(CargoTypes cargo_mask) * Set a new company mask and rebuild the cache. * @param company_mask New company mask. */ -void LinkGraphOverlay::SetCompanyMask(uint32 company_mask) +void LinkGraphOverlay::SetCompanyMask(CompanyMask company_mask) { this->company_mask = company_mask; this->RebuildCache(); @@ -564,7 +564,7 @@ LinkGraphLegendWindow::LinkGraphLegendWindow(WindowDesc *desc, int window_number */ void LinkGraphLegendWindow::SetOverlay(std::shared_ptr overlay) { this->overlay = overlay; - uint32 companies = this->overlay->GetCompanyMask(); + CompanyMask companies = this->overlay->GetCompanyMask(); for (uint c = 0; c < MAX_COMPANIES; c++) { if (!this->IsWidgetDisabled(WID_LGL_COMPANY_FIRST + c)) { this->SetWidgetLoweredState(WID_LGL_COMPANY_FIRST + c, HasBit(companies, c)); diff --git a/src/linkgraph/linkgraph_gui.h b/src/linkgraph/linkgraph_gui.h index 2d3c2baaff..31cbafbb08 100644 --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -56,13 +56,13 @@ public: * @param company_mask Bitmask of companies to be shown. * @param scale Desired thickness of lines and size of station dots. */ - LinkGraphOverlay(Window *w, uint wid, CargoTypes cargo_mask, uint32 company_mask, uint scale) : + LinkGraphOverlay(Window *w, uint wid, CargoTypes cargo_mask, CompanyMask company_mask, uint scale) : window(w), widget_id(wid), cargo_mask(cargo_mask), company_mask(company_mask), scale(scale) {} void Draw(const DrawPixelInfo *dpi); void SetCargoMask(CargoTypes cargo_mask); - void SetCompanyMask(uint32 company_mask); + void SetCompanyMask(CompanyMask company_mask); bool ShowTooltip(Point pt, TooltipCloseCondition close_cond); @@ -73,13 +73,13 @@ public: CargoTypes GetCargoMask() { return this->cargo_mask; } /** Get a bitmask of the currently shown companies. */ - uint32 GetCompanyMask() { return this->company_mask; } + CompanyMask GetCompanyMask() { return this->company_mask; } protected: Window *window; ///< Window to be drawn into. const uint widget_id; ///< ID of Widget in Window to be drawn to. CargoTypes cargo_mask; ///< Bitmask of cargos to be displayed. - uint32 company_mask; ///< Bitmask of companies to be displayed. + CompanyMask company_mask; ///< Bitmask of companies to be displayed. LinkMap cached_links; ///< Cache for links to reduce recalculation. StationSupplyList cached_stations; ///< Cache for stations to be drawn. uint scale; ///< Width of link lines. diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 7514fdbe99..4e448a05c2 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1594,7 +1594,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt) if (!this->refresh.Elapsed(delta_ms)) return; if (this->map_type == SMT_LINKSTATS) { - uint32 company_mask = this->GetOverlayCompanyMask(); + CompanyMask company_mask = this->GetOverlayCompanyMask(); if (this->overlay->GetCompanyMask() != company_mask) { this->overlay->SetCompanyMask(company_mask); } else { diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index cb2992bbae..774a42a841 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -151,9 +151,9 @@ protected: * the _local_company. Spectators get to see all companies' links. * @return Company mask. */ - inline uint32 GetOverlayCompanyMask() const + inline CompanyMask GetOverlayCompanyMask() const { - return Company::IsValidID(_local_company) ? 1U << _local_company : 0xffffffff; + return Company::IsValidID(_local_company) ? 1U << _local_company : MAX_UVALUE(CompanyMask); } void RebuildColourIndexIfNecessary();