diff options
author | glx22 <glx@openttd.org> | 2021-06-13 02:41:41 +0200 |
---|---|---|
committer | Loïc Guilloux <glx22@users.noreply.github.com> | 2021-07-09 21:36:09 +0200 |
commit | 5844027eb8588197d82fe896f027182621c4f923 (patch) | |
tree | 1c7def8d614ade7d98ab97d42651a152b34eafe7 /src/station_gui.cpp | |
parent | 87eb997be0ffb8a62f31ed222e41a10a2622437f (diff) | |
download | openttd-5844027eb8588197d82fe896f027182621c4f923.tar.xz |
Codechange: Remove FOR_ALL_SORTED_STANDARD_CARGOSPECS
Diffstat (limited to 'src/station_gui.cpp')
-rw-r--r-- | src/station_gui.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/station_gui.cpp b/src/station_gui.cpp index a43cc1707..1b64d8aee 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -347,10 +347,12 @@ public: this->FinishInitNested(window_number); this->owner = (Owner)this->window_number; - const CargoSpec *cs; - FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) { - if (!HasBit(this->cargo_filter, cs->Index())) continue; - this->LowerWidget(WID_STL_CARGOSTART + index); + uint8 index = 0; + for (const CargoSpec *cs : _sorted_standard_cargo_specs) { + if (HasBit(this->cargo_filter, cs->Index())) { + this->LowerWidget(WID_STL_CARGOSTART + index); + } + index++; } if (this->cargo_filter == this->cargo_filter_max) this->cargo_filter = _cargo_mask; @@ -396,8 +398,7 @@ public: /* Determine appropriate width for mini station rating graph */ this->rating_width = 0; - const CargoSpec *cs; - FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) { + for (const CargoSpec *cs : _sorted_standard_cargo_specs) { this->rating_width = std::max(this->rating_width, GetStringBoundingBox(cs->abbrev).width); } /* Approximately match original 16 pixel wide rating bars by multiplying string width by 1.6 */ @@ -465,8 +466,8 @@ public: x += rtl ? -text_spacing : text_spacing; /* show cargo waiting and station ratings */ - for (uint j = 0; j < _sorted_standard_cargo_specs_size; j++) { - CargoID cid = _sorted_cargo_specs[j]->Index(); + for (const CargoSpec *cs : _sorted_standard_cargo_specs) { + CargoID cid = cs->Index(); if (st->goods[cid].cargo.TotalCount() > 0) { /* For RTL we work in exactly the opposite direction. So * decrement the space needed first, then draw to the left @@ -581,7 +582,7 @@ public: break; case WID_STL_CARGOALL: { - for (uint i = 0; i < _sorted_standard_cargo_specs_size; i++) { + for (uint i = 0; i < _sorted_standard_cargo_specs.size(); i++) { this->LowerWidget(WID_STL_CARGOSTART + i); } this->LowerWidget(WID_STL_NOCARGOWAITING); @@ -607,7 +608,7 @@ public: this->include_empty = !this->include_empty; this->ToggleWidgetLoweredState(WID_STL_NOCARGOWAITING); } else { - for (uint i = 0; i < _sorted_standard_cargo_specs_size; i++) { + for (uint i = 0; i < _sorted_standard_cargo_specs.size(); i++) { this->RaiseWidget(WID_STL_CARGOSTART + i); } @@ -629,7 +630,7 @@ public: ToggleBit(this->cargo_filter, cs->Index()); this->ToggleWidgetLoweredState(widget); } else { - for (uint i = 0; i < _sorted_standard_cargo_specs_size; i++) { + for (uint i = 0; i < _sorted_standard_cargo_specs.size(); i++) { this->RaiseWidget(WID_STL_CARGOSTART + i); } this->RaiseWidget(WID_STL_NOCARGOWAITING); @@ -724,7 +725,7 @@ static NWidgetBase *CargoWidgets(int *biggest_index) { NWidgetHorizontal *container = new NWidgetHorizontal(); - for (uint i = 0; i < _sorted_standard_cargo_specs_size; i++) { + for (uint i = 0; i < _sorted_standard_cargo_specs.size(); i++) { NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_STL_CARGOSTART + i); panel->SetMinimalSize(14, 0); panel->SetMinimalTextLines(1, 0, FS_NORMAL); @@ -733,7 +734,7 @@ static NWidgetBase *CargoWidgets(int *biggest_index) panel->SetDataTip(0, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE); container->Add(panel); } - *biggest_index = WID_STL_CARGOSTART + _sorted_standard_cargo_specs_size; + *biggest_index = WID_STL_CARGOSTART + static_cast<int>(_sorted_standard_cargo_specs.size()); return container; } @@ -1859,8 +1860,7 @@ struct StationViewWindow : public Window { DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_STATION_VIEW_SUPPLY_RATINGS_TITLE); y += FONT_HEIGHT_NORMAL; - const CargoSpec *cs; - FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) { + for (const CargoSpec *cs : _sorted_standard_cargo_specs) { const GoodsEntry *ge = &st->goods[cs->Index()]; if (!ge->HasRating()) continue; |