summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-08 17:25:32 +0000
committerfrosch <frosch@openttd.org>2011-11-08 17:25:32 +0000
commit449d6792304b1e6aa0ce6581d2f50f223545eff7 (patch)
tree6d71e5cb133e4e1d396ce572befe0d701dde986a
parentd8f8909f859eb900ceaf8897537b2f46d970b308 (diff)
downloadopenttd-449d6792304b1e6aa0ce6581d2f50f223545eff7.tar.xz
(svn r23143) -Change: [NewGRF v8] Return the translated cargobit in vehicle var 42.
-rw-r--r--src/newgrf_engine.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 48830240f..40d931d70 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -531,7 +531,10 @@ static uint32 VehicleGetVariable(Vehicle *v, const ResolverObject *object, byte
}
}
- uint8 common_bitnum = (common_cargo_type == CT_INVALID ? 0xFF : CargoSpec::Get(common_cargo_type)->bitnum);
+ /* Unlike everywhere else the cargo translation table is only used since grf version 8, not 7. */
+ const GRFFile *grffile = v->GetGRF();
+ uint8 common_bitnum = (common_cargo_type == CT_INVALID) ? 0xFF :
+ (grffile->grf_version < 8) ? CargoSpec::Get(common_cargo_type)->bitnum : grffile->cargo_map[common_cargo_type];
v->grf_cache.consist_cargo_information = cargo_classes | (common_bitnum << 8) | (common_subtype << 16) | (user_def_data << 24);
SetBit(v->grf_cache.cache_valid, NCVV_CONSIST_CARGO_INFORMATION);
}