Changeset - r8853:c56f6dec859b
[Not reviewed]
master
0 13 0
rubidium - 17 years ago 2008-04-07 19:18:56
rubidium@openttd.org
(svn r12615) -Codechange: rename some enums related to depot orders to make it more clear that they are no loading/unloading flags. Also add more type strictness.
13 files changed with 73 insertions and 70 deletions:
0 comments (0 inline, 0 general)
src/ai/trolly/trolly.cpp
Show inline comments
 
@@ -1181,13 +1181,13 @@ static void AiNew_State_GiveOrders(Playe
 
		_players_ainew[p->index].veh_main_id = _players_ainew[p->index].veh_id;
 
	}
 

	
 
	// Very handy for AI, goto depot.. but yeah, it needs to be activated ;)
 
	if (_patches.gotodepot) {
 
		idx = 0;
 
		order.MakeGoToDepot(GetDepotByTile(_players_ainew[p->index].depot_tile)->index, true);
 
		order.MakeGoToDepot(GetDepotByTile(_players_ainew[p->index].depot_tile)->index, ODTFB_PART_OF_ORDERS);
 
		AI_DoCommand(0, _players_ainew[p->index].veh_id + (idx << 16), order.Pack(), DC_EXEC, CMD_INSERT_ORDER);
 
	}
 

	
 
	idx = 0;
 
	order.MakeGoToStation(GetStationIndex(_players_ainew[p->index].to_tile));
 
	if (_players_ainew[p->index].tbt == AI_TRUCK && _players_ainew[p->index].to_deliver)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -567,30 +567,30 @@ CommandCost CmdSendAircraftToHangar(Tile
 

	
 
	Vehicle *v = GetVehicle(p1);
 

	
 
	if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner) || v->IsInDepot()) return CMD_ERROR;
 

	
 
	if (v->current_order.IsType(OT_GOTO_DEPOT) && !(p2 & DEPOT_LOCATE_HANGAR)) {
 
		bool halt_in_depot = HasBit(v->current_order.GetDepotActionType(), OF_HALT_IN_DEPOT);
 
		bool halt_in_depot = v->current_order.GetDepotActionType() & ODATFB_HALT;
 
		if (!!(p2 & DEPOT_SERVICE) == halt_in_depot) {
 
			/* We called with a different DEPOT_SERVICE setting.
 
			 * Now we change the setting to apply the new one and let the vehicle head for the same hangar.
 
			 * Note: the if is (true for requesting service == true for ordered to stop in hangar) */
 
			if (flags & DC_EXEC) {
 
				v->current_order.SetDepotOrderType(OFB_MANUAL_ORDER);
 
				v->current_order.SetDepotActionType(halt_in_depot ? OFB_NORMAL_ACTION : OFB_HALT_IN_DEPOT);
 
				v->current_order.SetDepotOrderType(ODTF_MANUAL);
 
				v->current_order.SetDepotActionType(halt_in_depot ? ODATF_SERVICE_ONLY : ODATFB_HALT);
 
				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			}
 
			return CommandCost();
 
		}
 

	
 
		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of hangar orders
 
		if (flags & DC_EXEC) {
 
			/* If the orders to 'goto depot' are in the orders list (forced servicing),
 
			 * then skip to the next order; effectively cancelling this forced service */
 
			if (v->current_order.GetDepotOrderType() & OFB_PART_OF_ORDERS) v->cur_order_index++;
 
			if (v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) v->cur_order_index++;
 

	
 
			v->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
	} else {
 
		bool next_airport_has_hangar = true;
 
@@ -606,14 +606,14 @@ CommandCost CmdSendAircraftToHangar(Tile
 
			next_airport_index = station;
 
		}
 

	
 
		if (flags & DC_EXEC) {
 
			if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
 

	
 
			v->current_order.MakeGoToDepot(next_airport_index, false);
 
			if (!(p2 & DEPOT_SERVICE)) v->current_order.SetDepotActionType(OFB_HALT_IN_DEPOT);
 
			v->current_order.MakeGoToDepot(next_airport_index, ODTF_MANUAL);
 
			if (!(p2 & DEPOT_SERVICE)) v->current_order.SetDepotActionType(ODATFB_HALT);
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			if (v->u.air.state == FLYING && !next_airport_has_hangar) {
 
				/* The aircraft is now heading for a different hangar than the next in the orders */
 
				AircraftNextAirportPos_and_Order(v);
 
			}
 
		}
 
@@ -711,13 +711,13 @@ static void CheckIfAircraftNeedsService(
 

	
 
	const Station *st = GetStation(v->current_order.GetDestination());
 
	/* only goto depot if the target airport has terminals (eg. it is airport) */
 
	if (st->IsValid() && st->airport_tile != 0 && st->Airport()->terminals != NULL) {
 
//		printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
 
//		v->u.air.targetairport = st->index;
 
		v->current_order.MakeGoToDepot(0, false);
 
		v->current_order.MakeGoToDepot(0, ODTFB_SERVICE);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	} else if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
		v->current_order.MakeDummy();
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 
}
src/order_base.h
Show inline comments
 
@@ -84,13 +84,13 @@ public:
 
	 * 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 overriden vehicle order?
 
	 * @param cargo       the cargo type to change to.
 
	 * @param subtype     the subtype to change to.
 
	 */
 
	void MakeGoToDepot(DepotID destination, bool order, CargoID cargo = CT_NO_REFIT, byte subtype = 0);
 
	void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, CargoID cargo = CT_NO_REFIT, byte subtype = 0);
 

	
 
	/**
 
	 * Makes this order a Go To Waypoint order.
 
	 * @param destination the waypoint to go to.
 
	 */
 
	void MakeGoToWaypoint(WaypointID destination);
 
@@ -164,26 +164,26 @@ public:
 
	inline byte GetLoadType() const { return this->flags & OFB_FULL_LOAD; }
 
	/** How must the consist be unloaded? */
 
	inline byte GetUnloadType() const { return GB(this->flags, 0, 2); }
 
	/** Where must we stop? */
 
	OrderNonStopFlags GetNonStopType() const;
 
	/** What caused us going to the depot? */
 
	inline byte GetDepotOrderType() const { return this->flags; }
 
	inline OrderDepotTypeFlags GetDepotOrderType() const { return (OrderDepotTypeFlags)this->flags; }
 
	/** What are we going to do when in the depot. */
 
	inline byte GetDepotActionType() const { return this->flags; }
 
	inline OrderDepotActionFlags GetDepotActionType() const { return (OrderDepotActionFlags)this->flags; }
 

	
 
	/** Set how the consist must be loaded. */
 
	inline void SetLoadType(byte load_type) { SB(this->flags, 2, 1, !!load_type); }
 
	/** Set how the consist must be unloaded. */
 
	inline void SetUnloadType(byte unload_type) { SB(this->flags, 0, 2, unload_type); }
 
	/** Set whether we must stop at stations or not. */
 
	inline void SetNonStopType(OrderNonStopFlags non_stop_type) { SB(this->flags, 3, 1, !!non_stop_type); }
 
	/** Set the cause to go to the depot. */
 
	inline void SetDepotOrderType(byte depot_order_type) { this->flags = depot_order_type; }
 
	inline void SetDepotOrderType(OrderDepotTypeFlags depot_order_type) { this->flags = depot_order_type; }
 
	/** Set what we are going to do in the depot. */
 
	inline void SetDepotActionType(byte depot_service_type) { this->flags = depot_service_type; }
 
	inline void SetDepotActionType(OrderDepotActionFlags depot_service_type) { this->flags = depot_service_type; }
 

	
 
	bool ShouldStopAtStation(const Vehicle *v, StationID station) const;
 

	
 
	/**
 
	 * Assign the given order to this one.
 
	 * @param other the data to copy (except next pointer).
src/order_cmd.cpp
Show inline comments
 
@@ -62,19 +62,18 @@ void Order::MakeGoToStation(StationID de
 
{
 
	this->type = OT_GOTO_STATION;
 
	this->flags = 0;
 
	this->dest = destination;
 
}
 

	
 
void Order::MakeGoToDepot(DepotID destination, bool order, CargoID cargo, byte subtype)
 
void Order::MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, CargoID cargo, byte subtype)
 
{
 
	this->type = OT_GOTO_DEPOT;
 
	this->flags = 0;
 
	if (order) {
 
		this->SetDepotOrderType(OFB_PART_OF_ORDERS);
 
	} else {
 
	this->SetDepotOrderType(order);
 
	if (!(order & ODTFB_PART_OF_ORDERS)) {
 
		this->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
	}
 
	this->dest = destination;
 
	this->SetRefit(cargo, subtype);
 
}
 

	
 
@@ -374,14 +373,14 @@ CommandCost CmdInsertOrder(TileIndex til
 
			if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR;
 

	
 
			/* Order flags can be any of the following for depots:
 
			 * order [+ halt] [+ non-stop]
 
			 * non-stop orders (if any) are only valid for trains */
 
			switch (new_order.GetDepotOrderType() | new_order.GetDepotActionType()) {
 
				case OFB_PART_OF_ORDERS:
 
				case OFB_PART_OF_ORDERS | OFB_HALT_IN_DEPOT:
 
				case ODTFB_PART_OF_ORDERS:
 
				case ODTFB_PART_OF_ORDERS | ODATFB_HALT:
 
					break;
 

	
 
				default: return CMD_ERROR;
 
			}
 
			break;
 
		}
 
