]> git.pond.sub.org Git - empserver/blobdiff - src/lib/subs/snxtitem.c
Update copyright notice
[empserver] / src / lib / subs / snxtitem.c
index 1e799fa33b3e69de52aef728a19daa9edfe508c6..47cb7dae4d294aa52210f6b91df3c973ad1e5797 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -26,7 +26,7 @@
  *  ---
  *
  *  snxtitem.c: Arrange item selection using one of many criteria.
- * 
+ *
  *  Known contributors to this file:
  *     Dave Pare, 1989
  *     Markus Armbruster, 2008
@@ -41,6 +41,7 @@
 #include "nsc.h"
 #include "file.h"
 #include "prototypes.h"
+#include "unit.h"
 
 /*
  * setup the nstr structure for sector selection.
@@ -222,3 +223,21 @@ snxtitem_list(struct nstr_item *np, int type, int *list, int len)
     np->size = len;
     return 1;
 }
+
+/*
+ * Initialize NP to iterate over the items of type TYPE in a carrier.
+ * The carrier has file type CARRIER_TYPE and uid CARRIER_UID.
+ * Note: you can take an item gotten with nxtitem() off its carrier
+ * without disturbing the iterator.  Whether the iterator will pick up
+ * stuff you load onto the carrier during iteration is unspecified.
+ */
+void
+snxtitem_cargo(struct nstr_item *np, int type,
+              int carrier_type, int carrier_uid)
+{
+    memset(np, 0, sizeof(*np));
+    np->cur = -1;
+    np->type = type;
+    np->sel = NS_CARGO;
+    np->next = unit_cargo_first(carrier_type, carrier_uid, type);
+}