From 4c63dd074e84cff5ef94cc8e03a841f676b25e92 Mon Sep 17 00:00:00 2001
From: rubidium <rubidium@openttd.org>
Date: Fri, 28 Mar 2008 16:36:32 +0000
Subject: [PATCH] (svn r12470) -Codechange: split order related types from
 order.h (and openttd.h) to order_type.h.

---
 projects/openttd_vs80.vcproj |  4 ++
 projects/openttd_vs90.vcproj |  4 ++
 source.list                  |  1 +
 src/openttd.h                |  2 -
 src/order.h                  | 79 +------------------------------
 src/order_type.h             | 90 ++++++++++++++++++++++++++++++++++++
 src/vehicle_gui.cpp          |  9 ++++
 src/vehicle_gui.h            |  1 +
 src/window_gui.h             |  9 ----
 9 files changed, 110 insertions(+), 89 deletions(-)
 create mode 100644 src/order_type.h

diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 5dae4b1d64..03f7ee3d77 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -1191,6 +1191,10 @@
 				RelativePath=".\..\src\order.h"
 				>
 			</File>
+			<File
+				RelativePath=".\..\src\order_type.h"
+				>
+			</File>
 			<File
 				RelativePath=".\..\src\core\overflowsafe_type.hpp"
 				>
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index 058034e304..0413859e5c 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -1188,6 +1188,10 @@
 				RelativePath=".\..\src\order.h"
 				>
 			</File>
+			<File
+				RelativePath=".\..\src\order_type.h"
+				>
+			</File>
 			<File
 				RelativePath=".\..\src\core\overflowsafe_type.hpp"
 				>
diff --git a/source.list b/source.list
index 46fda4ddc4..554aec12f0 100644
--- a/source.list
+++ b/source.list
@@ -206,6 +206,7 @@ video/null_v.h
 oldpool.h
 openttd.h
 order.h
+order_type.h
 core/overflowsafe_type.hpp
 pathfind.h
 player_base.h
diff --git a/src/openttd.h b/src/openttd.h
index 53be15a00b..e19dd22d64 100644
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -12,7 +12,6 @@
 struct Waypoint;
 struct ViewPort;
 struct DrawPixelInfo;
-typedef byte VehicleOrderID;  ///< The index of an order within its current vehicle (not pool related)
 typedef byte LandscapeID;
 typedef uint16 EngineID;
 typedef uint16 UnitID;
@@ -21,7 +20,6 @@ typedef EngineID *EngineList; ///< engine list type placeholder acceptable for C
 
 /* IDs used in Pools */
 typedef uint16 WaypointID;
-typedef uint16 OrderID;
 typedef uint16 SignID;
 typedef uint16 EngineRenewID;
 
diff --git a/src/order.h b/src/order.h
index b9557adce0..2e0a3eeb73 100644
--- a/src/order.h
+++ b/src/order.h
@@ -5,6 +5,7 @@
 #ifndef ORDER_H
 #define ORDER_H
 
+#include "order_type.h"
 #include "oldpool.h"
 #include "core/bitmath_func.hpp"
 #include "cargo_type.h"
@@ -13,84 +14,6 @@
 #include "date_type.h"
 #include "group_type.h"
 
