|
@@ -170,35 +170,35 @@ Order::Order(uint32 packed)
|
|
|
this->refit_subtype = 0;
|
|
|
this->wait_time = 0;
|
|
|
this->travel_time = 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* Updates the widgets of a vehicle which contains the order-data
|
|
|
*
|
|
|
*/
|
|
|
void InvalidateVehicleOrder(const Vehicle *v, int data)
|
|
|
{
|
|
|
InvalidateWindow(WC_VEHICLE_VIEW, v->index);
|
|
|
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
|
|
|
|
|
|
if (data != 0) {
|
|
|
/* Calls SetDirty() too */
|
|
|
InvalidateWindowData(WC_VEHICLE_ORDERS, v->index, data);
|
|
|
InvalidateWindowData(WC_VEHICLE_TIMETABLE, v->index, data);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
InvalidateWindow(WC_VEHICLE_ORDERS, v->index);
|
|
|
InvalidateWindow(WC_VEHICLE_TIMETABLE, v->index);
|
|
|
SetWindowDirty(WC_VEHICLE_ORDERS, v->index);
|
|
|
SetWindowDirty(WC_VEHICLE_TIMETABLE, v->index);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* Assign data to an order (from an other order)
|
|
|
* This function makes sure that the index is maintained correctly
|
|
|
*
|
|
|
*/
|
|
|
void Order::AssignOrder(const Order &other)
|
|
|
{
|
|
|
this->type = other.type;
|
|
|
this->flags = other.flags;
|
|
@@ -786,26 +786,26 @@ CommandCost CmdSkipToOrder(TileIndex til
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
v->cur_order_index = sel_ord;
|
|
|
|
|
|
if (v->type == VEH_ROAD) ClearSlot(RoadVehicle::From(v));
|
|
|
|
|
|
if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
|
|
|
|
|
|
InvalidateVehicleOrder(v, -2);
|
|
|
}
|
|
|
|
|
|
/* We have an aircraft/ship, they have a mini-schedule, so update them all */
|
|
|
if (v->type == VEH_AIRCRAFT) InvalidateWindowClasses(WC_AIRCRAFT_LIST);
|
|
|
if (v->type == VEH_SHIP) InvalidateWindowClasses(WC_SHIPS_LIST);
|
|
|
if (v->type == VEH_AIRCRAFT) SetWindowClassesDirty(WC_AIRCRAFT_LIST);
|
|
|
if (v->type == VEH_SHIP) SetWindowClassesDirty(WC_SHIPS_LIST);
|
|
|
|
|
|
return CommandCost();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Move an order inside the orderlist
|
|
|
* @param tile unused
|
|
|
* @param p1 the ID of the vehicle
|
|
|
* @param p2 order to move and target
|
|
|
* bit 0-15 : the order to move
|
|
|
* bit 16-31 : the target order
|
|
|
* @note The target order will move one place down in the orderlist
|
|
@@ -1506,25 +1506,25 @@ void RemoveOrderFromAllVehicles(OrderTyp
|
|
|
/* Aircraft have StationIDs for depot orders and never use DepotIDs
|
|
|
* This fact is handled specially below
|
|
|
*/
|
|
|
|
|
|
/* Go through all vehicles */
|
|
|
FOR_ALL_VEHICLES(v) {
|
|
|
Order *order;
|
|
|
|
|
|
order = &v->current_order;
|
|
|
if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type &&
|
|
|
v->current_order.GetDestination() == destination) {
|
|
|
order->MakeDummy();
|
|
|
InvalidateWindow(WC_VEHICLE_VIEW, v->index);
|
|
|
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
|
|
|
}
|
|
|
|
|
|
/* Clear the order from the order-list */
|
|
|
int id = -1;
|
|
|
FOR_VEHICLE_ORDERS(v, order) {
|
|
|
id++;
|
|
|
if (order->IsType(OT_GOTO_DEPOT) && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
|
|
|
if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type &&
|
|
|
order->GetDestination() == destination) {
|
|
|
order->MakeDummy();
|
|
|
for (const Vehicle *w = v->FirstShared(); w != NULL; w = w->NextShared()) {
|
|
|
/* In GUI, simulate by removing the order and adding it back */
|
|
@@ -1797,25 +1797,25 @@ bool ProcessOrders(Vehicle *v)
|
|
|
|
|
|
InvalidateVehicleOrder(v, -2);
|
|
|
switch (v->type) {
|
|
|
default:
|
|
|
NOT_REACHED();
|
|
|
|
|
|
case VEH_ROAD:
|
|
|
case VEH_TRAIN:
|
|
|
break;
|
|
|
|
|
|
case VEH_AIRCRAFT:
|
|
|
case VEH_SHIP:
|
|
|
InvalidateWindowClasses(GetWindowClassForVehicleType(v->type));
|
|
|
SetWindowClassesDirty(GetWindowClassForVehicleType(v->type));
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return UpdateOrderDest(v, order) && may_reverse;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check whether the given vehicle should stop at the given station
|
|
|
* based on this order and the non-stop settings.
|
|
|
* @param v the vehicle that might be stopping.
|
|
|
* @param station the station to stop at.
|
|
|
* @return true if the vehicle should stop.
|