#define NS_NCOND 16
/* Value type */
-enum nsc_type {
+typedef enum {
NSC_NOTYPE,
/* promoted types */
NSC_LONG, /* long */
NSC_YCOORD, /* coord that needs y conversion */
NSC_TIME, /* time_t */
NSC_FLOAT /* float */
-};
-typedef enum nsc_type nsc_type;
+} nsc_type;
typedef char packed_nsc_type;
/* Value category */
-enum nsc_cat {
+typedef enum {
NSC_NOCAT,
NSC_VAL, /* evaluated value */
NSC_OFF /* symbolic value: at offset in object */
-};
-typedef enum nsc_cat nsc_cat;
+} nsc_cat;
typedef char packed_nsc_cat;
enum {
struct valstr rgt; /* right operand */
};
+/* Selection type */
+typedef enum {
+ NS_UNDEF, /* error value */
+ NS_LIST, /* list of IDs */
+ NS_DIST, /* circular area */
+ NS_AREA, /* rectangular area */
+ NS_ALL, /* everything */
+ NS_XY, /* one sector area */
+ NS_GROUP /* group, i.e. fleet, wing, army */
+} ns_seltype;
+
+/* Sector iterator */
struct nstr_sect {
coord x, y; /* current x-y */
coord dx, dy; /* accumlated x,y travel */
int id; /* return value of sctoff */
- int type; /* type of query */
+ ns_seltype type; /* type of query */
int curdist; /* dist query: current range */
struct range range; /* area of coverage */
int dist; /* dist query: range */
struct nscstr cond[NS_NCOND]; /* selection conditions */
};
+/* Item iterator */
struct nstr_item {
int cur; /* current item */
- int sel; /* selection type */
+ ns_seltype sel; /* selection type */
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 index; /* NS_LIST: index */
int list[NS_LSIZE]; /* NS_LIST: item list */
int (*read)(int type, int id, caddr_t ptr); /* read function */
- int flags; /* EFF_ flags */
+ int flags; /* ef_flags(TYPE) */
int ncond; /* # of selection conditions */
- struct nscstr cond[NS_NCOND]; /* selection conditions */
+ struct nscstr cond[NS_NCOND]; /* selection conditions */
};
-#define NS_UNDEF 0
-#define NS_LIST 1
-#define NS_DIST 2
-#define NS_AREA 3
-#define NS_ALL 4
-#define NS_XY 5
-#define NS_GROUP 6
-
/*
* Selector descriptor.
* Value is at offset CA_OFF in the context object.
extern int check_retreat_and_do_shipdamage(struct shpstr *, int);
extern int check_retreat_and_do_landdamage(struct lndstr *, int);
/* sarg.c */
-extern int sarg_type(s_char *);
+extern ns_seltype sarg_type(s_char *);
extern int sarg_xy(s_char *, coord *, coord *);
extern int sarg_area(s_char *, register struct range *);
extern int sarg_range(s_char *, coord *, coord *, int *);
rada(void)
{
s_char *cp;
- int type;
double tf;
double tech;
struct nstr_item ni;
"Radar from (unit # or sector(s)) : ", buf);
if (cp == 0)
return RET_SYN;
- type = sarg_type(cp);
- if (type == NS_AREA) {
+ switch (sarg_type(cp)) {
+ case NS_AREA:
if (!snxtsct(&ns, cp))
return RET_SYN;
tech = tfact(player->cnum, 8.0);
radmap(sect.sct_x, sect.sct_y, (int)sect.sct_effic,
(int)(tech * 2.0), 0.0);
}
- } else if (type == NS_LIST || type == NS_GROUP) {
+ case NS_LIST:
+ case NS_GROUP:
if (!from_unit) {
/* assumes a NS_LIST return is a shipno */
if (!snxtitem(&ni, EF_SHIP, cp)) {
(int)tech, tf);
}
}
- } else {
+ default:
if (!from_unit)
pr("Must use a ship or sector specifier\n");
else