TTY_PERM_INVENT tweaks

This commit is contained in:
nhmall
2022-06-25 22:26:18 -04:00
parent 86bf8cfb45
commit d2ca61a0a0
3 changed files with 24 additions and 10 deletions

View File

@@ -5349,6 +5349,7 @@ 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;
#endif
void
@@ -5376,7 +5377,8 @@ core_update_invent_slot()
|| (pi_info.tocore.tocore_flags & prohibited))
return;
if (!iflags.perm_invent && g.core_invent_state) {
if ((!iflags.perm_invent && g.core_invent_state)
&& !in_tty_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.
@@ -5388,7 +5390,8 @@ core_update_invent_slot()
(void) doredraw();
return;
}
if (!iflags.perm_invent && !in_tty_perm_invent_toggled)
return;
/*
* The core looks after what content goes into the
* inventory slots, and deals with things like obj
@@ -5419,7 +5422,7 @@ core_update_invent_slot()
wport_id = "perm_invent";
pi_info.fromcore.core_request = 0;
if (!g.core_invent_state) {
if ((iflags.perm_invent && !g.core_invent_state) || in_tty_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))) {
@@ -5427,7 +5430,7 @@ core_update_invent_slot()
/* sizes aren't good enough */
set_option_mod_status("perm_invent", set_gameview);
iflags.perm_invent = FALSE;
pline("%s could not be enabled.", wport_id);
pline("%s could not be enabled.", wport_id);
pline("%s needs a terminal that is at least %dx%d, yours is %dx%d.",
wport_id,
pi->tocore.needrows, pi->tocore.needcols,
@@ -5442,8 +5445,10 @@ core_update_invent_slot()
display_nhwindow(g.perm_invent_win, FALSE);
g.core_invent_state++;
}
text = Empty; /* lint suppression */
if (!pi || pi->tocore.maxslot == 0)
return;
text = Empty; /* lint suppression */
pi_info.fromcore.core_request = update_slot;
obj = g.invent;
for (slot = 0; slot < pi->tocore.maxslot; ++slot) {

View File

@@ -162,12 +162,14 @@ synch_cursor(void)
return;
}
#ifdef TTY_PERM_INVENT
boolean in_tty_perm_invent_toggled = FALSE;
void
tty_perm_invent_toggled(boolean negated)
{
}
#endif
#endif
#endif /* TTY_PERM_INVENT */
#endif /* TTY_GRAPHICS */
void
more(void)

View File

@@ -267,6 +267,8 @@ static boolean done_tty_perm_invent_init = FALSE;
#ifndef NOINVSYM /* invent.c */
#define NOINVSYM '#'
#endif
/* not static, core_update_invent_slot() needs to see it from invent.c */
boolean in_tty_perm_invent_toggled = FALSE;
static int ttyinv_create_window(int, struct WinDesc *);
static void tty_invent_box_glyph_init(struct WinDesc *cw);
@@ -3926,15 +3928,20 @@ tty_invent_box_glyph_init(struct WinDesc *cw)
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 {
g.perm_invent_win = create_nhwindow(NHW_PERMINVENT);
if (g.perm_invent_win != WIN_ERR)
display_nhwindow(g.perm_invent_win, FALSE);
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 */