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:
parent
7a4b7f75a0
commit
e7f5b517a0
5 changed files with 37 additions and 3 deletions
|
@ -37,6 +37,7 @@
|
|||
#include "land.h"
|
||||
#include "nsc.h"
|
||||
#include "ship.h"
|
||||
#include "unit.h"
|
||||
#include "update.h"
|
||||
|
||||
void *
|
||||
|
@ -53,6 +54,11 @@ nxtitemp(struct nstr_item *np)
|
|||
if (np->index >= np->size)
|
||||
return 0;
|
||||
np->cur = np->list[np->index];
|
||||
} else if (np->sel == NS_CARGO) {
|
||||
if (np->next < 0)
|
||||
return 0;
|
||||
np->cur = np->next;
|
||||
np->next = unit_cargo_next(np->type, np->next);
|
||||
} else {
|
||||
np->cur++;
|
||||
}
|
||||
|
@ -63,7 +69,7 @@ nxtitemp(struct nstr_item *np)
|
|||
selected = 1;
|
||||
switch (np->sel) {
|
||||
case NS_LIST:
|
||||
break;
|
||||
case NS_CARGO:
|
||||
case NS_ALL:
|
||||
break;
|
||||
case NS_DIST:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue