diff -r 358095cd3c51 -r d8790704c8b0 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);