From 5c7f2945dac40f732c255c93da4e7018bbd5d841 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 16 Aug 2022 15:23:37 -0700 Subject: [PATCH] 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. --- src/options.c | 17 ++++++++++++++++- win/curses/cursmain.c | 2 +- win/curses/cursstat.c | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/options.c b/src/options.c index f6a7aed5c..0e47e0c13 100644 --- a/src/options.c +++ b/src/options.c @@ -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(); diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index cbdcf4559..ff6769e67 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -1103,7 +1103,7 @@ curs_reset_windows(boolean redo_main, boolean redo_status) } if (need_redraw) { curses_last_messages(); - doredraw(); + docrt(); } } diff --git a/win/curses/cursstat.c b/win/curses/cursstat.c index 791398205..0d9aaabc6 100644 --- a/win/curses/cursstat.c +++ b/win/curses/cursstat.c @@ -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) */