(svn r22332) -Fix: When inserting automatic orders, do not create consecutive duplicate orders.

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
frosch 14 years ago
parent 8dd2f413bd
commit 74069dbda3

@ -1861,20 +1861,28 @@ void Vehicle::BeginLoading()
* to show that we are stopping here, but only do that if the order * to show that we are stopping here, but only do that if the order
* list isn't empty. */ * list isn't empty. */
Order *in_list = this->GetOrder(this->cur_auto_order_index); 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->IsType(OT_AUTOMATIC) ||
in_list->GetDestination() != this->last_station_visited) && in_list->GetDestination() != this->last_station_visited)) {
!suppress_automatic_orders && /* Do not create consecutive duplicates of automatic orders */
Order::CanAllocateItem()) { Order *prev_order = this->cur_auto_order_index > 0 ? this->GetOrder(this->cur_auto_order_index - 1) : NULL;
Order *auto_order = new Order(); if (prev_order == NULL ||
auto_order->MakeAutomatic(this->last_station_visited); (!prev_order->IsType(OT_AUTOMATIC) && !prev_order->IsType(OT_GOTO_STATION)) ||
InsertOrder(this, auto_order, this->cur_auto_order_index); prev_order->GetDestination() != this->last_station_visited) {
if (this->cur_auto_order_index > 0) --this->cur_auto_order_index;
if (!suppress_automatic_orders && this->orders.list->GetNumOrders() < MAX_VEH_ORDER_ID && Order::CanAllocateItem()) {
/* InsertOrder disabled creation of automatic orders for all vehicles with the same automatic order. /* Insert new automatic order */
* Reenable it for this vehicle */ Order *auto_order = new Order();
uint16 &gv_flags = this->GetGroundVehicleFlags(); auto_order->MakeAutomatic(this->last_station_visited);
ClrBit(gv_flags, GVF_SUPPRESS_AUTOMATIC_ORDERS); 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); this->current_order.MakeLoading(false);
} }

Loading…
Cancel
Save