Changeset - r26466:938bcd34baa7
[Not reviewed]
master
0 6 0
Nicolas Chappe - 2 years 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
 
@@ -7,12 +7,16 @@
 

	
 
/** @file depot_type.h Header files for depots (not hangars) */
 

	
 
#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
 
@@ -653,13 +653,13 @@ void OrderList::DebugCheckSanity() const
 
 * @param o the order to check
 
 * @return true if the destination is a station
 
 */
 
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);
 
}
 

	
 
/**
 
 * Delete all news items regarding defective orders about a vehicle
 
 * This could kill still valid warnings (for example about void order when just
 
 * another order gets added), but assume the company will notice the problems,
 
@@ -687,13 +687,13 @@ TileIndex Order::GetLocation(const Vehic
 
		case OT_GOTO_STATION:
 
		case OT_IMPLICIT:
 
			if (airport && v->type == VEH_AIRCRAFT) return Station::Get(this->GetDestination())->airport.tile;
 
			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:
 
			return INVALID_TILE;
 
	}
 
}
 
@@ -1988,13 +1988,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->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);
 

	
 
					if (v->type == VEH_AIRCRAFT) {
 
						Aircraft *a = Aircraft::From(v);
src/order_gui.cpp
Show inline comments
 
@@ -616,13 +616,13 @@ private:
 
	 */
 
	void OrderClick_NearestDepot()
 
	{
 
		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);
 

	
 
		Command<CMD_INSERT_ORDER>::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), order);
 
	}
 

	
src/script/api/script_order.cpp
Show inline comments
 
@@ -467,13 +467,13 @@ static int ScriptOrderPositionToRealOrde
 
		case OT_GOTO_DEPOT: {
 
			OrderDepotTypeFlags odtf = (OrderDepotTypeFlags)(ODTFB_PART_OF_ORDERS | ((order_flags & OF_SERVICE_IF_NEEDED) ? ODTFB_SERVICE : 0));
 
			OrderDepotActionFlags odaf = (OrderDepotActionFlags)(ODATF_SERVICE_ONLY | ((order_flags & OF_STOP_IN_DEPOT) ? ODATFB_HALT : 0));
 
			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). */
 
				if (::Vehicle::Get(vehicle_id)->type == VEH_AIRCRAFT) {
 
					if (!::IsTileType(destination, MP_STATION)) return false;
 
					order.MakeGoToDepot(::GetStationIndex(destination), odtf, onsf, odaf);
src/train_cmd.cpp
Show inline comments
 
@@ -3971,13 +3971,13 @@ static void CheckIfTrainNeedsService(Tra
 
			v->current_order.GetDestination() != depot &&
 
			!Chance16(3, 16)) {
 
		return;
 
	}
 

	
 
	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);
 
}
 

	
 
/** Update day counters of the train vehicle. */
 
void Train::OnNewDay()
src/vehicle_gui.cpp
Show inline comments
 
@@ -2861,13 +2861,13 @@ public:
 
				}
 

	
 
				case OT_GOTO_DEPOT: {
 
					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.
 
						 * It is primarily to guard for the case that there is no
 
						 * depot with index 0, which would be used as fallback for
 
						 * evaluating the string in the status bar. */
0 comments (0 inline, 0 general)