diff options
author | Peter Nelson <peter1138@openttd.org> | 2021-04-28 21:50:46 +0100 |
---|---|---|
committer | PeterN <peter@fuzzle.org> | 2021-04-28 23:54:31 +0100 |
commit | 20ac0b41484ebcaef3f8bdc9d4410903fd499386 (patch) | |
tree | 2bb5c52a372de305061dd544303052bda8a75980 | |
parent | de81afdf4bfb97a48533489101e3aa0e5eb2cb4f (diff) | |
download | openttd-20ac0b41484ebcaef3f8bdc9d4410903fd499386.tar.xz |
Cleanup: Replace FOR_ALL_SORTED_CARGOSPECS macro with range iterator.
-rw-r--r-- | src/cargotype.cpp | 2 | ||||
-rw-r--r-- | src/cargotype.h | 7 | ||||
-rw-r--r-- | src/strings.cpp | 3 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 3 |
4 files changed, 3 insertions, 12 deletions
diff --git a/src/cargotype.cpp b/src/cargotype.cpp index e30b9899f..81818d5f9 100644 --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -181,7 +181,7 @@ void InitializeSortedCargoSpecs() _standard_cargo_mask = 0; _sorted_standard_cargo_specs_size = 0; - FOR_ALL_SORTED_CARGOSPECS(cargo) { + for (const auto &cargo : _sorted_cargo_specs) { if (cargo->classes & CC_SPECIAL) break; _sorted_standard_cargo_specs_size++; SetBit(_standard_cargo_mask, cargo->Index()); diff --git a/src/cargotype.h b/src/cargotype.h index f6b3eaead..afc501a2f 100644 --- a/src/cargotype.h +++ b/src/cargotype.h @@ -157,13 +157,6 @@ static inline bool IsCargoInClass(CargoID c, CargoClass cc) #define FOR_EACH_SET_CARGO_ID(var, cargo_bits) FOR_EACH_SET_BIT_EX(CargoID, var, CargoTypes, cargo_bits) /** - * Loop header for iterating over cargoes, sorted by name. This includes phony cargoes like regearing cargoes. - * @param var Reference getting the cargospec. - * @see CargoSpec - */ -#define FOR_ALL_SORTED_CARGOSPECS(var) for (uint8 index = 0; index < _sorted_cargo_specs.size() && (var = _sorted_cargo_specs[index], true) ; index++) - -/** * Loop header for iterating over 'real' cargoes, sorted by name. Phony cargoes like regearing cargoes are skipped. * @param var Reference getting the cargospec. * @see CargoSpec diff --git a/src/strings.cpp b/src/strings.cpp index d533db1fc..e340a2b1c 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1171,8 +1171,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg CargoTypes cmask = args->GetInt64(SCC_CARGO_LIST); bool first = true; - const CargoSpec *cs; - FOR_ALL_SORTED_CARGOSPECS(cs) { + for (const auto &cs : _sorted_cargo_specs) { if (!HasBit(cmask, cs->Index())) continue; if (buff >= last - 2) break; // ',' and ' ' diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index f4b518586..c6f2ee52a 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -513,8 +513,7 @@ struct RefitWindow : public Window { /* Loop through all cargoes in the refit mask */ int current_index = 0; - const CargoSpec *cs; - FOR_ALL_SORTED_CARGOSPECS(cs) { + for (const auto &cs : _sorted_cargo_specs) { CargoID cid = cs->Index(); /* Skip cargo type if it's not listed */ if (!HasBit(cmask, cid)) { |