summaryrefslogtreecommitdiff
path: root/src/cargotype.cpp
diff options
context:
space:
mode:
authorglx22 <glx@openttd.org>2021-04-29 17:51:05 +0200
committerLoïc Guilloux <glx22@users.noreply.github.com>2021-04-29 21:08:24 +0200
commit9a8756d7ed6fdde20bad9be8c8b8bc8fda0170f9 (patch)
tree54941350dff9cc05ee0e9b32e116df385f977a46 /src/cargotype.cpp
parent14e92bd8e241998ced263ee542965a71bbdd77a5 (diff)
downloadopenttd-9a8756d7ed6fdde20bad9be8c8b8bc8fda0170f9.tar.xz
Codechange: Replace FOR_ALL_CARGOSPECS with range-based for loops
Diffstat (limited to 'src/cargotype.cpp')
-rw-r--r--src/cargotype.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/cargotype.cpp b/src/cargotype.cpp
index 81818d5f9..bf9561dda 100644
--- a/src/cargotype.cpp
+++ b/src/cargotype.cpp
@@ -84,8 +84,7 @@ void SetupCargoForClimate(LandscapeID l)
*/
CargoID GetCargoIDByLabel(CargoLabel cl)
{
- const CargoSpec *cs;
- FOR_ALL_CARGOSPECS(cs) {
+ for (const CargoSpec *cs : CargoSpec::Iterate()) {
if (cs->label == cl) return cs->Index();
}
@@ -103,8 +102,7 @@ CargoID GetCargoIDByBitnum(uint8 bitnum)
{
if (bitnum == INVALID_CARGO) return CT_INVALID;
- const CargoSpec *cs;
- FOR_ALL_CARGOSPECS(cs) {
+ for (const CargoSpec *cs : CargoSpec::Iterate()) {
if (cs->bitnum == bitnum) return cs->Index();
}
@@ -132,7 +130,6 @@ SpriteID CargoSpec::GetCargoIcon() const
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.
-
/** Sort cargo specifications by their name. */
static bool CargoSpecNameSorter(const CargoSpec * const &a, const CargoSpec * const &b)
{
@@ -169,9 +166,8 @@ static bool CargoSpecClassSorter(const CargoSpec * const &a, const CargoSpec * c
void InitializeSortedCargoSpecs()
{
_sorted_cargo_specs.clear();
- const CargoSpec *cargo;
/* Add each cargo spec to the list. */
- FOR_ALL_CARGOSPECS(cargo) {
+ for (const CargoSpec *cargo : CargoSpec::Iterate()) {
_sorted_cargo_specs.push_back(cargo);
}