From 979704271bfbe3759fdc0aefb5361b04996107ab Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 9 Jul 2022 12:28:20 +0200 Subject: [PATCH] Fix: reverse train direction command did not validate the given vehicle properly (#9947) You could give a wagon in the chain to reverse (which makes no functional sense ofc). In result, only parts of the vehicle were reversing, leading to weird crashes. --- src/train_cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 2af665a4a6..983b5ccd1c 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1936,6 +1936,7 @@ CommandCost CmdReverseTrainDirection(DoCommandFlag flags, VehicleID veh_id, bool } } else { /* turn the whole train around */ + if (!v->IsPrimaryVehicle()) return CMD_ERROR; if ((v->vehstatus & VS_CRASHED) || v->breakdown_ctr != 0) return CMD_ERROR; if (flags & DC_EXEC) {