summaryrefslogtreecommitdiff
path: root/src/order_base.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-06 07:22:26 +0000
committerrubidium <rubidium@openttd.org>2008-04-06 07:22:26 +0000
commit8cd1795fe32fc2afaa75f48b8b62ff992bf8f618 (patch)
tree94d7efcddd239260e27551baae6bc2aebe3a5f14 /src/order_base.h
parente68b2088ce090c1eaf182e120195d8453f4f02c2 (diff)
downloadopenttd-8cd1795fe32fc2afaa75f48b8b62ff992bf8f618.tar.xz
(svn r12587) -Codechange: unduplicate some code in the Unpack*Order functions and move the 'normal' case Pack/Unpack to Order.
Diffstat (limited to 'src/order_base.h')
-rw-r--r--src/order_base.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/order_base.h b/src/order_base.h
index 8acea0069..9fc7514ac 100644
--- a/src/order_base.h
+++ b/src/order_base.h
@@ -26,10 +26,6 @@ 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; ///< The type of order
@@ -49,6 +45,12 @@ public:
~Order() { this->type = OT_NOTHING; }
/**
+ * Create an order based on a packed representation of that order.
+ * @param packed the packed representation.
+ */
+ Order(uint32 packed);
+
+ /**
* Check if a Order really exists.
* @return true if the order is valid.
*/
@@ -158,6 +160,14 @@ public:
* @return true if the type, flags and destination match.
*/
bool Equals(const Order &other) const;
+
+ /**
+ * Pack this order into a 32 bits integer, or actually only
+ * the type, flags and destination.
+ * @return the packed representation.
+ * @note unpacking is done in the constructor.
+ */
+ uint32 Pack() const;
};
static inline VehicleOrderID GetMaxOrderIndex()
@@ -182,8 +192,6 @@ static inline VehicleOrderID GetNumOrders()
#define FOR_VEHICLE_ORDERS(v, order) for (order = v->orders; order != NULL; order = order->next)
/* (Un)pack routines */
-uint32 PackOrder(const Order *order);
-Order UnpackOrder(uint32 packed);
Order UnpackOldOrder(uint16 packed);
#endif /* ORDER_H */