changeset 13076:955e6a7abd7b draft

(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
author rubidium <rubidium@openttd.org>
date Sat, 19 Sep 2009 13:55:37 +0000
parents 0a2c74e86245
children 7e8fe82936af
files src/train_cmd.cpp
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1159,6 +1159,15 @@
 				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)) {