summaryrefslogtreecommitdiff
path: root/src/order_base.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-05 23:36:54 +0000
committerrubidium <rubidium@openttd.org>2008-04-05 23:36:54 +0000
commit5b47f81b0f6d46a876a24c0384791af123ac4ab7 (patch)
tree0ddf9ce628e1f7f3677425777bfeb4f04b23d7a0 /src/order_base.h
parent56e63a60447beeae0cc541191ea77f06e237b40a (diff)
downloadopenttd-5b47f81b0f6d46a876a24c0384791af123ac4ab7.tar.xz
(svn r12584) -Codechange: do not access the order type directly.
Diffstat (limited to 'src/order_base.h')
-rw-r--r--src/order_base.h63
1 files changed, 62 insertions, 1 deletions
diff --git a/src/order_base.h b/src/order_base.h
index 267da1321..ada3aad37 100644
--- a/src/order_base.h
+++ b/src/order_base.h
@@ -9,8 +9,10 @@
#include "oldpool.h"
#include "core/bitmath_func.hpp"
#include "cargo_type.h"
+#include "depot_type.h"
#include "station_type.h"
#include "vehicle_type.h"
+#include "waypoint_type.h"
DECLARE_OLD_POOL(Order, Order, 6, 1000)
@@ -20,9 +22,20 @@ DECLARE_OLD_POOL(Order, Order, 6, 1000)
* - REF_ORDER (all REFs are currently limited to 16 bits!!)
*/
struct Order : PoolItem<Order, OrderID, &_Order_pool> {
- Order *next; ///< Pointer to next order. If NULL, end of list
+private:
+ friend const struct SaveLoad *GetVehicleDescription(VehicleType vt); ///< Saving and loading the current order of vehicles.
+ friend void Load_VEHS(); ///< Loading of ancient vehicles.
+ friend const struct SaveLoad *GetOrderDescription(); ///< Saving and loading of orders.
+ friend uint32 PackOrder(const Order *order); ///< 'Compressing' an order.
+ friend Order UnpackOrder(uint32 packed); ///< 'Uncompressing' an order.
+ friend Order UnpackOldOrder(uint16 packed); ///< 'Uncompressing' a loaded old order.
+ friend Order UnpackVersion4Order(uint16 packed); ///< 'Uncompressing' a loaded ancient order.
OrderTypeByte type;
+
+public:
+ Order *next; ///< Pointer to next order. If NULL, end of list
+
uint8 flags;
DestinationID dest; ///< The destionation of the order.
@@ -37,16 +50,64 @@ struct Order : PoolItem<Order, OrderID, &_Order_pool> {
/**
* Check if a Order really exists.
+ * @return true if the order is valid.
*/
inline bool IsValid() const { return this->type != OT_NOTHING; }
/**
+ * Check whether this order is of the given type.
+ * @param type the type to check against.
+ * @return true if the order matches.
+ */
+ inline bool IsType(OrderType type) const { return this->type == type; }
+
+ /**
+ * Get the type of order of this order.
+ * @return the order type.
+ */
+ inline OrderType GetType() const { return this->type; }
+
+ /**
* 'Free' the order
* @note ONLY use on "current_order" vehicle orders!
*/
void Free();
/**
+ * Makes this order a Go To Station order.
+ * @param destsination the station to go to.
+ */
+ void MakeGoToStation(StationID destination);
+
+ /**
+ * 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?
+ */
+ void MakeGoToDepot(DepotID destination, bool order);
+
+ /**
+ * Makes this order a Go To Waypoint order.
+ * @param destination the waypoint to go to.
+ */
+ void MakeGoToWaypoint(WaypointID destination);
+
+ /**
+ * Makes this order a Loading order.
+ */
+ void MakeLoading();
+
+ /**
+ * Makes this order a Leave Station order.
+ */
+ void MakeLeaveStation();
+
+ /**
+ * Makes this order a Dummy order.
+ */
+ void MakeDummy();
+
+ /**
* Free a complete order chain.
* @note do not use on "current_order" vehicle orders!
*/