Changeset - r11804:b557a467d2ad
[Not reviewed]
master
0 4 0
frosch - 15 years ago 2009-05-02 00:10:24
frosch@openttd.org
(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'.
4 files changed with 20 insertions and 20 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_order.cpp
Show inline comments
 
@@ -340,10 +340,10 @@ static const Order *ResolveOrder(Vehicle
 
			 * to a depot (other vehicle types). */
 
			if (::GetVehicle(vehicle_id)->type == VEH_AIRCRAFT) {
 
				if (!::IsTileType(destination, MP_STATION)) return false;
 
				order.MakeGoToDepot(::GetStationIndex(destination), odtf, odaf);
 
				order.MakeGoToDepot(::GetStationIndex(destination), odtf, ONSF_STOP_EVERYWHERE, odaf);
 
			} else {
 
				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;
 
		}
src/order_base.h
Show inline comments
 
@@ -83,13 +83,14 @@ 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 action      what to do in the depot?
 
	 * @param cargo       the cargo type to change to.
 
	 * @param subtype     the subtype to change to.
 
	 * @param destination   the depot to go to.
 
	 * @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 cargo         the cargo type 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.
src/order_cmd.cpp
Show inline comments
 
@@ -51,14 +51,12 @@ void Order::MakeGoToStation(StationID de
 
	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->SetDepotOrderType(order);
 
	this->SetDepotActionType(action);
 
	if (!(order & ODTFB_PART_OF_ORDERS)) {
 
		this->SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
	}
 
	this->SetNonStopType(non_stop_type);
 
	this->dest = destination;
 
	this->SetRefit(cargo, subtype);
 
}
 
@@ -1644,7 +1642,7 @@ bool UpdateOrderDest(Vehicle *v, const O
 

	
 
				if (v->FindClosestDepot(&location, &destination, &reverse)) {
 
					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 (v->type == VEH_TRAIN && reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
src/order_gui.cpp
Show inline comments
 
@@ -299,9 +299,9 @@ static Order GetOrderCmdFromTile(const V
 
			case MP_RAILWAY:
 
				if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_company)) {
 
					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 (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
						return order;
 
					}
 
				}
 
@@ -309,9 +309,9 @@ static Order GetOrderCmdFromTile(const V
 

	
 
			case MP_ROAD:
 
				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 (_settings_client.gui.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
					return order;
 
				}
 
				break;
 
@@ -319,7 +319,7 @@ static Order GetOrderCmdFromTile(const V
 
			case MP_STATION:
 
				if (v->type != VEH_AIRCRAFT) break;
 
				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));
 
					return order;
 
				}
 
@@ -330,7 +330,7 @@ static Order GetOrderCmdFromTile(const V
 
				if (IsShipDepot(tile) && IsTileOwner(tile, _local_company)) {
 
					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));
 
					return order;
 
				}
 
@@ -507,7 +507,8 @@ private:
 
		Order order;
 
		order.next = NULL;
 
		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);
 

	
 
		DoCommandP(w->vehicle->tile, w->vehicle->index + (w->OrderGetSel() << 16), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
0 comments (0 inline, 0 general)