@@ -762,13 +761,13 @@ CommandCost CmdModifyOrder(TileIndex til
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		switch (p2) {
 
			case OF_FULL_LOAD:
 
				if (order->IsType(OT_GOTO_DEPOT)) {
 
					order->SetDepotOrderType(order->GetDepotOrderType() ^ OFB_SERVICE_IF_NEEDED);
 
					order->SetDepotOrderType((OrderDepotTypeFlags)(order->GetDepotOrderType() ^ ODTFB_SERVICE));
 
				} else {
 
					order->SetLoadType(order->GetLoadType() ^ OFB_FULL_LOAD);
 
					order->SetUnloadType(order->GetUnloadType() & ~OFB_UNLOAD);
 
				}
 
				break;
 
			case OF_UNLOAD:
 
@@ -981,13 +980,13 @@ CommandCost CmdOrderRefit(TileIndex tile
 
		u = GetFirstVehicleFromSharedList(v);
 
		for (; u != NULL; u = u->next_shared) {
 
			/* Update any possible open window of the vehicle */
 
			InvalidateVehicleOrder(u);
 

	
 
			/* If the vehicle already got the current depot set as current order, then update current order as well */
 
			if (u->cur_order_index == order_number && HasBit(u->current_order.GetDepotOrderType(), OF_PART_OF_ORDERS)) {
 
			if (u->cur_order_index == order_number && u->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) {
 
				u->current_order.SetRefit(cargo, subtype);
 
			}
 
		}
 
	}
 

	
 
	return CommandCost();
 
@@ -1364,15 +1363,15 @@ static bool CheckForValidOrders(const Ve
 
 */
 
bool ProcessOrders(Vehicle *v)
 
{
 
	switch (v->current_order.GetType()) {
 
		case OT_GOTO_DEPOT:
 
			/* Let a depot order in the orderlist interrupt. */
 
			if (!(v->current_order.GetDepotOrderType() & OFB_PART_OF_ORDERS)) return false;
 
			if (!(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) return false;
 

	
 
			if ((v->current_order.GetDepotOrderType() & OFB_SERVICE_IF_NEEDED) && !VehicleNeedsService(v)) {
 
			if ((v->current_order.GetDepotOrderType() & ODTFB_SERVICE) && !VehicleNeedsService(v)) {
 
				UpdateVehicleTimetable(v, true);
 
				v->cur_order_index++;
 
			}
 
			break;
 

	
 
		case OT_LOADING:
src/order_gui.cpp
Show inline comments
 
@@ -219,13 +219,13 @@ static void DrawOrdersWindow(Window *w)
 
							case VEH_ROAD:  s = STR_GO_TO_ROADVEH_DEPOT; break;
 
							case VEH_SHIP:  s = STR_GO_TO_SHIP_DEPOT; break;
 
							default: break;
 
						}
 
					}
 

	
 
					if (order->GetDepotOrderType() & OFB_SERVICE_IF_NEEDED) s++; /* service at */
 
					if (order->GetDepotOrderType() & ODTFB_SERVICE) s++; /* service at */
 

	
 
					SetDParam(1, s);
 
					if (order->IsRefit()) {
 
						SetDParam(3, STR_REFIT_ORDER);
 
						SetDParam(4, GetCargo(order->GetRefitCargo())->name);
 
					} else {
 
@@ -267,40 +267,40 @@ static Order GetOrderCmdFromTile(const V
 
	// check depot first
 
	if (_patches.gotodepot) {
 
		switch (GetTileType(tile)) {
 
		case MP_RAILWAY:
 
			if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_player)) {
 
				if (IsRailDepot(tile)) {
 
					order.MakeGoToDepot(GetDepotByTile(tile)->index, true);
 
					order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
 
					return order;
 
				}
 
			}
 
			break;
 

	
 
		case MP_ROAD:
 
			if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
 
				order.MakeGoToDepot(GetDepotByTile(tile)->index, true);
 
				order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
 
				return order;
 
			}
 
			break;
 

	
 
		case MP_STATION:
 
			if (v->type != VEH_AIRCRAFT) break;
 
			if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
 
				order.MakeGoToDepot(GetStationIndex(tile), true);
 
				order.MakeGoToDepot(GetStationIndex(tile), ODTFB_PART_OF_ORDERS);
 
				return order;
 
			}
 
			break;
 

	
 
		case MP_WATER:
 
			if (v->type != VEH_SHIP) break;
 
			if (IsTileDepotType(tile, TRANSPORT_WATER) &&
 
					IsTileOwner(tile, _local_player)) {
 
				TileIndex tile2 = GetOtherShipDepotTile(tile);
 

	
 
				order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, true);
 
				order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS);
 
				return order;
 
			}
 

	
 
			default:
 
				break;
 
		}
src/order_type.h
Show inline comments
 
@@ -46,45 +46,49 @@ enum OrderFlagMasks {
 
	/** If OFB_TRANSFER is not set, drop any cargo loaded. If accepted, deliver, otherwise cargo remains at the station.
 
      * No new cargo is loaded onto the vehicle whatsoever */
 
	OFB_UNLOAD             = 0x2,
 
	/** Wait for full load of all vehicles, or of at least one cargo type, depending on patch setting
 
	  * @todo make this two different flags */
 
	OFB_FULL_LOAD          = 0x4,
 

	
 
	//Flags for depots:
 
	/** The current depot-order was initiated because it was in the vehicle's order list */
 
	OFB_MANUAL_ORDER       = 0x0,
 
	OFB_PART_OF_ORDERS     = 0x2,
 
	/** if OFB_PART_OF_ORDERS is not set, this will cause the vehicle to be stopped in the depot */
 
 	OFB_NORMAL_ACTION      = 0x0,
 
	OFB_HALT_IN_DEPOT      = 0x4,
 
	/** if OFB_PART_OF_ORDERS is set, this will cause the order only be come active if the vehicle needs servicing */
 
	OFB_SERVICE_IF_NEEDED  = 0x4, //used when OFB_PART_OF_ORDERS is set.
 
};
 

	
 
/**
 
 * Non-stop order flags.
 
 */
 
enum OrderNonStopFlags {
 
	ONSF_STOP_EVERYWHERE                  = 0,
 
	ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS = 1,
 
	ONSF_NO_STOP_AT_DESTINATION_STATION   = 2,
 
	ONSF_NO_STOP_AT_ANY_STATION           = 3
 
};
 

	
 
/**
 
 * Reasons that could cause us to go to the depot.
 
 */
 
enum OrderDepotTypeFlags {
 
	ODTF_MANUAL          = 0,      ///< The player initiated this order manually.
 
	ODTFB_SERVICE        = 1 << 2, ///< This depot order is because of the servicing limit.
 
	ODTFB_PART_OF_ORDERS = 1 << 1, ///< This depot order is because of a regular order.
 
};
 

	
 
/**
 
 * Actions that can be performed when the vehicle enters the depot.
 
 */
 
enum OrderDepotActionFlags {
 
	ODATF_SERVICE_ONLY   = 0,      ///< Only service the vehicle.
 
	ODATFB_HALT          = 1 << 2, ///< Service the vehicle and then halt it.
 
};
 

	
 
/** Order flags bits - these are for the *BIT macros
 
 * for descrption of flags, see OrderFlagMasks
 
 * @see OrderFlagMasks
 
 */
 
enum {
 
	OF_TRANSFER          = 0,
 
	OF_UNLOAD            = 1,
 
	OF_FULL_LOAD         = 2,
 
	OF_PART_OF_ORDERS    = 1,
 
	OF_HALT_IN_DEPOT     = 2,
 
	OF_SERVICE_IF_NEEDED = 2,
 
	OF_NON_STOP          = 3
 
};
 

	
 

	
 
/* Possible clone options */
 
enum {
src/roadveh_cmd.cpp
Show inline comments
 
@@ -474,30 +474,30 @@ CommandCost CmdSendRoadVehToDepot(TileIn
 
	if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
 

	
 
	if (v->IsInDepot()) return CMD_ERROR;
 

	
 
	/* If the current orders are already goto-depot */
 
	if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
		bool halt_in_depot = HasBit(v->current_order.GetDepotActionType(), OF_HALT_IN_DEPOT);
 
		bool halt_in_depot = v->current_order.GetDepotActionType() & ODATFB_HALT;
 
		if (!!(p2 & DEPOT_SERVICE) == halt_in_depot) {
 
			/* We called with a different DEPOT_SERVICE setting.
 
			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
 
			 * Note: the if is (true for requesting service == true for ordered to stop in depot) */
 
			if (flags & DC_EXEC) {
 
				v->current_order.SetDepotOrderType(OFB_MANUAL_ORDER);
 
				v->current_order.SetDepotActionType(halt_in_depot ? OFB_NORMAL_ACTION : OFB_HALT_IN_DEPOT);
 
				v->current_order.SetDepotOrderType(ODTF_MANUAL);
 
				v->current_order.SetDepotActionType(halt_in_depot ? ODATF_SERVICE_ONLY : ODATFB_HALT);
 
				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			}
 
			return CommandCost();
 
		}
 

	
 
		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
 
		if (flags & DC_EXEC) {
 
			/* If the orders to 'goto depot' are in the orders list (forced servicing),
 
			 * then skip to the next order; effectively cancelling this forced service */
 
			if (v->current_order.GetDepotOrderType() & OFB_PART_OF_ORDERS) v->cur_order_index++;
 
			if (v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) v->cur_order_index++;
 

	
 
			v->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
		return CommandCost();
 
	}
 
@@ -506,14 +506,14 @@ CommandCost CmdSendRoadVehToDepot(TileIn
 
	if (dep == NULL) return_cmd_error(STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT);
 

	
 
	if (flags & DC_EXEC) {
 
		if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
 

	
 
		ClearSlot(v);
 
		v->current_order.MakeGoToDepot(dep->index, false);
 
		if (!(p2 & DEPOT_SERVICE)) v->current_order.SetDepotActionType(OFB_HALT_IN_DEPOT);
 
		v->current_order.MakeGoToDepot(dep->index, ODTF_MANUAL);
 
		if (!(p2 & DEPOT_SERVICE)) v->current_order.SetDepotActionType(ODATFB_HALT);
 
		v->dest_tile = dep->xy;
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 

	
 
	return CommandCost();
 
}
 
@@ -1934,13 +1934,13 @@ static void CheckIfRoadVehNeedsService(V
 
		return;
 
	}
 

	
 
	if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
 
	ClearSlot(v);
 

	
 
	v->current_order.MakeGoToDepot(depot->index, false);
 
	v->current_order.MakeGoToDepot(depot->index, ODTFB_SERVICE);
 
	v->dest_tile = depot->xy;
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
void RoadVehicle::OnNewDay()
 
{
src/ship_cmd.cpp
Show inline comments
 
@@ -157,13 +157,13 @@ static void CheckIfShipNeedsService(Vehi
 
			v->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
		return;
 
	}
 

	
 
	v->current_order.MakeGoToDepot(depot->index, false);
 
	v->current_order.MakeGoToDepot(depot->index, ODTFB_SERVICE);
 
	v->dest_tile = depot->xy;
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
void Ship::OnNewDay()
 
{
 
@@ -940,30 +940,30 @@ CommandCost CmdSendShipToDepot(TileIndex
 
	if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
 

	
 
	if (v->IsInDepot()) return CMD_ERROR;
 

	
 
	/* If the current orders are already goto-depot */
 
	if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
		bool halt_in_depot = HasBit(v->current_order.GetDepotActionType(), OF_HALT_IN_DEPOT);
 
		bool halt_in_depot = v->current_order.GetDepotActionType() & ODATFB_HALT;
 
		if (!!(p2 & DEPOT_SERVICE) == halt_in_depot) {
 
			/* We called with a different DEPOT_SERVICE setting.
 
			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
 
			 * Note: the if is (true for requesting service == true for ordered to stop in depot)          */
 
			if (flags & DC_EXEC) {
 
				v->current_order.SetDepotOrderType(OFB_MANUAL_ORDER);
 
				v->current_order.SetDepotActionType(halt_in_depot ? OFB_NORMAL_ACTION : OFB_HALT_IN_DEPOT);
 
				v->current_order.SetDepotOrderType(ODTF_MANUAL);
 
				v->current_order.SetDepotActionType(halt_in_depot ? ODATF_SERVICE_ONLY : ODATFB_HALT);
 
				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			}
 
			return CommandCost();
 
		}
 

	
 
		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
 
		if (flags & DC_EXEC) {
 
			/* If the orders to 'goto depot' are in the orders list (forced servicing),
 
			 * then skip to the next order; effectively cancelling this forced service */
 
			if (v->current_order.GetDepotOrderType() & OFB_PART_OF_ORDERS) v->cur_order_index++;
 
			if (v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) v->cur_order_index++;
 

	
 
			v->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
		return CommandCost();
 
	}
 
@@ -972,14 +972,14 @@ CommandCost CmdSendShipToDepot(TileIndex
 
	if (dep == NULL) return_cmd_error(STR_981A_UNABLE_TO_FIND_LOCAL_DEPOT);
 

	
 
	if (flags & DC_EXEC) {
 
		if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
 

	
 
		v->dest_tile = dep->xy;
 
		v->current_order.MakeGoToDepot(dep->index, false);
 
		if (!(p2 & DEPOT_SERVICE)) v->current_order.SetDepotActionType(OFB_HALT_IN_DEPOT);
 
		v->current_order.MakeGoToDepot(dep->index, ODTF_MANUAL);
 
		if (!(p2 & DEPOT_SERVICE)) v->current_order.SetDepotActionType(ODATFB_HALT);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 

	
 
	return CommandCost();
 
}
 

	
src/timetable_cmd.cpp
Show inline comments
 
@@ -21,13 +21,13 @@ static void ChangeTimetable(Vehicle *v, 
 
	if (is_journey) {
 
		order->travel_time = time;
 
	} else {
 
		order->wait_time = time;
 
	}
 

	
 
	if (v->cur_order_index == order_number && HasBit(v->current_order.GetDepotOrderType(), OF_PART_OF_ORDERS)) {
 
	if (v->cur_order_index == order_number && v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) {
 
		if (is_journey) {
 
			v->current_order.travel_time = time;
 
		} else {
 
			v->current_order.wait_time = time;
 
		}
 
	}
src/timetable_gui.cpp
Show inline comments
 
@@ -143,13 +143,13 @@ static void DrawTimetableWindow(Window *
 
							case VEH_ROAD:  string = STR_GO_TO_ROADVEH_DEPOT; break;
 
							case VEH_SHIP:  string = STR_GO_TO_SHIP_DEPOT; break;
 
							default: break;
 
						}
 
					}
 

	
 
					if (order->GetDepotOrderType() & OFB_SERVICE_IF_NEEDED) string++; /* service at */
 
					if (order->GetDepotOrderType() & ODTFB_SERVICE) string++; /* service at */
 

	
 
					SetDParam(0, string);
 
				} break;
 

	
 
				case OT_GOTO_WAYPOINT:
 
					SetDParam(0, (order->GetNonStopType() != ONSF_STOP_EVERYWHERE) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
src/train_cmd.cpp
Show inline comments
 
@@ -2106,30 +2106,30 @@ CommandCost CmdSendTrainToDepot(TileInde
 

	
 
	if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	if (v->vehstatus & VS_CRASHED) return CMD_ERROR;
 

	
 
	if (v->current_order.IsType(OT_GOTO_DEPOT)) {
 
		bool halt_in_depot = HasBit(v->current_order.GetDepotActionType(), OF_HALT_IN_DEPOT);
 
		bool halt_in_depot = v->current_order.GetDepotActionType() & ODATFB_HALT;
 
		if (!!(p2 & DEPOT_SERVICE) == halt_in_depot) {
 
			/* We called with a different DEPOT_SERVICE setting.
 
			 * Now we change the setting to apply the new one and let the vehicle head for the same depot.
 
			 * Note: the if is (true for requesting service == true for ordered to stop in depot)          */
 
			if (flags & DC_EXEC) {
 
				v->current_order.SetDepotOrderType(OFB_MANUAL_ORDER);
 
				v->current_order.SetDepotActionType(halt_in_depot ? OFB_NORMAL_ACTION : OFB_HALT_IN_DEPOT);
 
				v->current_order.SetDepotOrderType(ODTF_MANUAL);
 
				v->current_order.SetDepotActionType(halt_in_depot ? ODATF_SERVICE_ONLY : ODATFB_HALT);
 
				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
			}
 
			return CommandCost();
 
		}
 

	
 
		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
 
		if (flags & DC_EXEC) {
 
			/* If the orders to 'goto depot' are in the orders list (forced servicing),
 
			 * then skip to the next order; effectively cancelling this forced service */
 
			if (v->current_order.GetDepotOrderType() & OFB_PART_OF_ORDERS) v->cur_order_index++;
 
			if (v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) v->cur_order_index++;
 

	
 
			v->current_order.MakeDummy();
 
			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		}
 
		return CommandCost();
 
	}
 
@@ -2142,14 +2142,14 @@ CommandCost CmdSendTrainToDepot(TileInde
 
	if (tfdd.best_length == (uint)-1) return_cmd_error(STR_883A_UNABLE_TO_FIND_ROUTE_TO);
 

	
 
	if (flags & DC_EXEC) {
 
		if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
 

	
 
		v->dest_tile = tfdd.tile;
 
		v->current_order.MakeGoToDepot(GetDepotByTile(tfdd.tile)->index, false);
 
		if (!(p2 & DEPOT_SERVICE)) v->current_order.SetDepotActionType(OFB_HALT_IN_DEPOT);
 
		v->current_order.MakeGoToDepot(GetDepotByTile(tfdd.tile)->index, ODTF_MANUAL);
 
		if (!(p2 & DEPOT_SERVICE)) v->current_order.SetDepotActionType(ODATFB_HALT);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
		/* If there is no depot in front, reverse automatically */
 
		if (tfdd.reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
 
	}
 

	
 
	return CommandCost();
 
@@ -3567,13 +3567,13 @@ static void CheckIfTrainNeedsService(Veh
 
	if (v->current_order.IsType(OT_GOTO_DEPOT) &&
 
			v->current_order.GetDestination() != depot->index &&
 
			!Chance16(3, 16)) {
 
		return;
 
	}
 

	
 
	v->current_order.MakeGoToDepot(depot->index, false);
 
	v->current_order.MakeGoToDepot(depot->index, ODTFB_SERVICE);
 
	v->dest_tile = tfdd.tile;
 
	InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
}
 

	
 
void Train::OnNewDay()
 
{
src/vehicle.cpp
Show inline comments
 
@@ -118,16 +118,16 @@ void VehicleServiceInDepot(Vehicle *v)
 
	InvalidateWindow(WC_VEHICLE_DETAILS, v->index); // ensure that last service date and reliability are updated
 
}
 

	
 
bool VehicleNeedsService(const Vehicle *v)
 
{
 
	if (v->vehstatus & (VS_STOPPED | VS_CRASHED))       return false;
 
	if (!v->current_order.IsType(OT_GOTO_DEPOT) || !(v->current_order.GetDepotOrderType() & OFB_PART_OF_ORDERS)) { // Don't interfere with a depot visit by the order list
 
	if (!v->current_order.IsType(OT_GOTO_DEPOT) || !(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) { // Don't interfere with a depot visit by the order list
 
		if (_patches.gotodepot && VehicleHasDepotOrders(v)) return false;
 
		if (v->current_order.IsType(OT_LOADING))            return false;
 
		if (v->current_order.IsType(OT_GOTO_DEPOT) && v->current_order.GetDepotActionType() & OFB_HALT_IN_DEPOT) return false;
 
		if (v->current_order.IsType(OT_GOTO_DEPOT) && v->current_order.GetDepotActionType() & ODATFB_HALT) return false;
 
	}
 

	
 
	if (_patches.no_servicing_if_no_breakdowns && _opt.diff.vehicle_breakdowns == 0) {
 
		return EngineHasReplacementForPlayer(GetPlayer(v->owner), v->engine_type, v->group_id);  /* Vehicles set for autoreplacing needs to go to a depot even if breakdowns are turned off */
 
	}
 

	
 
@@ -629,13 +629,13 @@ static Vehicle* _first_veh_in_depot_list
 
 * @param *v vehicle to add
 
 */
 
void VehicleEnteredDepotThisTick(Vehicle *v)
 
{
 
	/* We need to set v->leave_depot_instantly as we have no control of it's contents at this time.
 
	 * Vehicle should stop in the depot if it was in 'stopping' state - train intered depot while slowing down. */
 
	if ((HasBit(v->current_order.GetDepotActionType(), OF_HALT_IN_DEPOT) && !HasBit(v->current_order.GetDepotOrderType(), OF_PART_OF_ORDERS) && v->current_order.IsType(OT_GOTO_DEPOT)) ||
 
	if (((v->current_order.GetDepotActionType() & ODATFB_HALT) && !(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) && v->current_order.IsType(OT_GOTO_DEPOT)) ||
 
			(v->vehstatus & VS_STOPPED)) {
 
		/* we keep the vehicle in the depot since the user ordered it to stay */
 
		v->leave_depot_instantly = false;
 
	} else {
 
		/* the vehicle do not plan on stopping in the depot, so we stop it to ensure that it will not reserve the path
 
		 * out of the depot before we might autoreplace it to a different engine. The new engine would not own the reserved path
 
@@ -2260,17 +2260,17 @@ void VehicleEnterDepot(Vehicle *v)
 
				}
 
			} else if (v->owner == _local_player && cost.GetCost() != 0) {
 
				ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost.GetCost());
 
			}
 
		}
 

	
 
		if (HasBit(t.GetDepotOrderType(), OF_PART_OF_ORDERS)) {
 
		if (t.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) {
 
			/* Part of orders */
 
			UpdateVehicleTimetable(v, true);
 
			v->cur_order_index++;
 
		} else if (HasBit(t.GetDepotActionType(), OF_HALT_IN_DEPOT)) {
 
		} else if (t.GetDepotActionType() & ODATFB_HALT) {
 
			/* Force depot visit */
 
			v->vehstatus |= VS_STOPPED;
 
			if (v->owner == _local_player) {
 
				StringID string;
 

	
 
				switch (v->type) {
src/vehicle_gui.cpp
Show inline comments
 
@@ -1966,13 +1966,13 @@ static void DrawVehicleViewWindow(Window
 
					SetDParam(1, v->GetDisplaySpeed());
 
				} else {
 
					Depot *depot = GetDepot(v->current_order.GetDestination());
 
					SetDParam(0, depot->town_index);
 
					SetDParam(1, v->GetDisplaySpeed());
 
				}
 
				if (HasBit(v->current_order.GetDepotActionType(), OF_HALT_IN_DEPOT) && !HasBit(v->current_order.GetDepotOrderType(), OF_PART_OF_ORDERS)) {
 
				if ((v->current_order.GetDepotActionType() & ODATFB_HALT) && !(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) {
 
					str = _heading_for_depot_strings[v->type] + _patches.vehicle_speed;
 
				} else {
 
					str = _heading_for_depot_service_strings[v->type] + _patches.vehicle_speed;
 
				}
 
			} break;
 

	
0 comments (0 inline, 0 general)