-typedef uint16 DestinationID;
-
-enum {
-	INVALID_VEH_ORDER_ID = 0xFF,
-};
-
-static const OrderID INVALID_ORDER = 0xFFFF;
-
-/* Order types */
-enum OrderType {
-	OT_BEGIN         = 0,
-	OT_NOTHING       = 0,
-	OT_GOTO_STATION  = 1,
-	OT_GOTO_DEPOT    = 2,
-	OT_LOADING       = 3,
-	OT_LEAVESTATION  = 4,
-	OT_DUMMY         = 5,
-	OT_GOTO_WAYPOINT = 6,
-	OT_END
-};
-
-/* It needs to be 8bits, because we save and load it as such */
-/** Define basic enum properties */
-template <> struct EnumPropsT<OrderType> : MakeEnumPropsT<OrderType, byte, OT_BEGIN, OT_END, OT_END> {};
-typedef TinyEnumT<OrderType> OrderTypeByte;
-
-
-/* Order flags -- please use OF instead OF and use HASBIT/SETBIT/CLEARBIT */
-
-/** Order flag masks - these are for direct bit operations */
-enum OrderFlagMasks {
-	//Flags for stations:
-	/** vehicle will transfer cargo (i. e. not deliver to nearby industry/town even if accepted there) */
-	OFB_TRANSFER           = 0x1,
-	/** 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_PART_OF_ORDERS     = 0x2,
-	/** if OFB_PART_OF_ORDERS is not set, this will cause the vehicle to be stopped in the depot */
-	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.
-
-	//Common flags
-	/** This causes the vehicle not to stop at intermediate OR the destination station (depending on patch settings)
-	  * @todo make this two different flags */
-	OFB_NON_STOP           = 0x8
-};
-
-/** 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 {
-	CO_SHARE   = 0,
-	CO_COPY    = 1,
-	CO_UNSHARE = 2
-};
-
-struct Order;
 DECLARE_OLD_POOL(Order, Order, 6, 1000)
 
 /* If you change this, keep in mind that it is saved on 3 places:
diff --git a/src/order_type.h b/src/order_type.h
new file mode 100644
index 0000000000..3517bdc714
--- /dev/null
+++ b/src/order_type.h
@@ -0,0 +1,90 @@
+/* $Id$ */
+
+/** @file order_type.h Types related to orders. */
+
+#ifndef ORDER_TYPE_H
+#define ORDER_TYPE_H
+
+#include "core/enum_type.hpp"
+
+typedef byte VehicleOrderID;  ///< The index of an order within its current vehicle (not pool related)
+typedef uint16 OrderID;
+
+enum {
+	INVALID_VEH_ORDER_ID = 0xFF,
+};
+
+static const OrderID INVALID_ORDER = 0xFFFF;
+
+/* Order types */
+enum OrderType {
+	OT_BEGIN         = 0,
+	OT_NOTHING       = 0,
+	OT_GOTO_STATION  = 1,
+	OT_GOTO_DEPOT    = 2,
+	OT_LOADING       = 3,
+	OT_LEAVESTATION  = 4,
+	OT_DUMMY         = 5,
+	OT_GOTO_WAYPOINT = 6,
+	OT_END
+};
+
+/* It needs to be 8bits, because we save and load it as such */
+/** Define basic enum properties */
+template <> struct EnumPropsT<OrderType> : MakeEnumPropsT<OrderType, byte, OT_BEGIN, OT_END, OT_END> {};
+typedef TinyEnumT<OrderType> OrderTypeByte;
+
+
+/* Order flags -- please use OF instead OF and use HASBIT/SETBIT/CLEARBIT */
+
+/** Order flag masks - these are for direct bit operations */
+enum OrderFlagMasks {
+	//Flags for stations:
+	/** vehicle will transfer cargo (i. e. not deliver to nearby industry/town even if accepted there) */
+	OFB_TRANSFER           = 0x1,
+	/** 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_PART_OF_ORDERS     = 0x2,
+	/** if OFB_PART_OF_ORDERS is not set, this will cause the vehicle to be stopped in the depot */
+	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.
+
+	//Common flags
+	/** This causes the vehicle not to stop at intermediate OR the destination station (depending on patch settings)
+	  * @todo make this two different flags */
+	OFB_NON_STOP           = 0x8
+};
+
+/** 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 {
+	CO_SHARE   = 0,
+	CO_COPY    = 1,
+	CO_UNSHARE = 2
+};
+
+struct Order;
+
+#endif /* ORDER_TYPE_H */
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index c19badd40f..f9495aeef9 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -40,6 +40,15 @@
 #include "table/sprites.h"
 #include "table/strings.h"
 
+struct refit_d {
+	int sel;
+	struct RefitOption *cargo;
+	struct RefitList *list;
+	uint length;
+	VehicleOrderID order;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d));
+
 struct Sorting {
 	Listing aircraft;
 	Listing roadveh;
diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h
index 3c27c9e09b..e62c67ddf4 100644
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -7,6 +7,7 @@
 
 #include "window_gui.h"
 #include "vehicle_type.h"
+#include "order_type.h"
 #include "station_type.h"
 
 void DrawVehicleProfitButton(const Vehicle *v, int x, int y);
diff --git a/src/window_gui.h b/src/window_gui.h
index de3c2f231b..0787e9cb40 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -361,15 +361,6 @@ struct smallmap_d {
 };
 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(smallmap_d));
 
-struct refit_d {
-	int sel;
-	struct RefitOption *cargo;
-	struct RefitList *list;
-	uint length;
-	VehicleOrderID order;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(refit_d));
-
 struct vp_d {
 	VehicleID follow_vehicle;
 	int32 scrollpos_x;