summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-04-16 17:18:04 +0000
committerfrosch <frosch@openttd.org>2011-04-16 17:18:04 +0000
commit74069dbda31c7311f2f11b8ac31fa6c927e4b763 (patch)
tree1e701cd4009af606591acdba5a4764042115e84f /src
parent8dd2f413bd896983df15f7fe1d5cf019cfb0184e (diff)
downloadopenttd-74069dbda31c7311f2f11b8ac31fa6c927e4b763.tar.xz
(svn r22332) -Fix: When inserting automatic orders, do not create consecutive duplicate orders.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 8d3aac139..94a71da43 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1861,20 +1861,28 @@ void Vehicle::BeginLoading()
* to show that we are stopping here, but only do that if the order
* list isn't empty. */
Order *in_list = this->GetOrder(this->cur_auto_order_index);
- if (in_list != NULL && this->orders.list->GetNumOrders() < MAX_VEH_ORDER_ID &&
+ if (in_list != NULL &&
(!in_list->IsType(OT_AUTOMATIC) ||
- in_list->GetDestination() != this->last_station_visited) &&
- !suppress_automatic_orders &&
- Order::CanAllocateItem()) {
- Order *auto_order = new Order();
- auto_order->MakeAutomatic(this->last_station_visited);
- InsertOrder(this, auto_order, this->cur_auto_order_index);
- if (this->cur_auto_order_index > 0) --this->cur_auto_order_index;
-
- /* InsertOrder disabled creation of automatic orders for all vehicles with the same automatic order.
- * Reenable it for this vehicle */
- uint16 &gv_flags = this->GetGroundVehicleFlags();
- ClrBit(gv_flags, GVF_SUPPRESS_AUTOMATIC_ORDERS);
+ in_list->GetDestination() != this->last_station_visited)) {
+ /* Do not create consecutive duplicates of automatic orders */
+ Order *prev_order = this->cur_auto_order_index > 0 ? this->GetOrder(this->cur_auto_order_index - 1) : NULL;
+ if (prev_order == NULL ||
+ (!prev_order->IsType(OT_AUTOMATIC) && !prev_order->IsType(OT_GOTO_STATION)) ||
+ prev_order->GetDestination() != this->last_station_visited) {
+
+ if (!suppress_automatic_orders && this->orders.list->GetNumOrders() < MAX_VEH_ORDER_ID && Order::CanAllocateItem()) {
+ /* Insert new automatic order */
+ Order *auto_order = new Order();
+ auto_order->MakeAutomatic(this->last_station_visited);
+ InsertOrder(this, auto_order, this->cur_auto_order_index);
+ if (this->cur_auto_order_index > 0) --this->cur_auto_order_index;
+
+ /* InsertOrder disabled creation of automatic orders for all vehicles with the same automatic order.
+ * Reenable it for this vehicle */
+ uint16 &gv_flags = this->GetGroundVehicleFlags();
+ ClrBit(gv_flags, GVF_SUPPRESS_AUTOMATIC_ORDERS);
+ }
+ }
}
this->current_order.MakeLoading(false);
}