summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-03-16 08:03:50 +0000
committerpeter1138 <peter1138@openttd.org>2009-03-16 08:03:50 +0000
commit5df06384d386fc5aaba40e951c39abb2b017b614 (patch)
treefa8da31f67bf93d5063a9796ddccb23893c801c6 /src
parentce4744e1d6637d0dec3766c5a827b43859396e58 (diff)
downloadopenttd-5df06384d386fc5aaba40e951c39abb2b017b614.tar.xz
(svn r15739) -Codechange: Expose GRF ID of engines in var action property 0x25.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index d1a300cf0..1f19b2f01 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -122,7 +122,8 @@ const GRFFile *GetEngineGRF(EngineID engine)
*/
uint32 GetEngineGRFID(EngineID engine)
{
- return GetEngineGRF(engine)->grfid;
+ const GRFFile *file = GetEngineGRF(engine);
+ return file == NULL ? 0 : file->grfid;
}
@@ -500,6 +501,9 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
/* Calculated vehicle parameters */
switch (variable) {
+ case 0x25: // Get engine GRF ID
+ return GetEngineGRFID(v->engine_type);
+
case 0x40: // Get length of consist
if (!HasBit(v->cache_valid, 0)) {
v->cached_var40 = PositionHelper(v, false);