Codechange: Use iteration when dealing with all HouseSpecs.

This commit is contained in:
Peter Nelson
2024-03-12 17:28:45 +00:00
committed by Michael Lutz
parent 3e83dcedfd
commit e16b982b6a
4 changed files with 43 additions and 42 deletions

View File

@@ -2504,12 +2504,11 @@ struct CargoesRow {
} else {
/* Houses only display what is demanded. */
for (uint i = 0; i < cargo_fld->u.cargo.num_cargoes; i++) {
for (uint h = 0; h < NUM_HOUSES; h++) {
HouseSpec *hs = HouseSpec::Get(h);
if (!hs->enabled) continue;
for (const auto &hs : HouseSpec::Specs()) {
if (!hs.enabled) continue;
for (uint j = 0; j < lengthof(hs->accepts_cargo); j++) {
if (hs->cargo_acceptance[j] > 0 && cargo_fld->u.cargo.vertical_cargoes[i] == hs->accepts_cargo[j]) {
for (uint j = 0; j < lengthof(hs.accepts_cargo); j++) {
if (hs.cargo_acceptance[j] > 0 && cargo_fld->u.cargo.vertical_cargoes[i] == hs.accepts_cargo[j]) {
cargo_fld->ConnectCargo(cargo_fld->u.cargo.vertical_cargoes[i], false);
goto next_cargo;
}
@@ -2724,12 +2723,11 @@ struct IndustryCargoesWindow : public Window {
for (uint i = 0; i < length; i++) {
if (!IsValidCargoID(cargoes[i])) continue;
for (uint h = 0; h < NUM_HOUSES; h++) {
HouseSpec *hs = HouseSpec::Get(h);
if (!hs->enabled || !(hs->building_availability & climate_mask)) continue;
for (const auto &hs : HouseSpec::Specs()) {
if (!hs.enabled || !(hs.building_availability & climate_mask)) continue;
for (uint j = 0; j < lengthof(hs->accepts_cargo); j++) {
if (hs->cargo_acceptance[j] > 0 && cargoes[i] == hs->accepts_cargo[j]) return true;
for (uint j = 0; j < lengthof(hs.accepts_cargo); j++) {
if (hs.cargo_acceptance[j] > 0 && cargoes[i] == hs.accepts_cargo[j]) return true;
}
}
}