summaryrefslogtreecommitdiff
path: root/src/order_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-05 20:57:01 +0000
committerrubidium <rubidium@openttd.org>2008-04-05 20:57:01 +0000
commit21ae6fa4446cc68d66d3639c1a18f7ece5422390 (patch)
tree67a701930ea78526c28cf16af313d5564a1ac57f /src/order_cmd.cpp
parentb5a73c77deef0683e1baacd0cd465c0132bf74cd (diff)
downloadopenttd-21ae6fa4446cc68d66d3639c1a18f7ece5422390.tar.xz
(svn r12582) -Codechange: move some (needlessly) static inlined functions from order_base.h to order_cmd.cpp.
Diffstat (limited to 'src/order_cmd.cpp')
-rw-r--r--src/order_cmd.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 723d56fec..9debcdd96 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -40,6 +40,52 @@ BackuppedOrders _backup_orders_data;
DEFINE_OLD_POOL_GENERIC(Order, Order)
+void Order::Free()
+{
+ this->type = OT_NOTHING;
+ this->flags = 0;
+ this->dest = 0;
+ this->next = NULL;
+}
+
+void Order::FreeChain()
+{
+ if (next != NULL) next->FreeChain();
+ delete this;
+}
+
+static bool HasOrderPoolFree(uint amount)
+{
+ const Order *order;
+
+ /* There is always room if not all blocks in the pool are reserved */
+ if (_Order_pool.CanAllocateMoreBlocks()) return true;
+
+ FOR_ALL_ORDERS(order) if (!order->IsValid() && --amount == 0) return true;
+
+ return false;
+}
+
+uint32 PackOrder(const Order *order)
+{
+ return order->dest << 16 | order->flags << 8 | order->type;
+}
+
+Order UnpackOrder(uint32 packed)
+{
+ Order order;
+ order.type = (OrderType)GB(packed, 0, 8);
+ order.flags = GB(packed, 8, 8);
+ order.dest = GB(packed, 16, 16);
+ order.next = NULL;
+ order.index = 0; // avoid compiler warning
+ order.refit_cargo = CT_NO_REFIT;
+ order.refit_subtype = 0;
+ order.wait_time = 0;
+ order.travel_time = 0;
+ return order;
+}
+
/**
*
* Unpacks a order from savegames made with TTD(Patch)