summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2007-05-26 17:00:44 +0000
committerbjarni <bjarni@openttd.org>2007-05-26 17:00:44 +0000
commit3963b48f17daa6c218d350e3136428b2b96c5f01 (patch)
tree76f63f11b13322e8e72c77222d23842a25b0f70e /src
parentba85ab33d6dbea92abc11aba4c3ea8bf2536e18e (diff)
downloadopenttd-3963b48f17daa6c218d350e3136428b2b96c5f01.tar.xz
(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
Diffstat (limited to 'src')
-rw-r--r--src/autoreplace_cmd.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 776320e04..5d1dce962 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -195,9 +195,11 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags, int32 total_cost)
* 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);