From 5f57ea7198626ddfd6adb4f38681aec40c9bc634 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Mon, 16 Mar 2009 08:03:50 +0000 Subject: (svn r15739) -Codechange: Expose GRF ID of engines in var action property 0x25. --- src/newgrf_engine.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- cgit v1.2.3-70-g09d2