Codechange: Add IsCargoAccepted/Produced() helpers.

This commit is contained in:
2023-05-24 00:52:44 +01:00
committed by PeterN
parent 633f19419d
commit 09408e8e46
9 changed files with 40 additions and 65 deletions

View File

@@ -1243,14 +1243,11 @@ static bool CDECL CargoFilter(const Industry * const *industry, const std::pair<
break;
case CF_NONE:
accepted_cargo_matches = std::all_of(std::begin((*industry)->accepts_cargo), std::end((*industry)->accepts_cargo), [](CargoID cargo) {
return !IsValidCargoID(cargo);
});
accepted_cargo_matches = !(*industry)->IsCargoAccepted();
break;
default:
const auto &ac = (*industry)->accepts_cargo;
accepted_cargo_matches = std::find(std::begin(ac), std::end(ac), accepted_cargo) != std::end(ac);
accepted_cargo_matches = (*industry)->IsCargoAccepted(accepted_cargo);
break;
}
@@ -1262,14 +1259,11 @@ static bool CDECL CargoFilter(const Industry * const *industry, const std::pair<
break;
case CF_NONE:
produced_cargo_matches = std::all_of(std::begin((*industry)->produced_cargo), std::end((*industry)->produced_cargo), [](CargoID cargo) {
return !IsValidCargoID(cargo);
});
produced_cargo_matches = !(*industry)->IsCargoProduced();
break;
default:
const auto &pc = (*industry)->produced_cargo;
produced_cargo_matches = std::find(std::begin(pc), std::end(pc), produced_cargo) != std::end(pc);
produced_cargo_matches = (*industry)->IsCargoProduced(produced_cargo);
break;
}