invent menu fixes (mostly menustyle:Traditional)

For menustyle:Traditional, the object class prompt for 'D' includes
an entry choice of 'm' to request a menu.  Supplying real classes
and 'm' resulted in a menu limited to those classes, as intended,
but any of BUCX for curse/bless state and 'm' without any actual
classes resulted in a menu of entire invent.  A one-line fix once
the proper place for that fix was located.

For menustyle:Traditional or menustyle:Combination, 'A' includes an
extra choice of 'i' to examine relevant inventory prior to choosing
object classes (and object identification also offers that), but
the inventory display showed everything rather than just the items
applicable to 'A' (or to object ID).  Figuring out where to apply
the fix was trivial, but the fix itself was a bit more involved and
it exposed a latent bug in display_pickinv(): "" was supposed to be
the same as NULL when passed in as list of target inventory letters,
but it wasn't being handled correctly.
This commit is contained in:
PatR
2016-04-17 16:50:25 -07:00
parent 8132cb5a42
commit d02ba84684
2 changed files with 27 additions and 7 deletions

View File

@@ -1594,13 +1594,23 @@ unsigned *resultflags;
ilets[iletct] = '\0';
for (;;) {
Sprintf(qbuf, "What kinds of thing do you want to %s? [%s]", word,
ilets);
Sprintf(qbuf, "What kinds of thing do you want to %s? [%s]",
word, ilets);
getlin(qbuf, buf);
if (buf[0] == '\033')
return 0;
if (index(buf, 'i')) {
if (display_inventory((char *) 0, TRUE) == '\033')
char ailets[1+26+26+1+5+1]; /* $ + a-z + A-Z + # + slop + \0 */
struct obj *otmp;
/* applicable inventory letters; if empty, show entire invent */
ailets[0] = '\0';
if (ofilter)
for (otmp = invent; otmp; otmp = otmp->nobj)
/* index() check: limit overflow items to one '#' */
if ((*ofilter)(otmp) && !index(ailets, otmp->invlet))
(void) strkitten(ailets, otmp->invlet);
if (display_inventory(ailets, TRUE) == '\033')
return 0;
} else
break;
@@ -1684,7 +1694,9 @@ unsigned *resultflags;
}
if (m_seen) {
return (allflag || (!oletct && ckfn != ckunpaid)) ? -2 : -3;
return (allflag
|| (!oletct && ckfn != ckunpaid && ckfn != ckvalidcat))
? -2 : -3;
} else if (flags.menu_style != MENU_TRADITIONAL && combo && !allflag) {
return 0;
#if 0
@@ -2137,7 +2149,10 @@ long *out_cnt;
anything any;
menu_item *selected;
if (flags.perm_invent && ((lets && *lets) || xtra_choice)) {
if (lets && !*lets)
lets = 0; /* simplify tests: (lets) instead of (lets && *lets) */
if (flags.perm_invent && (lets || xtra_choice)) {
/* partial inventory in perm_invent setting; don't operate on
full inventory window, use an alternate one instead; create
the first time needed and keep it for re-use as needed later */