From: PatR Date: Sat, 28 Oct 2017 21:12:50 +0000 (-0700) Subject: fix #6284 - empty perm_invent X-Git-Tag: NetHack-3.6.1_RC01~231 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=72978d69faa880b1808d549f717445b6a1e3fb96;p=nethack fix #6284 - empty perm_invent 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.) --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 3002f5512..c36858045 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -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 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 diff --git a/src/end.c b/src/end.c index d0fb09bc5..e1d8a6423 100644 --- 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"); diff --git a/src/invent.c b/src/invent.c index 429b5a9d5..edacfc547 100644 --- a/src/invent.c +++ b/src/invent.c @@ -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);