]> granicus.if.org Git - nethack/commitdiff
fix #6284 - empty perm_invent
authorPatR <rankin@nethack.org>
Sat, 28 Oct 2017 21:12:50 +0000 (14:12 -0700)
committerPatR <rankin@nethack.org>
Sat, 28 Oct 2017 21:12:50 +0000 (14:12 -0700)
Report was for tty, but X11 exhibited the same behavior.  With the
perm_invent option enabled, when the permanent inventory window is
displayed, it would be empty if not carrying anything.  For tty, that
meant a naked "(end) " selection prompt.  Put a separator line of "Not
carrying anything" into the menu so that it won't be completely empty.
The selection prompt is still present but it is attached to something.
(The behavior is different from !perm_invent, where you get that same
text via pline without any menu at all.)

doc/fixes36.1
src/end.c
src/invent.c

index 3002f551209c00fc271a158f5a017744f67bcf16..c36858045f3bc5d944398f7cca8a3ebf263b849d 100644 (file)
@@ -466,6 +466,7 @@ sometimes rings dropped into sinks can be found in the pipes
 doors in special levels were always generated in vertical orientation
 assigning a type name to a potion on the floor which is actually a mimic could
        prompt "Call a stream of <potion-type> fluid:" (bogus 'fromsink')
+with perm_invent option enabled and no inventory, 'i' put up an empty menu
 
 
 Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
index d0fb09bc5a5687ef4c6ccbbde680746f0f404ea8..e1d8a64234666b58942e2ab52148af1bf5999025 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -1274,8 +1274,11 @@ int how;
     if (have_windows) {
         wait_synch();
         free_pickinv_cache(); /* extra persistent window if perm_invent */
-        if (WIN_INVEN != WIN_ERR)
+        if (WIN_INVEN != WIN_ERR) {
             destroy_nhwindow(WIN_INVEN),  WIN_INVEN = WIN_ERR;
+            /* precaution in case any late update_inventory() calls occur */
+            flags.perm_invent = 0;
+        }
         display_nhwindow(WIN_MESSAGE, TRUE);
         destroy_nhwindow(WIN_MAP),  WIN_MAP = WIN_ERR;
 #ifndef STATUS_HILITES
@@ -1315,7 +1318,7 @@ int how;
                 ? (const char *) ((flags.female && urole.name.f)
                     ? urole.name.f
                     : urole.name.m)
-            : (const char *) (flags.female ? "Demigoddess" : "Demigod"));
+                : (const char *) (flags.female ? "Demigoddess" : "Demigod"));
     dump_forward_putstr(endwin, 0, pbuf, done_stopprint);
     dump_forward_putstr(endwin, 0, "", done_stopprint);
 
@@ -1350,6 +1353,7 @@ int how;
             Schroedingers_cat = odds_and_ends(invent, CAT_CHECK);
         if (Schroedingers_cat) {
             int mhp, m_lev = adj_lev(&mons[PM_HOUSECAT]);
+
             mhp = d(m_lev, 8);
             nowrap_add(u.urexp, mhp);
             Strcat(eos(pbuf), " and Schroedinger's cat");
index 429b5a9d56acbd29a92a3021a43a24105690d1ae..edacfc5479f369c06477e40ab273218140a4cd2a 100644 (file)
@@ -2180,6 +2180,7 @@ const char *query;
 boolean want_reply;
 long *out_cnt;
 {
+    static const char not_carrying_anything[] = "Not carrying anything";
     struct obj *otmp;
     char ilet, ret;
     char *invlet = flags.inv_order;
@@ -2226,7 +2227,7 @@ long *out_cnt;
         ++n;
 
     if (n == 0) {
-        pline("Not carrying anything.");
+        pline("%s.", not_carrying_anything);
         return 0;
     }
 
@@ -2314,14 +2315,24 @@ nextclass:
             goto nextclass;
         }
     }
-
     if (iflags.force_invmenu && lets && want_reply) {
         any = zeroany;
-        add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings, "Special", MENU_UNSELECTED);
+        add_menu(win, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
+                 "Special", MENU_UNSELECTED);
         any.a_char = '*';
-        add_menu(win, NO_GLYPH, &any, '*', 0, ATR_NONE, "(list everything)", MENU_UNSELECTED);
+        add_menu(win, NO_GLYPH, &any, '*', 0, ATR_NONE,
+                 "(list everything)", MENU_UNSELECTED);
+    }
+    /* for permanent inventory where we intend to show everything but
+       nothing has been listed (because there isn't anyhing to list;
+       recognized via any.a_char still being zero; the n==0 case above
+       gets skipped for perm_invent), put something into the menu */
+    if (flags.perm_invent && !lets && !any.a_char) {
+        any = zeroany;
+        add_menu(win, NO_GLYPH, &any, 0, 0, 0,
+                 not_carrying_anything, MENU_UNSELECTED);
+        want_reply = FALSE;
     }
-
     end_menu(win, query && *query ? query : (char *) 0);
 
     n = select_menu(win, want_reply ? PICK_ONE : PICK_NONE, &selected);