|
@@ -80,22 +80,21 @@ void Order::MakeGoToStation(StationID de
|
|
|
* Makes this order a Go To Depot order.
|
|
|
* @param destination the depot to go to.
|
|
|
* @param order is this order a 'default' order, or an overridden vehicle order?
|
|
|
* @param non_stop_type how to get to the depot?
|
|
|
* @param action what to do in the depot?
|
|
|
* @param cargo the cargo type to change to.
|
|
|
* @param subtype the subtype to change to.
|
|
|
*/
|
|
|
void Order::MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type, OrderDepotActionFlags action, CargoID cargo, byte subtype)
|
|
|
void Order::MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type, OrderDepotActionFlags action, CargoID cargo)
|
|
|
{
|
|
|
this->type = OT_GOTO_DEPOT;
|
|
|
this->SetDepotOrderType(order);
|
|
|
this->SetDepotActionType(action);
|
|
|
this->SetNonStopType(non_stop_type);
|
|
|
this->dest = destination;
|
|
|
this->SetRefit(cargo, subtype);
|
|
|
this->SetRefit(cargo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Makes this order a Go To Waypoint order.
|
|
|
* @param destination the waypoint to go to.
|
|
|
*/
|
|
@@ -155,19 +154,17 @@ void Order::MakeImplicit(StationID desti
|
|
|
this->dest = destination;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Make this depot/station order also a refit order.
|
|
|
* @param cargo the cargo type to change to.
|
|
|
* @param subtype the subtype to change to.
|
|
|
* @pre IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION).
|
|
|
*/
|
|
|
void Order::SetRefit(CargoID cargo, byte subtype)
|
|
|
void Order::SetRefit(CargoID cargo)
|
|
|
{
|
|
|
this->refit_cargo = cargo;
|
|
|
this->refit_subtype = subtype;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Does this order have the same type, flags and destination?
|
|
|
* @param other the second order to compare to.
|
|
|
* @return true if the type, flags and destination match.
|
|
@@ -235,13 +232,12 @@ Order::Order(uint32 packed)
|
|
|
{
|
|
|
this->type = (OrderType)GB(packed, 0, 8);
|
|
|
this->flags = GB(packed, 8, 8);
|
|
|
this->dest = GB(packed, 16, 16);
|
|
|
this->next = NULL;
|
|
|
this->refit_cargo = CT_NO_REFIT;
|
|
|
this->refit_subtype = 0;
|
|
|
this->wait_time = 0;
|
|
|
this->travel_time = 0;
|
|
|
this->max_speed = UINT16_MAX;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -275,13 +271,12 @@ void Order::AssignOrder(const Order &oth
|
|
|
{
|
|
|
this->type = other.type;
|
|
|
this->flags = other.flags;
|
|
|
this->dest = other.dest;
|
|
|
|
|
|
this->refit_cargo = other.refit_cargo;
|
|
|
this->refit_subtype = other.refit_subtype;
|
|
|
|
|
|
this->wait_time = other.wait_time;
|
|
|
this->travel_time = other.travel_time;
|
|
|
this->max_speed = other.max_speed;
|
|
|
}
|
|
|
|
|
@@ -1584,23 +1579,21 @@ CommandCost CmdCloneOrder(TileIndex tile
|
|
|
* Add/remove refit orders from an order
|
|
|
* @param tile Not used
|
|
|
* @param flags operation to perform
|
|
|
* @param p1 VehicleIndex of the vehicle having the order
|
|
|
* @param p2 bitmask
|
|
|
* - bit 0-7 CargoID
|
|
|
* - bit 8-15 Cargo subtype
|
|
|
* - bit 16-23 number of order to modify
|
|
|
* @param text unused
|
|
|
* @return the cost of this operation or an error
|
|
|
*/
|
|
|
CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
{
|
|
|
VehicleID veh = GB(p1, 0, 20);
|
|
|
VehicleOrderID order_number = GB(p2, 16, 8);
|
|
|
CargoID cargo = GB(p2, 0, 8);
|
|
|
byte subtype = GB(p2, 8, 8);
|
|
|
|
|
|
if (cargo >= NUM_CARGO && cargo != CT_NO_REFIT && cargo != CT_AUTO_REFIT) return CMD_ERROR;
|
|
|
|
|
|
const Vehicle *v = Vehicle::GetIfValid(veh);
|
|
|
if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
|
|
|
|
|
@@ -1613,13 +1606,13 @@ CommandCost CmdOrderRefit(TileIndex tile
|
|
|
/* Automatic refit cargo is only supported for goto station orders. */
|
|
|
if (cargo == CT_AUTO_REFIT && !order->IsType(OT_GOTO_STATION)) return CMD_ERROR;
|
|
|
|
|
|
if (order->GetLoadType() & OLFB_NO_LOAD) return CMD_ERROR;
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
order->SetRefit(cargo, subtype);
|
|
|
order->SetRefit(cargo);
|
|
|
|
|
|
/* Make the depot order an 'always go' order. */
|
|
|
if (cargo != CT_NO_REFIT && order->IsType(OT_GOTO_DEPOT)) {
|
|
|
order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() & ~ODTFB_SERVICE));
|
|
|
order->SetDepotActionType((OrderDepotActionFlags)(order->GetDepotActionType() & ~ODATFB_HALT));
|
|
|
}
|
|
@@ -1627,13 +1620,13 @@ CommandCost CmdOrderRefit(TileIndex tile
|
|
|
for (Vehicle *u = v->FirstShared(); u != NULL; u = u->NextShared()) {
|
|
|
/* Update any possible open window of the vehicle */
|
|
|
InvalidateVehicleOrder(u, VIWD_MODIFY_ORDERS);
|
|
|
|
|
|
/* If the vehicle already got the current depot set as current order, then update current order as well */
|
|
|
if (u->cur_real_order_index == order_number && (u->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) {
|
|
|
u->current_order.SetRefit(cargo, subtype);
|
|
|
u->current_order.SetRefit(cargo);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return CommandCost();
|
|
|
}
|
|
@@ -1929,13 +1922,13 @@ bool UpdateOrderDest(Vehicle *v, const O
|
|
|
|
|
|
if (v->FindClosestDepot(&location, &destination, &reverse)) {
|
|
|
/* PBS reservations cannot reverse */
|
|
|
if (pbs_look_ahead && reverse) return false;
|
|
|
|
|
|
v->dest_tile = location;
|
|
|
v->current_order.MakeGoToDepot(destination, v->current_order.GetDepotOrderType(), v->current_order.GetNonStopType(), (OrderDepotActionFlags)(v->current_order.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT), v->current_order.GetRefitCargo(), v->current_order.GetRefitSubtype());
|
|
|
v->current_order.MakeGoToDepot(destination, v->current_order.GetDepotOrderType(), v->current_order.GetNonStopType(), (OrderDepotActionFlags)(v->current_order.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT), v->current_order.GetRefitCargo());
|
|
|
|
|
|
/* If there is no depot in front, reverse automatically (trains only) */
|
|
|
if (v->type == VEH_TRAIN && reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
|
|
|
|
|
|
if (v->type == VEH_AIRCRAFT) {
|
|
|
Aircraft *a = Aircraft::From(v);
|