# HG changeset patch # User frosch # Date 2015-10-30 16:18:39 # Node ID 4b9f3d9200bbcff9a407d8da6ec1464d724e471e # Parent 5a7dd7f2ecd333968aa63570c62b34169a440943 (svn r27419) -Fix [FS#6369]: CmdSellRailWagon did not revert all actions properly when no orderlist could be allocated. (Juanjo) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1386,13 +1386,15 @@ CommandCost CmdSellRailWagon(DoCommandFl return ret; } + 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); - if (first->orders.list == NULL && !OrderList::CanAllocateItem()) { - return_cmd_error(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS); - } - /* do it? */ if (flags & DC_EXEC) { /* First normalise the sub types of the chain. */