nsc: Reject array selectors in conditions

Array selectors were introduced for xdump (commit 612f2da, v4.2.18).
Since there is no syntax for subscripting arrays in conditions and
survey, we silently assume index zero.  Unclean.  Reject the selector
instead.

Affects ship selectors cargostart, cargoend, amtstart, amtend (since
commit 32011f1, v4.2.19), nat selectors relations (commit 0a44c48,
v4.3.0), contacts (commit c345ab8, v4.3.0), rejects (commit 6844c94,
v4.3.4).  The other array selectors aren't visible in conditions.  No
array selectors are visible in survey.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2014-02-02 10:29:18 +01:00
parent b6775d1c9b
commit 355344a82b

View file

@ -445,6 +445,13 @@ nstr_resolve_id(struct valstr *val, struct castr *ca, int idx)
return NULL;
}
if (CA_IS_ARRAY(&ca[idx])) {
pr("%.*s -- not usable here\n",
(int)val->val_as.str.maxsz, val->val_as.str.base);
val->val_cat = NSC_NOCAT;
return NULL;
}
if ((ca[idx].ca_flags & NSC_DEITY) && !player->god) {
pr("%.*s -- not accessible to mortals\n",
(int)val->val_as.str.maxsz, val->val_as.str.base);
@ -514,8 +521,6 @@ nstr_optype(enum nsc_type lft, enum nsc_type rgt)
* Return a pointer to the first character after the value on success,
* NULL on error.
* TYPE is the context type, a file type.
* If STR names an array, VAL simply refers to the element with index
* zero.
*/
char *
nstr_comp_val(char *str, struct valstr *val, int type)