summaryrefslogtreecommitdiff
path: root/src/newgrf.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/newgrf.cpp
parent665fa7f9c170774f6a640ecf381f714b50b6b174 (diff)
downloadopenttd-77d13eae6194387ca6ce2b0eb835b7f97f67d085.tar.xz
(svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
Diffstat (limited to 'src/newgrf.cpp')
-rw-r--r--src/newgrf.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 9fd96ca40..df745c634 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -2994,13 +2994,11 @@ static CargoID TranslateCargo(uint8 feature, uint8 ctype)
return CT_INVALID;
}
- for (CargoID c = 0; c < NUM_CARGO; c++) {
- const CargoSpec *cs = CargoSpec::Get(c);
- if (!cs->IsValid()) continue;
-
+ const CargoSpec *cs;
+ FOR_ALL_CARGOSPECS(cs) {
if (cs->bitnum == ctype) {
- grfmsg(6, "TranslateCargo: Cargo bitnum %d mapped to cargo type %d.", ctype, c);
- return c;
+ grfmsg(6, "TranslateCargo: Cargo bitnum %d mapped to cargo type %d.", ctype, cs->Index());
+ return cs->Index();
}
}
@@ -5698,21 +5696,19 @@ static void CalculateRefitMasks()
}
} else {
/* No cargo table, so use the cargo bitnum values */
- for (CargoID c = 0; c < NUM_CARGO; c++) {
- const CargoSpec *cs = CargoSpec::Get(c);
- if (!cs->IsValid()) continue;
-
- if (HasBit(ei->refit_mask, cs->bitnum)) SetBit(xor_mask, c);
+ const CargoSpec *cs;
+ FOR_ALL_CARGOSPECS(cs) {
+ if (HasBit(ei->refit_mask, cs->bitnum)) SetBit(xor_mask, cs->Index());
}
}
}
if (_gted[engine].cargo_allowed != 0) {
/* Build up the list of cargo types from the set cargo classes. */
- for (CargoID i = 0; i < NUM_CARGO; i++) {
- const CargoSpec *cs = CargoSpec::Get(i);
- if (_gted[engine].cargo_allowed & cs->classes) SetBit(mask, i);
- if (_gted[engine].cargo_disallowed & cs->classes) SetBit(not_mask, i);
+ const CargoSpec *cs;
+ FOR_ALL_CARGOSPECS(cs) {
+ if (_gted[engine].cargo_allowed & cs->classes) SetBit(mask, cs->Index());
+ if (_gted[engine].cargo_disallowed & cs->classes) SetBit(not_mask, cs->Index());
}
} else if (xor_mask == 0) {
/* Don't apply default refit mask to wagons or engines with no capacity */