Clean up struct nstr_sect and struct nstr_item a bit
Members read were always set to ef_read, remove and call directly. Member flag was only assigned to, never used, remove. Change member group to char to match struct empobj.
This commit is contained in:
parent
b10ebe6992
commit
7a4b7f75a0
5 changed files with 9 additions and 29 deletions
|
@ -152,31 +152,28 @@ struct nstr_sect {
|
|||
coord x, y; /* current x-y */
|
||||
coord dx, dy; /* accumlated x,y travel */
|
||||
int id; /* return value of sctoff */
|
||||
enum ns_seltype type; /* type of query */
|
||||
int curdist; /* dist query: current range */
|
||||
enum ns_seltype type; /* selection type: NS_AREA or NS_DIST */
|
||||
int curdist; /* NS_DIST: current range */
|
||||
struct range range; /* area of coverage */
|
||||
int dist; /* dist query: range */
|
||||
coord cx, cy; /* dist query: center x-y */
|
||||
int (*read)(int type, int id, void *ptr); /* read function */
|
||||
int dist; /* NS_DIST: range */
|
||||
coord cx, cy; /* NS_DIST: center x-y */
|
||||
int ncond; /* # of selection conditions */
|
||||
struct nscstr cond[NS_NCOND]; /* selection conditions */
|
||||
struct nscstr cond[NS_NCOND]; /* selection conditions */
|
||||
};
|
||||
|
||||
/* Item iterator */
|
||||
struct nstr_item {
|
||||
int cur; /* current item */
|
||||
enum ns_seltype sel; /* selection type */
|
||||
enum ns_seltype sel; /* selection type, any but NS_UNDEF */
|
||||
int type; /* item type being selected */
|
||||
int curdist; /* if NS_DIST, current item's dist */
|
||||
struct range range; /* NS_AREA/NS_DIST: range selector */
|
||||
int dist; /* NS_DIST: distance selector */
|
||||
coord cx, cy; /* NS_DIST: center x-y, NS_XY: xy */
|
||||
int group; /* NS_GROUP: fleet/wing match */
|
||||
char group; /* NS_GROUP: fleet/wing match */
|
||||
int size; /* NS_LIST: size of list */
|
||||
int index; /* NS_LIST: index */
|
||||
int list[NS_LSIZE]; /* NS_LIST: item list */
|
||||
int (*read)(int type, int id, void *ptr); /* read function */
|
||||
int flags; /* ef_flags(TYPE) */
|
||||
int ncond; /* # of selection conditions */
|
||||
struct nscstr cond[NS_NCOND]; /* selection conditions */
|
||||
};
|
||||
|
|
|
@ -61,10 +61,8 @@ nxtitem(struct nstr_item *np, void *ptr)
|
|||
} else {
|
||||
np->cur++;
|
||||
}
|
||||
if (!np->read(np->type, np->cur, ptr)) {
|
||||
/* if read fails, fatal */
|
||||
if (!ef_read(np->type, np->cur, ptr))
|
||||
return 0;
|
||||
}
|
||||
selected = 1;
|
||||
switch (np->sel) {
|
||||
case NS_LIST:
|
||||
|
|
|
@ -68,7 +68,7 @@ nxtsct(struct nstr_sect *np, struct sctstr *sp)
|
|||
continue;
|
||||
}
|
||||
np->id = sctoff(np->x, np->y);
|
||||
if (!np->read(EF_SECTOR, np->id, sp))
|
||||
if (!ef_read(EF_SECTOR, np->id, sp))
|
||||
continue;
|
||||
if (np->ncond == 0)
|
||||
return 1;
|
||||
|
|
|
@ -125,7 +125,6 @@ snxtitem(struct nstr_item *np, int type, char *str, char *prompt)
|
|||
default:
|
||||
return 0;
|
||||
}
|
||||
np->flags = flags;
|
||||
if (player->condarg == 0)
|
||||
return 1;
|
||||
n = nstr_comp(np->cond, sizeof(np->cond) / sizeof(*np->cond), type,
|
||||
|
@ -143,8 +142,6 @@ snxtitem_area(struct nstr_item *np, int type, struct range *range)
|
|||
np->sel = NS_AREA;
|
||||
np->index = -1;
|
||||
np->range = *range;
|
||||
np->read = ef_read;
|
||||
np->flags = ef_flags(type);
|
||||
xysize_range(&np->range);
|
||||
}
|
||||
|
||||
|
@ -161,8 +158,6 @@ snxtitem_dist(struct nstr_item *np, int type, int cx, int cy,
|
|||
np->cy = cy;
|
||||
np->index = -1;
|
||||
np->dist = dist;
|
||||
np->read = ef_read;
|
||||
np->flags = ef_flags(type);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -176,8 +171,6 @@ snxtitem_xy(struct nstr_item *np, int type, coord x, coord y)
|
|||
np->cy = ynorm(y);
|
||||
np->index = -1;
|
||||
np->dist = 0;
|
||||
np->read = ef_read;
|
||||
np->flags = ef_flags(type);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -188,8 +181,6 @@ snxtitem_all(struct nstr_item *np, int type)
|
|||
np->sel = NS_ALL;
|
||||
np->type = type;
|
||||
np->index = -1;
|
||||
np->read = ef_read;
|
||||
np->flags = ef_flags(type);
|
||||
xysize_range(&np->range);
|
||||
}
|
||||
|
||||
|
@ -204,8 +195,6 @@ snxtitem_group(struct nstr_item *np, int type, char group)
|
|||
np->group = group;
|
||||
np->type = type;
|
||||
np->index = -1;
|
||||
np->read = ef_read;
|
||||
np->flags = ef_flags(type);
|
||||
xysize_range(&np->range);
|
||||
}
|
||||
|
||||
|
@ -226,8 +215,6 @@ snxtitem_list(struct nstr_item *np, int type, int *list, int len)
|
|||
np->type = type;
|
||||
np->sel = NS_LIST;
|
||||
np->index = -1;
|
||||
np->read = ef_read;
|
||||
np->flags = ef_flags(type);
|
||||
if (len <= 0 || len > NS_LSIZE)
|
||||
return 0;
|
||||
for (i = 0; i < len; i++)
|
||||
|
|
|
@ -119,7 +119,6 @@ snxtsct_area(struct nstr_sect *np, struct range *range)
|
|||
np->range = *range;
|
||||
np->ncond = 0;
|
||||
np->type = NS_AREA;
|
||||
np->read = ef_read;
|
||||
np->x = np->range.lx - 1;
|
||||
np->y = np->range.ly;
|
||||
np->dx = -1;
|
||||
|
@ -146,7 +145,6 @@ snxtsct_dist(struct nstr_sect *np, coord cx, coord cy, int dist)
|
|||
np->ncond = 0;
|
||||
np->dist = dist;
|
||||
np->type = NS_DIST;
|
||||
np->read = ef_read;
|
||||
np->x = np->range.lx - 1;
|
||||
np->y = np->range.ly;
|
||||
np->dx = -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue