summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-03-12 19:40:16 +0000
committerfrosch <frosch@openttd.org>2009-03-12 19:40:16 +0000
commitafe547448ec06ac2ddc96812d3252ea7f00b780c (patch)
tree633a961a3c5a547dacb0208456ba46b623ab13c4 /src
parent684d1c4d4c40f6a2046cc52104b24385766bba74 (diff)
downloadopenttd-afe547448ec06ac2ddc96812d3252ea7f00b780c.tar.xz
(svn r15692) -Fix [FS#2721]: Just sell the old engines after autorenew/replace. Don't bother about trains exceeding the trainlimit, which will be sold anyway.
Diffstat (limited to 'src')
-rw-r--r--src/autoreplace_cmd.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 849d6d98e..e8e85b643 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -513,7 +513,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
*chain = new_head;
}
- /* Transfer cargo of old vehicles and sell them*/
+ /* Transfer cargo of old vehicles and sell them */
for (int i = 0; i < num_units; i++) {
Vehicle *w = old_vehs[i];
/* Is the vehicle again part of the new chain?
@@ -522,7 +522,10 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon
if ((flags & DC_EXEC) != 0) TransferCargo(w, new_head, true);
- cost.AddCost(DoCommand(0, w->index, 0, flags, GetCmdSellVeh(w)));
+ /* Sell the vehicle.
+ * Note: This might temporarly construct new trains, so use DC_AUTOREPLACE to prevent
+ * it from failing due to engine limits. */
+ cost.AddCost(DoCommand(0, w->index, 0, flags | DC_AUTOREPLACE, GetCmdSellVeh(w)));
if ((flags & DC_EXEC) != 0) {
old_vehs[i] = NULL;
if (i == 0) old_head = NULL;