mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 07:29:44 +00:00
(svn r16199) -Codechange: Pass OrderNonStopFlags also to MakeGoToDepotOrder().
-Fix: 'Go non-stop to nearest depot'-orders did not work wrt. the 'non-stop' part. -Fix: Adding 'Go to nearest depot'-orders did not respect the default setting for 'non-stop'.
This commit is contained in:
parent
a22ff74ef2
commit
d518b3d0ac
@ -340,10 +340,10 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
|
|||||||
* to a depot (other vehicle types). */
|
* to a depot (other vehicle types). */
|
||||||
if (::GetVehicle(vehicle_id)->type == VEH_AIRCRAFT) {
|
if (::GetVehicle(vehicle_id)->type == VEH_AIRCRAFT) {
|
||||||
if (!::IsTileType(destination, MP_STATION)) return false;
|
if (!::IsTileType(destination, MP_STATION)) return false;
|
||||||
order.MakeGoToDepot(::GetStationIndex(destination), odtf, odaf);
|
order.MakeGoToDepot(::GetStationIndex(destination), odtf, ONSF_STOP_EVERYWHERE, odaf);
|
||||||
} else {
|
} else {
|
||||||
if (::IsTileType(destination, MP_STATION)) return false;
|
if (::IsTileType(destination, MP_STATION)) return false;
|
||||||
order.MakeGoToDepot(::GetDepotByTile(destination)->index, odtf, odaf);
|
order.MakeGoToDepot(::GetDepotByTile(destination)->index, odtf, ONSF_STOP_EVERYWHERE, odaf);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -85,11 +85,12 @@ public:
|
|||||||
* Makes this order a Go To Depot order.
|
* Makes this order a Go To Depot order.
|
||||||
* @param destination the depot to go to.
|
* @param destination the depot to go to.
|
||||||
* @param order is this order a 'default' order, or an overriden vehicle order?
|
* @param order is this order a 'default' order, or an overriden vehicle order?
|
||||||
|
* @param non_stop_type how to get to the depot?
|
||||||
* @param action what to do in the depot?
|
* @param action what to do in the depot?
|
||||||
* @param cargo the cargo type to change to.
|
* @param cargo the cargo type to change to.
|
||||||
* @param subtype the subtype to change to.
|
* @param subtype the subtype to change to.
|
||||||
*/
|
*/
|
||||||
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderDepotActionFlags action = ODATF_SERVICE_ONLY, CargoID cargo = CT_NO_REFIT, byte subtype = 0);
|
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type = ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action = ODATF_SERVICE_ONLY, CargoID cargo = CT_NO_REFIT, byte subtype = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes this order a Go To Waypoint order.
|
* Makes this order a Go To Waypoint order.
|
||||||
|
@ -51,14 +51,12 @@ void Order::MakeGoToStation(StationID destination)
|
|||||||
this->dest = destination;
|
this->dest = destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Order::MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderDepotActionFlags action, CargoID cargo, byte subtype)
|
void Order::MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type, OrderDepotActionFlags action, CargoID cargo, byte subtype)
|
||||||
{
|
{
|
||||||
this->type = OT_GOTO_DEPOT;
|
this->type = OT_GOTO_DEPOT;
|
||||||
this->SetDepotOrderType(order);
|
this->SetDepotOrderType(order);
|
||||||
this->SetDepotActionType(action);
|
this->SetDepotActionType(action);
|
||||||
if (!(order & ODTFB_PART_OF_ORDERS)) {
|
this->SetNonStopType(non_stop_type);
|
||||||
this->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
|
||||||
}
|
|
||||||
this->dest = destination;
|
this->dest = destination;
|
||||||
this->SetRefit(cargo, subtype);
|
this->SetRefit(cargo, subtype);
|
||||||
}
|
}
|
||||||
@ -1644,7 +1642,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth)
|
|||||||
|
|
||||||
if (v->FindClosestDepot(&location, &destination, &reverse)) {
|
if (v->FindClosestDepot(&location, &destination, &reverse)) {
|
||||||
v->dest_tile = location;
|
v->dest_tile = location;
|
||||||
v->current_order.MakeGoToDepot(destination, v->current_order.GetDepotOrderType(), (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(), v->current_order.GetRefitSubtype());
|
||||||
|
|
||||||
/* If there is no depot in front, reverse automatically (trains only) */
|
/* 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_TRAIN && reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
|
||||||
|
@ -299,9 +299,9 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
|||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_company)) {
|
if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_company)) {
|
||||||
if (IsRailDepot(tile)) {
|
if (IsRailDepot(tile)) {
|
||||||
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
|
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS,
|
||||||
|
_settings_client.gui.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
|
||||||
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
||||||
if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,9 +309,9 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
|||||||
|
|
||||||
case MP_ROAD:
|
case MP_ROAD:
|
||||||
if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_company)) {
|
if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_company)) {
|
||||||
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
|
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS,
|
||||||
|
_settings_client.gui.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
|
||||||
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
||||||
if (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -319,7 +319,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
|||||||
case MP_STATION:
|
case MP_STATION:
|
||||||
if (v->type != VEH_AIRCRAFT) break;
|
if (v->type != VEH_AIRCRAFT) break;
|
||||||
if (IsHangar(tile) && IsTileOwner(tile, _local_company)) {
|
if (IsHangar(tile) && IsTileOwner(tile, _local_company)) {
|
||||||
order.MakeGoToDepot(GetStationIndex(tile), ODTFB_PART_OF_ORDERS);
|
order.MakeGoToDepot(GetStationIndex(tile), ODTFB_PART_OF_ORDERS, ONSF_STOP_EVERYWHERE);
|
||||||
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
|||||||
if (IsShipDepot(tile) && IsTileOwner(tile, _local_company)) {
|
if (IsShipDepot(tile) && IsTileOwner(tile, _local_company)) {
|
||||||
TileIndex tile2 = GetOtherShipDepotTile(tile);
|
TileIndex tile2 = GetOtherShipDepotTile(tile);
|
||||||
|
|
||||||
order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS);
|
order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS, ONSF_STOP_EVERYWHERE);
|
||||||
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
@ -507,7 +507,8 @@ private:
|
|||||||
Order order;
|
Order order;
|
||||||
order.next = NULL;
|
order.next = NULL;
|
||||||
order.index = 0;
|
order.index = 0;
|
||||||
order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS);
|
order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS,
|
||||||
|
_settings_client.gui.new_nonstop && (w->vehicle->type == VEH_TRAIN || w->vehicle->type == VEH_ROAD) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
|
||||||
order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
|
order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
|
||||||
|
|
||||||
DoCommandP(w->vehicle->tile, w->vehicle->index + (w->OrderGetSel() << 16), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
|
DoCommandP(w->vehicle->tile, w->vehicle->index + (w->OrderGetSel() << 16), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
|
||||||
|
Loading…
Reference in New Issue
Block a user