curses: interactively toggling 'perm_invent' On

Enabling perm_invent with 'O' ('m O' these days) with curses used to
work but stopped at some point.  Analysis by entrez has attributed
the change to the g.program_state.in_docrt flag in docrt().  When
curses creates the perm_invent window for update_inventory(), it
calls docrt() to have nethack redraw the screen.

 docrt() -> update_inventory() -> curses_update_inventory() -> ...
  -> curs_reset_windows() -> doredraw() -> docrt() [early return]

resulted in room for the persistent inventory window but it was
blank.

This also replaces a couple of doredraw() calls with direct calls to
docrt() (one in code that isn't used).  doredraw() implements a user
command; docrt() does the actual redrawing.
This commit is contained in:
PatR
2022-08-16 15:23:37 -07:00
parent 1900a30323
commit 5c7f2945da
3 changed files with 18 additions and 3 deletions

View File

@@ -8126,7 +8126,8 @@ doset(void) /* changing options via menu by Per Liboriussen */
Sprintf(buf, fmtstr_doset_tab,
name, *bool_p ? "true" : "false");
if (pass == 0)
enhance_menu_text(buf, sizeof buf, pass, bool_p, &allopt[i]);
enhance_menu_text(buf, sizeof buf, pass, bool_p,
&allopt[i]);
add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0,
ATR_NONE, clr, buf, MENU_ITEMFLAGS_NONE);
}
@@ -8266,6 +8267,20 @@ doset(void) /* changing options via menu by Per Liboriussen */
check_gold_symbol();
reglyph_darkroom();
docrt();
/*
* docrt() calls update_inventory() but
* (*windowprocs.win_update_inventory)(0) for curses ends up
* calling back to docrt() after creating its perm_invent
* window. That call back has become a no-op because of the
* program_state.in_docrt flag. So call update_inventory()
* explicitly in case perm_invent was toggled. It's only
* needed if perm_invent was off and is now on but won't kill
* anybody if done when not necessary.
* Note: doset_simple() doesn't need this because it doesn't
* offer a chance to toggle perm_invent.
*/
if (iflags.perm_invent)
update_inventory();
}
if (g.context.botl || g.context.botlx) {
bot();

View File

@@ -1103,7 +1103,7 @@ curs_reset_windows(boolean redo_main, boolean redo_status)
}
if (need_redraw) {
curses_last_messages();
doredraw();
docrt();
}
}

View File

@@ -1784,7 +1784,7 @@ curses_update_stats(void)
if (cy != ay) {
curses_create_main_windows();
curses_last_messages();
doredraw();
docrt();
/* Reset XP highlight (since classic_status and new show
different numbers) */