summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-10-30 16:18:39 +0000
committerfrosch <frosch@openttd.org>2015-10-30 16:18:39 +0000
commit378653100bb3d0b1f3ff7f7ac0fa10b1af085ed8 (patch)
treeaa5eede25db8a6c7ad5397281ba26d869201ef79 /src/train_cmd.cpp
parent22e6a2590d3955e86af609e2a1f103b663da25c8 (diff)
downloadopenttd-378653100bb3d0b1f3ff7f7ac0fa10b1af085ed8.tar.xz
(svn r27419) -Fix [FS#6369]: CmdSellRailWagon did not revert all actions properly when no orderlist could be allocated. (Juanjo)
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 8f20973b3..6f2feeaab 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1386,13 +1386,15 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16 data, uint3
return ret;
}
- CommandCost cost(EXPENSES_NEW_VEHICLES);
- for (Train *t = sell_head; t != NULL; t = t->Next()) cost.AddCost(-t->value);
-
if (first->orders.list == NULL && !OrderList::CanAllocateItem()) {
+ /* Restore the train we had. */
+ RestoreTrainBackup(original);
return_cmd_error(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS);
}
+ CommandCost cost(EXPENSES_NEW_VEHICLES);
+ for (Train *t = sell_head; t != NULL; t = t->Next()) cost.AddCost(-t->value);
+
/* do it? */
if (flags & DC_EXEC) {
/* First normalise the sub types of the chain. */