train_cmd.c
changeset 2825 f81c0b099d69
parent 2819 710436dd4288
child 2826 dc6b11d88562
--- a/train_cmd.c	Fri Jan 06 17:45:43 2006 +0000
+++ b/train_cmd.c	Fri Jan 06 18:26:02 2006 +0000
@@ -958,6 +958,8 @@
 		if (dst->next == NULL) {
 			/* It's the last one, so we will add the wagon just before the rear engine */
 			dst = GetPrevVehicleInChain(dst);
+			/* Now if the vehicle we want to link to is the vehicle itself, drop out */
+			if (dst == src) return CMD_ERROR;
 			// if dst is NULL, it means that dst got a rear multiheaded engine as first engine. We can't use that
 			if (dst == NULL) return CMD_ERROR;
 		} else {