changeset 8873:9780f2a6cd20 draft

(svn r12640) -Codechange: let GetLoadType make a difference between full load and full load any based on the patch setting instead of using the patch setting directly.
author rubidium <rubidium@openttd.org>
date Wed, 09 Apr 2008 18:26:19 +0000
parents 32505929420d
children a6a05ae5a7da
files src/economy.cpp src/order_base.h src/order_cmd.cpp src/order_gui.cpp src/order_type.h
diffstat 5 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1730,7 +1730,7 @@
 	} else {
 		bool finished_loading = true;
 		if (v->current_order.GetLoadType() & OLFB_FULL_LOAD) {
-			if (_patches.full_load_any) {
+			if (v->current_order.GetLoadType() == OLF_FULL_LOAD_ANY) {
 				/* if the aircraft carries passengers and is NOT full, then
 				 * continue loading, no matter how much mail is in */
 				if ((v->type == VEH_AIRCRAFT && IsCargoInClass(v->cargo_type, CC_PASSENGERS) && v->cargo_cap != v->cargo.Count()) ||
--- a/src/order_base.h
+++ b/src/order_base.h
@@ -161,7 +161,7 @@
 	void SetRefit(CargoID cargo, byte subtype = 0);
 
 	/** How must the consist be loaded? */
-	inline OrderLoadFlags GetLoadType() const { return (OrderLoadFlags)(this->flags & OLFB_FULL_LOAD); }
+	OrderLoadFlags GetLoadType() const;
 	/** How must the consist be unloaded? */
 	inline OrderUnloadFlags GetUnloadType() const { return (OrderUnloadFlags)GB(this->flags, 0, 2); }
 	/** Where must we stop? */
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -41,6 +41,12 @@
 
 DEFINE_OLD_POOL_GENERIC(Order, Order);
 
+OrderLoadFlags Order::GetLoadType() const
+{
+	if ((this->flags & OLFB_FULL_LOAD) == 0) return OLF_LOAD_IF_POSSIBLE;
+	return _patches.full_load_any ? OLF_FULL_LOAD_ANY : OLFB_FULL_LOAD;
+}
+
 OrderNonStopFlags Order::GetNonStopType() const
 {
 	if (_patches.new_nonstop) {
@@ -322,7 +328,10 @@
 			if ((new_order.GetLoadType() & OLFB_FULL_LOAD) && (new_order.GetUnloadType() & OUFB_UNLOAD)) return CMD_ERROR;
 
 			/* Filter invalid load/unload types. */
-			if (new_order.GetLoadType() & ~OLFB_FULL_LOAD) return CMD_ERROR;
+			switch (new_order.GetLoadType()) {
+				case OLF_LOAD_IF_POSSIBLE: case OLFB_FULL_LOAD: case OLF_FULL_LOAD_ANY: break;
+				default: return CMD_ERROR;
+			}
 			if (new_order.GetUnloadType() & ~(OUFB_UNLOAD | OUFB_TRANSFER)) return CMD_ERROR;
 			break;
 		}
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -194,7 +194,7 @@
 					break;
 
 				case OT_GOTO_STATION:
-					SetDParam(1, _station_order_strings[!(order->GetNonStopType() == (_patches.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE))][order->GetLoadType() | order->GetUnloadType()]);
+					SetDParam(1, _station_order_strings[!(order->GetNonStopType() == (_patches.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE))][(order->GetLoadType() & OLFB_FULL_LOAD) | order->GetUnloadType()]);
 					SetDParam(2, order->GetDestination());
 					break;
 
--- a/src/order_type.h
+++ b/src/order_type.h
@@ -50,7 +50,8 @@
  */
 enum OrderLoadFlags {
 	OLF_LOAD_IF_POSSIBLE = 0,      ///< Load as long as there is cargo that fits in the train.
-	OLFB_FULL_LOAD       = 1 << 2, ///< Full load the complete (or a single cargo) of the consist.
+	OLFB_FULL_LOAD       = 1 << 2, ///< Full load the complete the consist.
+	OLF_FULL_LOAD_ANY    = 5,      ///< Full load the a single cargo of the consist.
 };
 
 /**