summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-19 13:55:37 +0000
committerrubidium <rubidium@openttd.org>2009-09-19 13:55:37 +0000
commit4ee9de96fd431f0f955e0760fb16dab1b458b1a8 (patch)
treec758e025ec3bdea10fa8ffa7c923f9b4baa83826
parent8d7498b82cdcfe8d647d7aae0adddc762fa8f3ce (diff)
downloadopenttd-4ee9de96fd431f0f955e0760fb16dab1b458b1a8.tar.xz
(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
-rw-r--r--src/train_cmd.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 280912a63..cf95284e0 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)) {