From 82155367f6118c0a43a74eb842cf25b23d143d49 Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 9 Apr 2008 18:26:19 +0000 Subject: [PATCH] (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. --- src/economy.cpp | 2 +- src/order_base.h | 2 +- src/order_cmd.cpp | 11 ++++++++++- src/order_gui.cpp | 2 +- src/order_type.h | 3 ++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/economy.cpp b/src/economy.cpp index 7c70bba062..53115d4484 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1730,7 +1730,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left) } 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()) || diff --git a/src/order_base.h b/src/order_base.h index cb770eaa72..e3daa9098c 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -161,7 +161,7 @@ public: 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? */ diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index bbd1c01bd4..9fc94e854f 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -41,6 +41,12 @@ BackuppedOrders _backup_orders_data; 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 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) 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; } diff --git a/src/order_gui.cpp b/src/order_gui.cpp index 9cf98c48ec..76fa29b334 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -194,7 +194,7 @@ static void DrawOrdersWindow(Window *w) 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; diff --git a/src/order_type.h b/src/order_type.h index 1ebbbdc353..7e2548a086 100644 --- a/src/order_type.h +++ b/src/order_type.h @@ -50,7 +50,8 @@ enum OrderUnloadFlags { */ 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. }; /**