summaryrefslogtreecommitdiff
path: root/src/order.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-02 23:40:19 +0000
committerrubidium <rubidium@openttd.org>2007-08-02 23:40:19 +0000
commitd751ce56cbd05a12d914016a51f62138eeaa826f (patch)
treef09642f696ca07efc204427f47ac1de75821eb38 /src/order.h
parente4149482ec1c1d5424327983df2ebf2419ffe273 (diff)
downloadopenttd-d751ce56cbd05a12d914016a51f62138eeaa826f.tar.xz
(svn r10760) -Codechange: make the order struct use the pool item class as super class.
Diffstat (limited to 'src/order.h')
-rw-r--r--src/order.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/order.h b/src/order.h
index 30d59517c..987b36a0d 100644
--- a/src/order.h
+++ b/src/order.h
@@ -83,26 +83,30 @@ enum {
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:
* - Load_ORDR, all the global orders
* - Vehicle -> current_order
* - REF_ORDER (all REFs are currently limited to 16 bits!!)
*/
-struct Order {
+struct Order : PoolItem<Order, OrderID, &_Order_pool> {
Order *next; ///< Pointer to next order. If NULL, end of list
OrderTypeByte type;
uint8 flags;
DestinationID dest; ///< The destionation of the order.
- OrderID index; ///< Index of the order, is not saved or anything, just for reference
-
CargoID refit_cargo; // Refit CargoID
byte refit_subtype; // Refit subtype
uint16 wait_time; ///< How long in ticks to wait at the destination.
uint16 travel_time; ///< How long in ticks the journey to this destination should take.
+ Order() : refit_cargo(CT_NO_REFIT) {}
+ ~Order() { this->type = OT_NOTHING; }
+
bool IsValid() const;
void Free();
void FreeChain();
@@ -121,8 +125,6 @@ struct BackuppedOrders {
VARDEF TileIndex _backup_orders_tile;
VARDEF BackuppedOrders _backup_orders_data[1];
-DECLARE_OLD_POOL(Order, Order, 6, 1000)
-
static inline VehicleOrderID GetMaxOrderIndex()
{
/* TODO - This isn't the real content of the function, but
@@ -143,21 +145,21 @@ static inline VehicleOrderID GetNumOrders()
*/
inline bool Order::IsValid() const
{
- return type != OT_NOTHING;
+ return this->type != OT_NOTHING;
}
inline void Order::Free()
{
- type = OT_NOTHING;
- flags = 0;
- dest = 0;
- next = NULL;
+ this->type = OT_NOTHING;
+ this->flags = 0;
+ this->dest = 0;
+ this->next = NULL;
}
inline void Order::FreeChain()
{
if (next != NULL) next->FreeChain();
- Free();
+ delete this;
}
#define FOR_ALL_ORDERS_FROM(order, start) for (order = GetOrder(start); order != NULL; order = (order->index + 1U < GetOrderPoolSize()) ? GetOrder(order->index + 1U) : NULL) if (order->IsValid())