From: nhmall Date: Mon, 27 Jun 2022 12:13:37 +0000 (-0400) Subject: some tty perminvent follow-up() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=af58acccd27c2d54f6e9da8fb9b1c60b3df2b9f0;p=nethack some tty perminvent follow-up() --- diff --git a/include/extern.h b/include/extern.h index e3ebc56ef..dcdffdbd5 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1174,7 +1174,8 @@ extern long count_contents(struct obj *, boolean, boolean, boolean, boolean); extern void carry_obj_effects(struct obj *); extern const char *currency(long); extern void silly_thing(const char *, struct obj *); -extern void core_update_invent_slot(void); +extern void sync_perminvent(void); +extern void perm_invent_toggled(boolean negated); /* ### ioctl.c ### */ diff --git a/src/invent.c b/src/invent.c index 65487b618..dedb0dcbe 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2431,7 +2431,7 @@ update_inventory(void) iflags.suppress_price = 0; #if defined(TTY_PERM_INVENT) && defined(CORE_INVENT) if (WINDOWPORT("tty")) - core_update_invent_slot(); + sync_perminvent(); else #else (*windowprocs.win_update_inventory)(0); @@ -5349,11 +5349,11 @@ static char Empty[1] = { '\0' }; static int done_environment_var = 0; #ifdef TTY_PERM_INVENT extern void tty_perm_invent_toggled(boolean negated); -extern boolean in_tty_perm_invent_toggled; +static boolean in_perm_invent_toggled; #endif void -core_update_invent_slot() +sync_perminvent(void) { static perminvent_info *pi = 0; char *text, nxtlet; @@ -5378,19 +5378,19 @@ core_update_invent_slot() return; if ((!iflags.perm_invent && g.core_invent_state) - && !in_tty_perm_invent_toggled) { + && !in_perm_invent_toggled) { /* Odd - but this could be end-of-game disclosure * which just sets boolean iflag.perm_invent to * FALSE without actually doing anything else. */ #ifdef TTY_PERM_INVENT if (WINDOWPORT("tty")) - tty_perm_invent_toggled(TRUE); /* TRUE means negated */ + perm_invent_toggled(TRUE); /* TRUE means negated */ #endif (void) doredraw(); return; } - if (!iflags.perm_invent && !in_tty_perm_invent_toggled) + if (!iflags.perm_invent && !in_perm_invent_toggled) return; /* * The core looks after what content goes into the @@ -5422,7 +5422,7 @@ core_update_invent_slot() wport_id = "perm_invent"; pi_info.fromcore.core_request = 0; - if ((iflags.perm_invent && !g.core_invent_state) || in_tty_perm_invent_toggled) { + if ((iflags.perm_invent && !g.core_invent_state) || in_perm_invent_toggled) { /* Send the wport a request to get the related settings. */ pi_info.fromcore.core_request = request_settings; if ((pi = update_invent_slot(g.perm_invent_win, (slot = 0), &pi_info))) { @@ -5515,23 +5515,20 @@ core_update_invent_slot() pi_info.fromcore.core_request = 0; } -#if 0 -RESTORE_WARNING_FORMAT_NONLITERAL - void -tty_perm_invent_toggled(boolean negated) +perm_invent_toggled(boolean negated) { + in_perm_invent_toggled = TRUE; if (negated) { if (g.perm_invent_win != WIN_ERR) destroy_nhwindow(g.perm_invent_win), g.perm_invent_win = WIN_ERR; - done_tty_perm_invent_init = FALSE; + g.core_invent_state = 0; } else { - g.perm_invent_win = create_nhwindow(NHW_PERMINVENT); - if (g.perm_invent_win != WIN_ERR) - display_nhwindow(g.perm_invent_win, FALSE); + sync_perminvent(); } + in_perm_invent_toggled = FALSE; } -#endif + #endif /* CORE_INVENT */ /*invent.c*/ diff --git a/src/options.c b/src/options.c index 72aadf7db..e5f4d2c16 100644 --- a/src/options.c +++ b/src/options.c @@ -109,9 +109,6 @@ extern boolean colors_changed; /* in tos.c */ extern char *shade[3]; /* in sys/msdos/video.c */ extern char ttycolors[CLR_MAX]; /* in sys/msdos/video.c */ #endif -#ifdef TTY_PERM_INVENT -extern void tty_perm_invent_toggled(boolean negated); -#endif static char empty_optstr[] = { '\0' }; boolean duplicate, using_alias; @@ -4408,12 +4405,12 @@ optfn_boolean(int optidx, int req, boolean negated, char *opts, char *op) #ifdef TTY_PERM_INVENT /* if attempting to enable perm_invent fails, say so and return before "'perm_invent' option toggled on" would be given below; - tty_perm_invent_toggled() and routines it calls don't check + perm_invent_toggled() and routines it calls don't check iflags.perm_invent so it doesn't matter that 'SET IT HERE' hasn't been executed yet */ if (WINDOWPORT("tty") && !g.opt_initial && !negated) { - tty_perm_invent_toggled(FALSE); - /* tty_perm_invent_toggled() + perm_invent_toggled(FALSE); + /* perm_invent_toggled() -> tty_create_nhwindow(WIN_TTYINVENT) -> tty_create_invent() gives feedback for failure (terminal too small) */ diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 76443417e..68c694b1f 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -2765,6 +2765,7 @@ tty_destroy_nhwindow(winid window) } cw->maxrow = cw->maxcol = 0; g.perm_invent_win = WIN_ERR; + done_tty_perm_invent_init = FALSE; } #endif free_window_info(cw, TRUE); @@ -3926,24 +3927,6 @@ tty_invent_box_glyph_init(struct WinDesc *cw) done_tty_perm_invent_init = TRUE; } -void -tty_perm_invent_toggled(boolean negated) -{ - in_tty_perm_invent_toggled = TRUE; - if (negated) { - if (g.perm_invent_win != WIN_ERR) - destroy_nhwindow(g.perm_invent_win), g.perm_invent_win = WIN_ERR; - done_tty_perm_invent_init = FALSE; - g.core_invent_state = 0; - } else { - core_update_invent_slot(); - /* Doing this here was a problem */ - // g.perm_invent_win = create_nhwindow(NHW_PERMINVENT); - // if (g.perm_invent_win != WIN_ERR) - // display_nhwindow(g.perm_invent_win, FALSE); - } - in_tty_perm_invent_toggled = FALSE; -} #endif /* TTY_PERM_INVENT */ void