(nstr_promote, nstr_exec_val): Implement.
(nstr_exec_val): Ignored IDX for NSC_STRING values.
(nstr_exec): Implement NSC_STRING.
(ship_ca): New selector name.
NSC_YCOORD, /* coord that needs y conversion */
NSC_TIME, /* time_t */
NSC_FLOAT, /* float */
+ NSC_STRINGY, /* char[], zero-terminated string */
/* aliases, must match typedefs */
NSC_NATID = NSC_UCHAR /* nation id */
} nsc_type;
{NSC_TIME, 0, 0, fldoff(shpstr, shp_access), "access"},
{NSC_TIME, 0, 0, fldoff(shpstr, shp_timestamp), "timestamp"},
/* FIXME sail stuff missing */
- /* FIXME name missing */
+ {NSC_STRINGY, 0, 0, fldoff(shpstr, shp_name), "name"},
{NSC_UCHAR, 0, 0, fldoff(shpstr, shp_fuel), "fuel"},
{NSC_UCHAR, 0, 0, fldoff(shpstr, shp_nchoppers), "nchoppers"},
{NSC_UCHAR, 0, 0, fldoff(shpstr, shp_nxlight), "nxlight"},
int
nstr_exec(struct nscstr *np, int ncond, void *ptr)
{
- int i, op, optype;
+ int i, op, optype, cmp;
struct valstr lft, rgt;
for (i = 0; i < ncond; ++i) {
return 0;
break;
case NSC_STRING:
- CANT_HAPPEN("unimplemented OPTYPE"); /* FIXME */
+ cmp = strcmp(lft.val_as.str, rgt.val_as.str);
+ if (!EVAL(op, cmp, 0))
+ return 0;
return 0;
default:
CANT_HAPPEN("bad OPTYPE");
* Promote VALTYPE.
* If VALTYPE is an integer type, return NSC_LONG.
* If VALTYPE is a floating-point type, return NSC_DOUBLE.
+ * If VALTYPE is NSC_STRINGY, return NSC_STRING.
* If VALTYPE is NSC_NOTYPE, NSC_STRING or NSC_TYPEID, return VALTYPE.
*/
static int
case NSC_FLOAT:
valtype = NSC_DOUBLE;
break;
+ case NSC_STRINGY:
+ valtype = NSC_STRING;
+ break;
default:
CANT_HAPPEN("bad VALTYPE");
valtype = NSC_NOTYPE;
val->val_as.dbl = ((double *)memb_ptr)[idx];
valtype = NSC_DOUBLE;
break;
+ case NSC_STRINGY:
+ CANT_HAPPEN(idx);
+ val->val_as.str = (char *)memb_ptr;
+ valtype = NSC_STRING;
+ break;
case NSC_STRING:
- val->val_as.str = *(char **)memb_ptr;
+ val->val_as.str = ((char **)memb_ptr)[idx];
valtype = NSC_STRING;
break;
case NSC_TIME: