Make the item iterator capable of iterating over a cargo list

New snxtitem_cargo() initializes an iterator for a cargo list, with
new enum ns_seltype member NS_GROUP and new struct nstr_item member
next.  Extend nxtitem() and nxtitemp() to step through the list.
This commit is contained in:
Markus Armbruster 2008-09-12 18:46:54 -04:00
parent 7a4b7f75a0
commit e7f5b517a0
5 changed files with 37 additions and 3 deletions

View file

@ -144,7 +144,8 @@ enum ns_seltype {
NS_AREA, /* rectangular area */
NS_ALL, /* everything */
NS_XY, /* one sector area */
NS_GROUP /* group, i.e. fleet, wing, army */
NS_GROUP, /* group, i.e. fleet, wing, army */
NS_CARGO /* loaded on the same carrier */
};
/* Sector iterator */
@ -171,6 +172,7 @@ struct nstr_item {
int dist; /* NS_DIST: distance selector */
coord cx, cy; /* NS_DIST: center x-y, NS_XY: xy */
char group; /* NS_GROUP: fleet/wing match */
short next; /* NS_CARGO: next item */
int size; /* NS_LIST: size of list */
int index; /* NS_LIST: index */
int list[NS_LSIZE]; /* NS_LIST: item list */

View file

@ -674,6 +674,7 @@ extern void snxtitem_all(struct nstr_item *, int);
extern void snxtitem_group(struct nstr_item *, int, char);
extern void snxtitem_rewind(struct nstr_item *);
extern int snxtitem_list(struct nstr_item *, int, int *, int);
extern void snxtitem_cargo(struct nstr_item *, int, int, int);
/* snxtsct.c */
extern int snxtsct(struct nstr_sect *, char *);
extern void snxtsct_area(struct nstr_sect *, struct range *);