# HG changeset patch # User maedhros # Date 1180795345 0 # Node ID b0ba7d1b90962acebe2e1e786f08dc8e5a759f33 # Parent 312113ee210af1f74abe9a618619d3918aa445c3 (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. diff -r 312113ee210a -r b0ba7d1b9096 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);