From cb0dd7af3f964745dd8f23bf660a5d9e645e1b94 Mon Sep 17 00:00:00 2001 From: Patric Mueller Date: Mon, 20 Jun 2022 18:07:24 +0200 Subject: [PATCH] Enable TTY_PERM_INVENT The permanent inventory will be automatically shown if the terminal size allows. But only output an error message if the player requested it via perm_invent option. --- include/config.h | 2 +- src/allmain.c | 2 +- win/tty/wintty.c | 26 ++++++++++++++++---------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/config.h b/include/config.h index 9ed4e3273..2e9df46d7 100644 --- a/include/config.h +++ b/include/config.h @@ -562,7 +562,7 @@ typedef unsigned char uchar; /* An experimental minimalist inventory list capability under tty if you have * at least 28 additional rows beneath the status window on your terminal */ -/* #define TTY_PERM_INVENT */ +#define TTY_PERM_INVENT /* NetHack will execute an external program whenever a new message-window * message is shown. The program to execute is given in environment variable diff --git a/src/allmain.c b/src/allmain.c index a39f5d216..00aef7177 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -636,7 +636,7 @@ display_gamewindows(void) start_menu(WIN_INVEN, 0U), end_menu(WIN_INVEN, (char *) 0); #ifdef TTY_PERM_INVENT - if (WINDOWPORT("tty") && iflags.perm_invent) { + if (WINDOWPORT("tty")) { g.tty_invent_win = create_nhwindow(NHW_TTYINVENT); } #endif diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 997b43545..72a465d7d 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -1625,23 +1625,29 @@ tty_create_nhwindow(int type) if (newwin->rows < tty_pi_minrow) { tty_destroy_nhwindow(newid); - raw_printf("tty perm_invent has been disabled."); - raw_printf( - "tty perm_invent requires %d rows, your terminal has %d.", - (iflags.wc2_statuslines > 2) ? 54 : 53, ttyDisplay->rows); - iflags.perm_invent = FALSE; + if (iflags.perm_invent) { + raw_printf("tty perm_invent has been disabled."); + raw_printf( + "tty perm_invent requires %d rows, your terminal has %d.", + (iflags.wc2_statuslines > 2) ? 54 : 53, ttyDisplay->rows); + iflags.perm_invent = FALSE; + } return WIN_ERR; } else if (newwin->cols < tty_pi_mincol) { tty_destroy_nhwindow(newid); - raw_printf("tty perm_invent has been disabled."); - raw_printf( - "tty perm_invent requires %d columns, your terminal has %d.", - tty_pi_mincol, ttyDisplay->cols); - iflags.perm_invent = FALSE; + if (iflags.perm_invent) { + raw_printf("tty perm_invent has been disabled."); + raw_printf( + "tty perm_invent requires %d columns, your terminal has %d.", + tty_pi_mincol, ttyDisplay->cols); + iflags.perm_invent = FALSE; + } return WIN_ERR; } else { int r, c; + iflags.perm_invent = TRUE; + newwin->maxrow = tty_pi_minrow; newwin->maxcol = newwin->cols; /* establish the borders */