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
|| (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.
(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
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))) {
/* 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,
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) {
#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);
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 */