debugpline() fix

Something which occurred to me when looking at the magic whistle code.
It's behavior can vary depending upon whether pline()/You()/&c has
been called and that is detected by checking whether pline() has reset
iflags.last_msg.  Change the debugpline() mechanism to prevent it from
interfering with that.
This commit is contained in:
PatR
2022-06-19 02:30:45 -07:00
parent c3fcf9dbd6
commit 88c8e92e76

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 lint.h $NHDT-Date: 1596498539 2020/08/03 23:48:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.6 $ */
/* NetHack 3.7 lint.h $NHDT-Date: 1655631029 2022/06/19 09:30:29 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.8 $ */
/* Copyright (c) 2016 by Robert Patrick Rankin */
/* NetHack may be freely redistributed. See license for details. */
@@ -15,7 +15,7 @@
(also caller's responsibility to ensure it isn't actually modified!) */
#define nhStr(str) ((char *) str)
#define nhUse(arg) (void)(arg)
#define nhUse(arg) ((void) (arg))
/*
* This stuff isn't related to lint suppression but lives here to
@@ -25,21 +25,28 @@
#ifdef DEBUG
#define showdebug(file) debugcore(file, TRUE)
#define explicitdebug(file) debugcore(file, FALSE)
#define ifdebug(stmt) \
do { \
if (showdebug(__FILE__)) { \
stmt; \
} \
/* in case 'stmt' is pline() or something which calls pline(),
save and restore previous plnmsg code so that use of debugpline()
doesn't change message semantics */
#define ifdebug(stmt) \
do { \
if (showdebug(__FILE__)) { \
int save_plnmsg = iflags.last_msg; \
stmt; \
iflags.last_msg = save_plnmsg; \
} \
} while (0)
#ifdef _MSC_VER
/* if we have microsoft's C runtime we can use these instead */
#include <crtdbg.h>
#define crtdebug(stmt) \
do { \
if (showdebug(__FILE__)) { \
stmt; \
} \
_RPT0(_CRT_WARN, "\n"); \
#define crtdebug(stmt) \
do { \
if (showdebug(__FILE__)) { \
int save_plnmsg = iflags.last_msg; \
stmt; \
iflags.last_msg = save_plnmsg; \
} \
_RPT0(_CRT_WARN, "\n"); \
} while (0)
#define debugpline0(str) crtdebug(_RPT0(_CRT_WARN, str))
#define debugpline1(fmt, arg) crtdebug(_RPT1(_CRT_WARN, fmt, arg))