# HG changeset patch # User bjarni # Date 1180198844 0 # Node ID bfbaaa96b51bc3e16a124f5f3133917f21ad7ef1 # Parent 80f53cb28f3fa8c627bb1093be4bbbf9f63f61ef (svn r9938) -Fix [FS#799]: 100 wagons train + replace engine Replacing a unit in a train will now remove the old unit before adding the new one. This will solve issues when max train length has been reached diff -r 80f53cb28f3f -r bfbaaa96b51b src/autoreplace_cmd.cpp --- a/src/autoreplace_cmd.cpp Sat May 26 16:18:43 2007 +0000 +++ b/src/autoreplace_cmd.cpp Sat May 26 17:00:44 2007 +0000 @@ -195,9 +195,11 @@ * We add the new engine after the old one instead of replacing it. It will give the same result anyway when we * sell the old engine in a moment */ - DoCommand(0, (GetPrevVehicleInChain(old_v)->index << 16) | new_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); + Vehicle *front = GetPrevVehicleInChain(old_v); /* Now we move the old one out of the train */ DoCommand(0, (INVALID_VEHICLE << 16) | old_v->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); + /* Add the new vehicle */ + DoCommand(0, (front->index << 16) | new_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); } else { // copy/clone the orders DoCommand(0, (old_v->index << 16) | new_v->index, IsOrderListShared(old_v) ? CO_SHARE : CO_COPY, DC_EXEC, CMD_CLONE_ORDER);