summaryrefslogtreecommitdiff
path: root/src/cargotype.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-07-16 20:40:06 +0000
committersmatz <smatz@openttd.org>2009-07-16 20:40:06 +0000
commit77d13eae6194387ca6ce2b0eb835b7f97f67d085 (patch)
treea15b28b9384b9590cf11866a877097709db4d89d /src/cargotype.cpp
parent665fa7f9c170774f6a640ecf381f714b50b6b174 (diff)
downloadopenttd-77d13eae6194387ca6ce2b0eb835b7f97f67d085.tar.xz
(svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
Diffstat (limited to 'src/cargotype.cpp')
-rw-r--r--src/cargotype.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/cargotype.cpp b/src/cargotype.cpp
index cf1acb45e..b239b9362 100644
--- a/src/cargotype.cpp
+++ b/src/cargotype.cpp
@@ -11,7 +11,7 @@
#include "table/strings.h"
#include "table/cargo_const.h"
-CargoSpec CargoSpec::cargo[NUM_CARGO];
+CargoSpec CargoSpec::array[NUM_CARGO];
/* Bitmask of cargo types available */
uint32 _cargo_mask;
@@ -22,8 +22,8 @@ void SetupCargoForClimate(LandscapeID l)
assert(l < lengthof(_default_climate_cargo));
/* Reset and disable all cargo types */
- memset(CargoSpec::cargo, 0, sizeof(CargoSpec::cargo));
- for (CargoID i = 0; i < lengthof(CargoSpec::cargo); i++) CargoSpec::Get(i)->bitnum = INVALID_CARGO;
+ memset(CargoSpec::array, 0, sizeof(CargoSpec::array));
+ for (CargoID i = 0; i < lengthof(CargoSpec::array); i++) CargoSpec::Get(i)->bitnum = INVALID_CARGO;
_cargo_mask = 0;
@@ -56,10 +56,9 @@ void SetupCargoForClimate(LandscapeID l)
CargoID GetCargoIDByLabel(CargoLabel cl)
{
- for (CargoID c = 0; c < lengthof(CargoSpec::cargo); c++) {
- CargoSpec *cargo = CargoSpec::Get(c);
- if (cargo->bitnum == INVALID_CARGO) continue;
- if (cargo->label == cl) return c;
+ CargoSpec *cs;
+ FOR_ALL_CARGOSPECS(cs) {
+ if (cs->label == cl) return cs->Index();
}
/* No matching label was found, so it is invalid */
@@ -75,8 +74,9 @@ CargoID GetCargoIDByBitnum(uint8 bitnum)
{
if (bitnum == INVALID_CARGO) return CT_INVALID;
- for (CargoID c = 0; c < lengthof(CargoSpec::cargo); c++) {
- if (CargoSpec::Get(c)->bitnum == bitnum) return c;
+ CargoSpec *cs;
+ FOR_ALL_CARGOSPECS(cs) {
+ if (cs->bitnum == bitnum) return cs->Index();
}
/* No matching label was found, so it is invalid */