From 364ef8e6e6342f8f777da561571422c8c57c402b Mon Sep 17 00:00:00 2001 From: smatz Date: Tue, 8 Feb 2011 18:29:30 +0000 Subject: (svn r22024) -Fix [FS#4468]: verify we can allocate an OrderList before we actually try to do so (Rubidium) --- src/order_cmd.cpp | 4 ++++ src/train_cmd.cpp | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'src') diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 3a6f59f20..4f97c782b 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -1389,6 +1389,10 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } } + if (src->orders.list == NULL && !OrderList::CanAllocateItem()) { + return_cmd_error(STR_ERROR_NO_MORE_SPACE_FOR_ORDERS); + } + if (flags & DC_EXEC) { /* If the destination vehicle had a OrderList, destroy it */ DeleteVehicleOrders(dst); diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 61cd3ca5e..9746fd403 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1332,6 +1332,10 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16 data, uint3 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. */ -- cgit v1.2.3-70-g09d2