From c8afd40eb8d186de37749ceb784a3575d00cbcfa Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 4 Aug 2004 14:47:24 +0000 Subject: [PATCH] (nstr_comp_val): Since rev. 1.10, selectors were always preferred to type literals, unless type inference rejects the selector. This doesn't work for NSC_TYPE selectors: `?des=n' is interpreted as `?des=newdes'. Prefer type literal to NSC_TYPE selector. Closes #982021. --- src/lib/subs/nstr.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lib/subs/nstr.c b/src/lib/subs/nstr.c index 501ba28b..5bfaeb33 100644 --- a/src/lib/subs/nstr.c +++ b/src/lib/subs/nstr.c @@ -221,9 +221,19 @@ nstr_comp_val(char *str, struct valstr*val, int type) sizeof(struct castr)); if (j >= 0 && (!(cap[j].ca_flags & NSC_DEITY) || player->god)) { - val->val_type = cap[j].ca_type; - val->val_cat = NSC_OFF; - val->val_as.off = cap[j].ca_off; + if (cap[j].ca_type == NSC_TYPEID && val->val_as_type >= 0) + /* + * Got two matches of type NSC_TYPEID, need to + * choose. Prefer typematch(), because ?des=n + * would be interpreted as ?des=newdes + * otherwise + */ + ; + else { + val->val_type = cap[j].ca_type; + val->val_cat = NSC_OFF; + val->val_as.off = cap[j].ca_off; + } } } else j = M_NOTFOUND;