changeset 11809:57fd0a8c36cb draft

(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'.
author frosch <frosch@openttd.org>
date Sat, 02 May 2009 00:10:24 +0000
parents bd87a82fe7a9
children 86737f4f9bf1
files src/ai/api/ai_order.cpp src/order_base.h src/order_cmd.cpp src/order_gui.cpp
diffstat 4 files changed, 20 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -340,10 +340,10 @@
 			 * 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;
 		}
--- a/src/order_base.h
+++ b/src/order_base.h
@@ -83,13 +83,14 @@
 
 	/**
 	 * 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.
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -51,14 +51,12 @@
 	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 @@
 
 				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);
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -299,9 +299,9 @@
 			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 @@
 
 			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 @@
 			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 @@
 				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 @@
 		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));