(svn r10023) -Fix (r3218): When selling trains, if there were no wagons between multiheaded
authormaedhros
Sat, 02 Jun 2007 14:42:25 +0000
changeset 6785 b0ba7d1b9096
parent 6784 312113ee210a
child 6786 f938f80a255f
(svn r10023) -Fix (r3218): When selling trains, if there were no wagons between multiheaded
engines the rear part could be checked despite having already been deleted,
triggering an assert.
src/train_cmd.cpp
--- a/src/train_cmd.cpp	Sat Jun 02 11:15:38 2007 +0000
+++ b/src/train_cmd.cpp	Sat Jun 02 14:42:25 2007 +0000
@@ -1347,6 +1347,15 @@
 
 						if (rear != NULL) {
 							cost -= rear->value;
+
+							/* If this is a multiheaded vehicle with nothing
+							 * between the parts, tmp will be pointing to the
+							 * rear part, which is unlinked from the train and
+							 * deleted here. However, because tmp has already
+							 * been set it needs to be updated now so that the
+							 * loop never sees the rear part. */
+							if (tmp == rear) tmp = GetNextVehicle(tmp);
+
 							if (flags & DC_EXEC) {
 								first = UnlinkWagon(rear, first);
 								DeleteDepotHighlightOfVehicle(rear);