summaryrefslogtreecommitdiff
path: root/src/autoreplace_cmd.cpp
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2007-05-28 21:40:40 +0000
committerbjarni <bjarni@openttd.org>2007-05-28 21:40:40 +0000
commitbcb668c2ff482eaef7e01425267398df69c522e6 (patch)
treee7f1ab431b0a2d5ff6e50b4805c168c6833a0bdb /src/autoreplace_cmd.cpp
parent5ac10d4d2b3ba04ad7a0c5962f2a70836a968de1 (diff)
downloadopenttd-bcb668c2ff482eaef7e01425267398df69c522e6.tar.xz
(svn r9967) -Fix (r9938): autoreplace would in certain conditions move dualheaded engines in a train (usually to the rear)
-Change: moving an engine in between the two ends of a dualheaded engine will now move the rear dualheaded engine to the front of the newly added engine (instead of moving the new engine to the rear of the rear dualheaded engine) This can make a difference if there are wagons in the train
Diffstat (limited to 'src/autoreplace_cmd.cpp')
-rw-r--r--src/autoreplace_cmd.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 5d1dce962..6bcab4ca5 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -195,7 +195,10 @@ 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
*/
+ /* Get the vehicle in front of the one we move out */
Vehicle *front = GetPrevVehicleInChain(old_v);
+ /* If the vehicle in front is the rear end of a dualheaded engine, then we need to use the one in front of that one */
+ if (IsMultiheaded(front) && !IsTrainEngine(front)) front = GetPrevVehicleInChain(front);
/* 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 */