diff -r 58097db31633 -r 9825c7a74648 src/autoreplace_cmd.cpp --- a/src/autoreplace_cmd.cpp Tue Sep 04 19:58:18 2007 +0000 +++ b/src/autoreplace_cmd.cpp Wed Sep 05 09:31:15 2007 +0000 @@ -249,7 +249,8 @@ CommandCost tmp_move; if (old_v->type == VEH_TRAIN && IsFrontEngine(old_v)) { - Vehicle *next_veh = IsMultiheaded(old_v) ? old_v->Next()->Next() : old_v->Next(); + Vehicle *next_veh = GetNextVehicle(old_v); + if (IsMultiheaded(next_veh) && !IsTrainEngine(next_veh)) next_veh = next_veh->Next(); // don't try to move the rear multiheaded engine if (next_veh != NULL) { /* Verify that the wagons can be placed on the engine in question. * This is done by building an engine, test if the wagons can be added and then sell the test engine. */