summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2011-02-08 18:21:55 +0000
committersmatz <smatz@openttd.org>2011-02-08 18:21:55 +0000
commit7af2470a78d73ac2953a6ed2eb36bca15c03d3e4 (patch)
treede4707a31de3d429795cb434d4411983e59b4119 /src
parent1d0d7635e08056acf0d0243b0b5ea5f39a5953e3 (diff)
downloadopenttd-7af2470a78d73ac2953a6ed2eb36bca15c03d3e4.tar.xz
(svn r22022) -Fix [FS#4468]: verify we can allocate an order before we actually try to do so
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 14f7c9bf4..ec78d8f42 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1849,7 +1849,8 @@ void Vehicle::BeginLoading()
Order *in_list = this->GetOrder(this->cur_auto_order_index);
if (in_list != NULL && this->orders.list->GetNumOrders() < MAX_VEH_ORDER_ID &&
(!in_list->IsType(OT_AUTOMATIC) ||
- in_list->GetDestination() != this->last_station_visited)) {
+ in_list->GetDestination() != this->last_station_visited) &&
+ Order::CanAllocateItem()) {
Order *auto_order = new Order();
auto_order->MakeAutomatic(this->last_station_visited);
InsertOrder(this, auto_order, this->cur_auto_order_index);
@@ -2226,7 +2227,7 @@ void Vehicle::AddToShared(Vehicle *shared_chain)
{
assert(this->previous_shared == NULL && this->next_shared == NULL);
- if (!shared_chain->orders.list) {
+ if (shared_chain->orders.list == NULL) {
assert(shared_chain->previous_shared == NULL);
assert(shared_chain->next_shared == NULL);
this->orders.list = shared_chain->orders.list = new OrderList(NULL, shared_chain);