summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-12-12 19:31:47 +0000
committerfrosch <frosch@openttd.org>2011-12-12 19:31:47 +0000
commit686f51d810f9fa8303639c979f0ba76f1993ce9b (patch)
tree6960d58f3e7c82dc092247b1c2189313d140a488 /src
parent44dc83b73fbf0e9832576d62a7e4ef0f1f110b83 (diff)
downloadopenttd-686f51d810f9fa8303639c979f0ba76f1993ce9b.tar.xz
(svn r23503) -Fix (r23143): Desync debug wants to resolve vehicle variables of vehicles without NewGRF. So, let it.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 35f6b44c4..5e5ba91a9 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -540,10 +540,12 @@ static uint32 VehicleGetVariable(Vehicle *v, const ResolverObject *object, byte
/* The cargo translation is specific to the accessing GRF, and thus cannot be cached. */
CargoID common_cargo_type = (v->grf_cache.consist_cargo_information >> 8) & 0xFF;
- /* Unlike everywhere else the cargo translation table is only used since grf version 8, not 7. */
+ /* Unlike everywhere else the cargo translation table is only used since grf version 8, not 7.
+ * Note: The grffile == NULL case only happens if this function is called for default vehicles.
+ * And this is only done by CheckCaches(). */
const GRFFile *grffile = object->grffile;
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];
+ (grffile == NULL || grffile->grf_version < 8) ? CargoSpec::Get(common_cargo_type)->bitnum : grffile->cargo_map[common_cargo_type];
return (v->grf_cache.consist_cargo_information & 0xFFFF00FF) | common_bitnum << 8;
}