summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-05-31 11:27:10 +0000
committerfrosch <frosch@openttd.org>2009-05-31 11:27:10 +0000
commitc64fdcbef2de637d9cd7ab1fdacb27b443c57513 (patch)
tree44b0ac17823bcaf2c04cf1ee5883e444a666a024
parent75a818a32540ee05a244aae368fb84bf08b1ffc7 (diff)
downloadopenttd-c64fdcbef2de637d9cd7ab1fdacb27b443c57513.tar.xz
(svn r16478) -Fix (r15378): Determining most common (sub-)cargo-type was broken due to someone confusing similiary named variables.
-rw-r--r--src/newgrf_engine.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index a85d2f376..9ea0152eb 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -523,13 +523,11 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
if (!HasBit(v->vcache.cache_valid, 2)) {
const Vehicle *u;
byte cargo_classes = 0;
- CargoID common_cargo_best = CT_INVALID;
uint8 common_cargos[NUM_CARGO];
- uint8 common_subtype_best = 0xFF; // Return 0xFF if nothing is carried
uint8 common_subtypes[256];
byte user_def_data = 0;
- CargoID common_cargo_type = CT_PASSENGERS;
- uint8 common_subtype = 0;
+ CargoID common_cargo_type = CT_INVALID;
+ uint8 common_subtype = 0xFF; // Return 0xFF if nothing is carried
/* Reset our arrays */
memset(common_cargos, 0, sizeof(common_cargos));
@@ -546,9 +544,10 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
}
/* Pick the most common cargo type */
+ uint common_cargo_best_amount = 0;
for (CargoID cargo = 0; cargo < NUM_CARGO; cargo++) {
- if (common_cargos[cargo] > common_cargo_best) {
- common_cargo_best = common_cargos[cargo];
+ if (common_cargos[cargo] > common_cargo_best_amount) {
+ common_cargo_best_amount = common_cargos[cargo];
common_cargo_type = cargo;
}
}
@@ -562,9 +561,10 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
}
/* Pick the most common subcargo type*/
+ uint common_subtype_best_amount = 0;
for (uint i = 0; i < lengthof(common_subtypes); i++) {
- if (common_subtypes[i] > common_subtype_best) {
- common_subtype_best = common_subtypes[i];
+ if (common_subtypes[i] > common_subtype_best_amount) {
+ common_subtype_best_amount = common_subtypes[i];
common_subtype = i;
}
}