From d68c4bbd2fce3fb67a96660c9cbdc0b6e5f5ac7b Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 9 May 2023 12:50:37 +0100 Subject: [PATCH] Change: Use iterator when drawing industry cargo window. --- src/industry_gui.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 6e06888501..9b05beaddf 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -2935,8 +2935,8 @@ struct IndustryCargoesWindow : public Window { const NWidgetBase *nwp = this->GetWidget(WID_IC_PANEL); int vpos = WidgetDimensions::scaled.frametext.top - WidgetDimensions::scaled.bevel.top - this->vscroll->GetPosition() * nwp->resize_y; - for (uint i = 0; i < this->fields.size(); i++) { - int row_height = (i == 0) ? CargoesField::small_height : CargoesField::normal_height; + int row_height = CargoesField::small_height; + for (const auto &field : this->fields) { if (vpos + row_height >= 0) { int xpos = left_pos; int col, dir; @@ -2948,13 +2948,14 @@ struct IndustryCargoesWindow : public Window { dir = 1; } while (col >= 0 && col <= last_column) { - this->fields[i].columns[col].Draw(xpos, vpos); + field.columns[col].Draw(xpos, vpos); xpos += (col & 1) ? CargoesField::cargo_field_width : CargoesField::industry_width; col += dir; } } vpos += row_height; if (vpos >= height) break; + row_height = CargoesField::normal_height; } }