summaryrefslogtreecommitdiff
path: root/order.h
diff options
context:
space:
mode:
Diffstat (limited to 'order.h')
-rw-r--r--order.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/order.h b/order.h
index 0afaa48e9..5d0bdb204 100644
--- a/order.h
+++ b/order.h
@@ -117,7 +117,15 @@ static inline uint16 GetOrderPoolSize(void)
return _order_pool.total_items;
}
-#define FOR_ALL_ORDERS_FROM(order, start) for (order = GetOrder(start); order != NULL; order = (order->index + 1 < GetOrderPoolSize()) ? GetOrder(order->index + 1) : NULL)
+/**
+ * Check if a Order really exists.
+ */
+static inline bool IsValidOrder(const Order *o)
+{
+ return o->type != OT_NOTHING;
+}
+
+#define FOR_ALL_ORDERS_FROM(order, start) for (order = GetOrder(start); order != NULL; order = (order->index + 1 < GetOrderPoolSize()) ? GetOrder(order->index + 1) : NULL) if (IsValidOrder(order))
#define FOR_ALL_ORDERS(order) FOR_ALL_ORDERS_FROM(order, 0)