From ae16df2d61e66d8e41bdbf1b643a8886323c8915 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 14 Apr 2024 23:39:25 +0100 Subject: [PATCH] Fix #12497: Add workaround for motion_counter being implemented correctly. #12229 stopped updating motion_counter for non-engine parts of trains, and in doing so accidentally followed the spec for NewGRF var 46, which breaks NewGRFs that used to... accidentally work. Make var 46 return motion_counter of the first engine, regardless of self or parent scope. This means var 46 is always in sync with the head engine, and avoids further changes to when motion_counter is updated. (cherry picked from commit 9539b02455f672e11f3ac32302a00cffa5507770) --- src/newgrf_engine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index dd883425b0..aaf9e61160 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -680,7 +680,7 @@ static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *objec } case 0x46: // Motion counter - return v->motion_counter; + return v->First()->motion_counter; case 0x47: { // Vehicle cargo info /* Format: ccccwwtt