From 4ee9de96fd431f0f955e0760fb16dab1b458b1a8 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 19 Sep 2009 13:55:37 +0000 Subject: [PATCH] (svn r17576) -Fix [FS#3208]: assertion triggered when the second vehicle in a 101+ (or 11+ if mammoth trains is disabled) vehicle free wagon chain is an engine and the first vehicle is moved to another chain --- src/train_cmd.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 280912a631..cf95284e00 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1159,6 +1159,15 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u if (dst_len < 0) return_cmd_error(STR_ERROR_TRAINS_CAN_ONLY_BE_ALTERED_INSIDE_A_DEPOT); } + if (src_head == src && !HasBit(p2, 0)) { + /* Moving of a *single* vehicle at the front of the train. + * If the next vehicle is an engine a new train will be created + * instead of removing a vehicle from a free chain. The newly + * created train may not be too long. */ + const Train *u = src_head->GetNextVehicle(); + if (u != NULL && u->IsEngine() && (src_len - 1) > max_len) return_cmd_error(STR_ERROR_TRAIN_TOO_LONG); + } + /* We are moving between rows, so only count the wagons from the source * row that are being moved. */ if (HasBit(p2, 0)) {