diff --git a/include/flag.h b/include/flag.h index b22193566..fea62efd3 100644 --- a/include/flag.h +++ b/include/flag.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 flag.h $NHDT-Date: 1655161560 2022/06/13 23:06:00 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.201 $ */ +/* NetHack 3.7 flag.h $NHDT-Date: 1684791761 2023/05/22 21:42:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.217 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -230,6 +230,7 @@ struct instance_flags { boolean window_inited; /* true if init_nhwindows() completed */ boolean vision_inited; /* true if vision is ready */ boolean sanity_check; /* run sanity checks */ + boolean sanity_no_check; /* skip next sanity check */ boolean debug_overwrite_stairs; /* debug: allow overwriting stairs */ boolean debug_mongen; /* debug: prevent monster generation */ boolean debug_hunger; /* debug: prevent hunger */ diff --git a/include/func_tab.h b/include/func_tab.h index 764b9ff33..5078d5c8d 100644 --- a/include/func_tab.h +++ b/include/func_tab.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 func_tab.h $NHDT-Date: 1596498537 2020/08/03 23:48:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.14 $ */ +/* NetHack 3.7 func_tab.h $NHDT-Date: 1684791775 2023/05/22 21:42:55 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.24 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2016. */ /* NetHack may be freely redistributed. See license for details. */ @@ -20,6 +20,7 @@ #define PREFIXCMD 0x0200 /* prefix command, requires another one after it */ #define MOVEMENTCMD 0x0400 /* used to move hero/cursor */ #define MOUSECMD 0x0800 /* cmd allowed to be bound to mouse button */ +#define CMD_INSANE 0x1000 /* suppress sanity check (for ^P and ^R) */ /* flags for extcmds_match() */ #define ECM_NOFLAGS 0 @@ -31,7 +32,7 @@ struct ext_func_tab { uchar key; const char *ef_txt, *ef_desc; int (*ef_funct)(void); /* must return ECMD_foo flags */ - int flags; + unsigned flags; const char *f_text; }; diff --git a/src/cmd.c b/src/cmd.c index c943b739c..a8e6566a0 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 cmd.c $NHDT-Date: 1678312816 2023/03/08 22:00:16 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.666 $ */ +/* NetHack 3.7 cmd.c $NHDT-Date: 1684791777 2023/05/22 21:42:57 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.677 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -188,14 +188,11 @@ static const char *readchar_queue = ""; static const char unavailcmd[] = "Unavailable command '%s'."; /* for rejecting #if !SHELL, !SUSPEND */ static const char cmdnotavail[] = "'%s' command not available."; -/* doesn't need to be in struct g|gw */ -static boolean was_doprev = FALSE; /* the #prevmsg command */ static int doprev_message(void) { - was_doprev = TRUE; (void) nh_doprev_message(); return ECMD_OK; } @@ -2671,7 +2668,7 @@ struct ext_func_tab extcmdlist[] = { { M('p'), "pray", "pray to the gods for help", dopray, IFBURIED | AUTOCOMPLETE, NULL }, { C('p'), "prevmsg", "view recent game messages", - doprev_message, IFBURIED | GENERALCMD, NULL }, + doprev_message, IFBURIED | GENERALCMD | CMD_INSANE, NULL }, { 'P', "puton", "put on an accessory (ring, amulet, etc)", doputon, 0, NULL }, { 'q', "quaff", "quaff (drink) something", @@ -2684,7 +2681,7 @@ struct ext_func_tab extcmdlist[] = { { 'r', "read", "read a scroll or spellbook", doread, 0, NULL }, { C('r'), "redraw", "redraw screen", - doredraw, IFBURIED | GENERALCMD, NULL }, + doredraw, IFBURIED | GENERALCMD | CMD_INSANE, NULL }, { 'R', "remove", "remove an accessory (ring, amulet, etc)", doremring, 0, NULL }, { C('a'), "repeat", "repeat a previous command", @@ -4268,12 +4265,12 @@ you_sanity_check(void) void sanity_check(void) { - if (was_doprev) { + if (iflags.sanity_no_check) { /* in case a recurring sanity_check warning occurs, we mustn't re-trigger it when ^P is used, otherwise msg_window:Single and msg_window:Combination will always repeat the most recent instance, never able to go back to any earlier messages */ - was_doprev = FALSE; + iflags.sanity_no_check = FALSE; return; } you_sanity_check(); @@ -5000,6 +4997,12 @@ rhack(char *cmd) cmdq_clear(CQ_REPEAT); } } + /* some commands shouldn't trigger sanity_check() because + if it produces output that might interfere with them; + note: if sanity_check is False, this has no effect */ + if ((tlist->flags & CMD_INSANE) != 0) + iflags.sanity_no_check = iflags.sanity_check; + res = (*func)(); /* perform the command */ /* if 'func' is doextcmd(), 'tlist' is for Cmd.commands['#'] rather than for the command that doextcmd() just ran;