Fix #10430, Fix 6ba55e6: display chain window causing assert

This commit is contained in:
Rubidium 2023-01-29 16:48:00 +01:00 committed by rubidium42
parent 6ba55e663e
commit 8be908c919
1 changed files with 14 additions and 14 deletions

View File

@ -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);