From 8be908c9191a51981e5e0cd45858423e00b33538 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sun, 29 Jan 2023 16:48:00 +0100 Subject: [PATCH] Fix #10430, Fix 6ba55e6: display chain window causing assert --- src/industry_gui.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 01a76810b9..f973ee7ed2 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -2760,12 +2760,12 @@ struct IndustryCargoesWindow : public Window { _displayed_industries.set(displayed_it); this->fields.clear(); - CargoesRow &row = this->fields.emplace_back(); - row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS); - row.columns[1].MakeEmpty(CFT_SMALL_EMPTY); - row.columns[2].MakeEmpty(CFT_SMALL_EMPTY); - row.columns[3].MakeEmpty(CFT_SMALL_EMPTY); - row.columns[4].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS); + CargoesRow &first_row = this->fields.emplace_back(); + first_row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS); + first_row.columns[1].MakeEmpty(CFT_SMALL_EMPTY); + first_row.columns[2].MakeEmpty(CFT_SMALL_EMPTY); + first_row.columns[3].MakeEmpty(CFT_SMALL_EMPTY); + first_row.columns[4].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS); const IndustrySpec *central_sp = GetIndustrySpec(displayed_it); bool houses_supply = HousesCanSupply(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo)); @@ -2775,7 +2775,7 @@ struct IndustryCargoesWindow : public Window { int num_cust = CountMatchingAcceptingIndustries(central_sp->produced_cargo, lengthof(central_sp->produced_cargo)) + houses_accept; int num_indrows = std::max(3, std::max(num_supp, num_cust)); // One is needed for the 'it' industry, and 2 for the cargo labels. for (int i = 0; i < num_indrows; i++) { - row = this->fields.emplace_back(); + CargoesRow &row = this->fields.emplace_back(); row.columns[0].MakeEmpty(CFT_EMPTY); row.columns[1].MakeCargo(central_sp->accepts_cargo, lengthof(central_sp->accepts_cargo)); row.columns[2].MakeEmpty(CFT_EMPTY); @@ -2837,12 +2837,12 @@ struct IndustryCargoesWindow : public Window { _displayed_industries.reset(); this->fields.clear(); - CargoesRow &row = this->fields.emplace_back(); - row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS); - row.columns[1].MakeEmpty(CFT_SMALL_EMPTY); - row.columns[2].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS); - row.columns[3].MakeEmpty(CFT_SMALL_EMPTY); - row.columns[4].MakeEmpty(CFT_SMALL_EMPTY); + CargoesRow &first_row = this->fields.emplace_back(); + first_row.columns[0].MakeHeader(STR_INDUSTRY_CARGOES_PRODUCERS); + first_row.columns[1].MakeEmpty(CFT_SMALL_EMPTY); + first_row.columns[2].MakeHeader(STR_INDUSTRY_CARGOES_CUSTOMERS); + first_row.columns[3].MakeEmpty(CFT_SMALL_EMPTY); + first_row.columns[4].MakeEmpty(CFT_SMALL_EMPTY); bool houses_supply = HousesCanSupply(&cid, 1); bool houses_accept = HousesCanAccept(&cid, 1); @@ -2850,7 +2850,7 @@ struct IndustryCargoesWindow : public Window { int num_cust = CountMatchingAcceptingIndustries(&cid, 1) + houses_accept; int num_indrows = std::max(num_supp, num_cust); for (int i = 0; i < num_indrows; i++) { - row = this->fields.emplace_back(); + CargoesRow &row = this->fields.emplace_back(); row.columns[0].MakeEmpty(CFT_EMPTY); row.columns[1].MakeCargo(&cid, 1); row.columns[2].MakeEmpty(CFT_EMPTY);