From 701356341516334d1d6deabb884becf3ced1c03d Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 28 Jun 2019 12:50:08 -0700 Subject: [PATCH] ^I vs perm_invent again A recent fix for #wizidentify showing "Not carrying anything" after listing inventory items still showed "Not carrying anything" after "(all items are already identified)". Fix is easy. Trickier bug was that ^I performs object ID on selected items while the inventory routine is still in progress (but after it has processed every item) and the ID routine will call update_inventory() which will call the inventory routine to reformat invent. So the inventory display routine was called recursively without having returned to wizidentify where iflags.override_ID gets cleared to revert to normal inventory. The nested call was unintentionally narrowing the contents of persistent inventory window to whatever items were still unIDed. (Any inventory update, including ^R, restored it to full inventory.) --- doc/fixes36.3 | 7 ++++++- src/invent.c | 13 +++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index a46c815b8..5b177c06e 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.76 $ $NHDT-Date: 1561750114 2019/06/28 19:28:34 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.77 $ $NHDT-Date: 1561751390 2019/06/28 19:49:50 $ This fixes36.3 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.2 in May 2019. Please note, however, @@ -86,6 +86,9 @@ partly eaten food with one bite left had message anomalies when eaten; the resulted in no messages at all when restarting and finishing last bite wizard mode ^I menu could list "Not carrying anything" after inventory items if perm_invent option was On (even on tty where that's not supported) +wizard mode ^I with 'perm_invent' On would unintentionally filter the content + of the persistent inventory window to unIDed items if any item got + chosen to be identified (^R would fix it, as would any invent change) change #adjust to treat carrying only gold as not having anything to adjust saving bones with 'perm_invent' On could result in "Bad fruit #N" warnings update persistent inventory window immediately if 'sortpack' option is toggled @@ -103,6 +106,8 @@ for wizard mode 'wizweight' option, glob weight wasn't shown unless glob had shop price information attached fix for feedback when a monster plays a fire horn at self to cure green slime ended up being used for zapping a wand of fire at self too +wizard mode ^I "not carrying anything" still claimed "not carrying anything" + if "(all items are already identified)" was given curses: sometimes the message window would show a blank line after a prompt curses: the change to show map in columns 1..79 instead of 2..80 made the highlight for '@' show up in the wrong place if clipped map had been diff --git a/src/invent.c b/src/invent.c index a4175e2a8..fc76a57a4 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 invent.c $NHDT-Date: 1561314651 2019/06/23 18:30:51 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.259 $ */ +/* NetHack 3.6 invent.c $NHDT-Date: 1561751391 2019/06/28 19:49:51 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.260 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2550,12 +2550,12 @@ long *out_cnt; menu_item *selected; unsigned sortflags; Loot *sortedinvent, *srtinv; - boolean wizid = FALSE, gotsomething = FALSE; + boolean wizid = (wizard && iflags.override_ID), gotsomething = FALSE; if (lets && !*lets) lets = 0; /* simplify tests: (lets) instead of (lets && *lets) */ - if (iflags.perm_invent && (lets || xtra_choice)) { + if (iflags.perm_invent && (lets || xtra_choice || wizid)) { /* 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 */ @@ -2647,6 +2647,7 @@ long *out_cnt; add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "(all items are permanently identified already)", MENU_UNSELECTED); + gotsomething = TRUE; } else { any.a_obj = &wizid_fakeobj; Sprintf(prompt, "select %s to permanently identify", @@ -2661,7 +2662,7 @@ long *out_cnt; visctrl(iflags.override_ID)); add_menu(win, NO_GLYPH, &any, '_', iflags.override_ID, ATR_NONE, prompt, MENU_UNSELECTED); - wizid = gotsomething = TRUE; + gotsomething = TRUE; } } else if (xtra_choice) { /* wizard override ID and xtra_choice are mutually exclusive */ @@ -2737,6 +2738,10 @@ long *out_cnt; if (wizid) { int i; + /* identifying items will update perm_invent, calling this + routine recursively, and we don't want the nested call + to filter on unID'd items */ + iflags.override_ID = 0; ret = '\0'; for (i = 0; i < n; ++i) { otmp = selected[i].item.a_obj;