Changeset - r26466:938bcd34baa7
[Not reviewed]
master
0 6 0
Nicolas Chappe - 23 months ago 2022-07-26 16:27:54
74881848+nchappe@users.noreply.github.com
Codechange: Always set the ODATFB_NEAREST_DEPOT flag for 'any depot' orders
6 files changed with 12 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/depot_type.h
Show inline comments
 
@@ -10,9 +10,13 @@
 
#ifndef DEPOT_TYPE_H
 
#define DEPOT_TYPE_H
 

	
 
typedef uint16 DepotID; ///< Type for the unique identifier of depots.
 
#include "station_type.h"
 

	
 
typedef StationID DepotID; ///< Type for the unique identifier of depots.
 
struct Depot;
 

	
 
static const DepotID INVALID_DEPOT = INVALID_STATION;
 

	
 
static const uint MAX_LENGTH_DEPOT_NAME_CHARS = 32; ///< The maximum length of a depot name in characters including '\0'
 

	
 
#endif /* DEPOT_TYPE_H */
src/order_cmd.cpp
Show inline comments
 
@@ -656,7 +656,7 @@ void OrderList::DebugCheckSanity() const
 
static inline bool OrderGoesToStation(const Vehicle *v, const Order *o)
 
{
 
	return o->IsType(OT_GOTO_STATION) ||
 
			(v->type == VEH_AIRCRAFT && o->IsType(OT_GOTO_DEPOT) && !(o->GetDepotActionType() & ODATFB_NEAREST_DEPOT));
 
			(v->type == VEH_AIRCRAFT && o->IsType(OT_GOTO_DEPOT) && o->GetDestination() != INVALID_STATION);
 
}
 

	
 
/**
 
@@ -690,7 +690,7 @@ TileIndex Order::GetLocation(const Vehic
 
			return BaseStation::Get(this->GetDestination())->xy;
 

	
 
		case OT_GOTO_DEPOT:
 
			if ((this->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) return INVALID_TILE;
 
			if (this->GetDestination() == INVALID_DEPOT) return INVALID_TILE;
 
			return (v->type == VEH_AIRCRAFT) ? Station::Get(this->GetDestination())->xy : Depot::Get(this->GetDestination())->xy;
 

	
 
		default:
 
@@ -1991,7 +1991,7 @@ bool UpdateOrderDest(Vehicle *v, const O
 
					if (pbs_look_ahead && reverse) return false;
 

	
 
					v->SetDestTile(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.SetDestination(destination);
 

	
 
					/* If there is no depot in front, reverse automatically (trains only) */
 
					if (v->type == VEH_TRAIN && reverse) Command<CMD_REVERSE_TRAIN_DIRECTION>::Do(DC_EXEC, v->index, false);
src/order_gui.cpp
Show inline comments
 
@@ -619,7 +619,7 @@ private:
 
		Order order;
 
		order.next = nullptr;
 
		order.index = 0;
 
		order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS,
 
		order.MakeGoToDepot(INVALID_DEPOT, ODTFB_PART_OF_ORDERS,
 
				_settings_client.gui.new_nonstop && this->vehicle->IsGroundVehicle() ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
 
		order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
 

	
src/script/api/script_order.cpp
Show inline comments
 
@@ -470,7 +470,7 @@ static int ScriptOrderPositionToRealOrde
 
			if (order_flags & OF_GOTO_NEAREST_DEPOT) odaf |= ODATFB_NEAREST_DEPOT;
 
			OrderNonStopFlags onsf = (OrderNonStopFlags)((order_flags & OF_NON_STOP_INTERMEDIATE) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
 
			if (order_flags & OF_GOTO_NEAREST_DEPOT) {
 
				order.MakeGoToDepot(0, odtf, onsf, odaf);
 
				order.MakeGoToDepot(INVALID_DEPOT, odtf, onsf, odaf);
 
			} else {
 
				/* Check explicitly if the order is to a station (for aircraft) or
 
				 * to a depot (other vehicle types). */
src/train_cmd.cpp
Show inline comments
 
@@ -3974,7 +3974,7 @@ static void CheckIfTrainNeedsService(Tra
 
	}
 

	
 
	SetBit(v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS);
 
	v->current_order.MakeGoToDepot(depot, ODTFB_SERVICE);
 
	v->current_order.MakeGoToDepot(depot, ODTFB_SERVICE, ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, ODATFB_NEAREST_DEPOT);
 
	v->dest_tile = tfdd.tile;
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
 
}
src/vehicle_gui.cpp
Show inline comments
 
@@ -2864,7 +2864,7 @@ public:
 
					SetDParam(0, v->type);
 
					SetDParam(1, v->current_order.GetDestination());
 
					SetDParam(2, v->GetDisplaySpeed());
 
					if (v->current_order.GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
 
					if (v->current_order.GetDestination() == INVALID_DEPOT) {
 
						/* This case *only* happens when multiple nearest depot orders
 
						 * follow each other (including an order list only one order: a
 
						 * nearest depot order) and there are no reachable depots.
0 comments (0 inline, 0 general)