# HG changeset patch # User frosch # Date 2011-04-16 17:06:59 # Node ID 93c06b0d14314f366877db7ebcf0bfd1aeb02419 # Parent e1b7e68a1cb8acb86c552a301ef6a272acaacd67 (svn r22331) -Change: When inserting an (automatic) order A in front of an order B, disable modifications of automatic orders for all vehicles currently heading for B as we do not know whether they will reach A or B first. (except for the vehicle causing the insertion of the automatic order itself) diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -830,6 +830,13 @@ void InsertOrder(Vehicle *v, Order *new_ u->cur_real_order_index = cur; } } + if (sel_ord == u->cur_auto_order_index && u->IsGroundVehicle()) { + /* We are inserting an order just before the current automatic order. + * We do not know whether we will reach current automatic or the newly inserted order first. + * So, disable creation of automatic orders until we are on track again. */ + uint16 &gv_flags = u->GetGroundVehicleFlags(); + SetBit(gv_flags, GVF_SUPPRESS_AUTOMATIC_ORDERS); + } if (sel_ord <= u->cur_auto_order_index) { uint cur = u->cur_auto_order_index + 1; /* Check if we don't go out of bound */ diff --git a/src/vehicle.cpp b/src/vehicle.cpp --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1870,6 +1870,11 @@ void Vehicle::BeginLoading() 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); }