diff options
author | glx22 <glx@openttd.org> | 2021-06-13 02:41:41 +0200 |
---|---|---|
committer | Loïc Guilloux <glx22@users.noreply.github.com> | 2021-07-09 21:36:09 +0200 |
commit | 5844027eb8588197d82fe896f027182621c4f923 (patch) | |
tree | 1c7def8d614ade7d98ab97d42651a152b34eafe7 /src/cargotype.cpp | |
parent | 87eb997be0ffb8a62f31ed222e41a10a2622437f (diff) | |
download | openttd-5844027eb8588197d82fe896f027182621c4f923.tar.xz |
Codechange: Remove FOR_ALL_SORTED_STANDARD_CARGOSPECS
Diffstat (limited to 'src/cargotype.cpp')
-rw-r--r-- | src/cargotype.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/cargotype.cpp b/src/cargotype.cpp index a6ea680d8..e35c94d2f 100644 --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -149,8 +149,8 @@ SpriteID CargoSpec::GetCargoIcon() const return sprite; } -std::vector<const CargoSpec *> _sorted_cargo_specs; ///< Cargo specifications sorted alphabetically by name. -uint8 _sorted_standard_cargo_specs_size; ///< Number of standard cargo specifications stored in the _sorted_cargo_specs array. +std::vector<const CargoSpec *> _sorted_cargo_specs; ///< Cargo specifications sorted alphabetically by name. +span<const CargoSpec *> _sorted_standard_cargo_specs; ///< Standard cargo specifications sorted alphabetically by name. /** Sort cargo specifications by their name. */ static bool CargoSpecNameSorter(const CargoSpec * const &a, const CargoSpec * const &b) @@ -196,13 +196,16 @@ void InitializeSortedCargoSpecs() /* Sort cargo specifications by cargo class and name. */ std::sort(_sorted_cargo_specs.begin(), _sorted_cargo_specs.end(), &CargoSpecClassSorter); + /* Count the number of standard cargos and fill the mask. */ _standard_cargo_mask = 0; - - _sorted_standard_cargo_specs_size = 0; + uint8 nb_standard_cargo = 0; for (const auto &cargo : _sorted_cargo_specs) { if (cargo->classes & CC_SPECIAL) break; - _sorted_standard_cargo_specs_size++; + nb_standard_cargo++; SetBit(_standard_cargo_mask, cargo->Index()); } + + /* _sorted_standard_cargo_specs is a subset of _sorted_cargo_specs. */ + _sorted_standard_cargo_specs = { _sorted_cargo_specs.data(), nb_standard_cargo }; } |