/*
* 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
* ---
*
* snxtitem.c: Arrange item selection using one of many criteria.
- *
+ *
* Known contributors to this file:
* Dave Pare, 1989
* Markus Armbruster, 2008
#include "nsc.h"
#include "file.h"
#include "prototypes.h"
+#include "unit.h"
/*
* setup the nstr structure for sector selection.
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);
+}