]> granicus.if.org Git - nethack/commitdiff
invent menu fixes (mostly menustyle:Traditional)
authorPatR <rankin@nethack.org>
Sun, 17 Apr 2016 23:50:25 +0000 (16:50 -0700)
committerPatR <rankin@nethack.org>
Sun, 17 Apr 2016 23:50:25 +0000 (16:50 -0700)
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.

doc/fixes36.1
src/invent.c

index 78ad1acc26542840ab834bf815fb9214e6bd483a..93a7da5653ec656ebacaa465ff746010f0be0844 100644 (file)
@@ -205,9 +205,14 @@ when attacking a monster with a rust or corrosion or acid passive
        counter-attack, grease wasn't protecting the attacker's weapon
 the Bell of Opening now correctly reports when it opens a trapdoor/hole
 knocking can no longer send a monster through a trapdoor/hole and desaddle it
-the game no longer gets confused when you break an item while in a different
-    shop
+game no longer gets confused when you break an unpaid shop item while inside
+       a different shop
 shopkeepers now correctly handle nested containers and gold in containers
+for menustyle traditional, 'D' followed by (B|U|C|X)&m presented a menu of
+       everything, not just invent subset matching specified BUCX categories
+for menustyles traditional or combination, 'A' (or object ID) followed by i
+       displayed an inventory of everything rather than just worn items (or
+       not fully identified items)
 
 post-3.6.0: fix "object lost" panic during pickup caused by sortloot revamp
 post-3.6.0: more sortloot revisions
index ae1ce3bd0dcb74577c2fcee983daae9bd3066ce0..6219f833036bac310fa106e433cd382a4bdaac5f 100644 (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 */