Selector rewrite: values other than long, interpret identifiers
according to context, to make `lstat * ?type#spy&spy>1' work. Closes bug#825363, #905809, #905814 and #922968. (nsc_type, packed_nsc_type, nsc_cat, packed_nsc_cat, nsc_flags): New. (valstr): New. Old code encoded values in type long, which was somewhat hard to read and could only support signed integer values. (nscstr): Redesign. Use valstr. Typed operator. (castr): Split ca_code into ca_type, ca_flags, ca_off. Tables changed. (nstr_comp, nstr_exec): Redesign and rewrite. Callers changed. They used the old design incorrectly, which let players smash the stack by supplying more than NCOND conditions. (encode, nstr_comp_val, decode, nstr_exec_val): Rename, redesign, and rewrite. Callers changed. (nstr_coerce_val): New. (var_ca, sect_ca, ship_ca, land_ca): Checking both var_ca[] and the object's ca complicates proper recognition of unique abbreviations. Copy contents of var_ca[] into the ca of objects, remove var_ca[]. (surv): Reject values with category other than NSC_OFF and types that can't be coerced to NSC_LONG. Old code happily passed values with category NSC_VAL to code_char(). The previous version interpreted them correctly, but earlier versions interpreted them as NSC_OFF, then logged `bad type in decode: 0' and evaluated them into zero. (code_char): Used to test category NSC_VAR to decide whether to display tens or hundreds. NSC_VAR no longer exists. Test type instead. Makes more sense anyway.
This commit is contained in:
parent
47c8a32ae3
commit
4366c5ac6e
13 changed files with 726 additions and 544 deletions
|
@ -50,7 +50,6 @@
|
|||
int
|
||||
snxtitem(register struct nstr_item *np, int type, s_char *str)
|
||||
{
|
||||
register s_char *cp;
|
||||
struct range range;
|
||||
int list[NS_LSIZE];
|
||||
int n;
|
||||
|
@ -120,11 +119,10 @@ snxtitem(register struct nstr_item *np, int type, s_char *str)
|
|||
np->flags = flags;
|
||||
if (player->condarg == 0)
|
||||
return 1;
|
||||
cp = player->condarg;
|
||||
while ((cp = nstr_comp(np->cond, &np->ncond, type, cp)) && *cp) ;
|
||||
if (cp == 0)
|
||||
return 0;
|
||||
return 1;
|
||||
n = nstr_comp(np->cond, sizeof(np->cond) / sizeof(*np->cond), type,
|
||||
player->condarg);
|
||||
np->ncond = n >= 0 ? n : 0;
|
||||
return n >= 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue