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:
@@ -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 */
|
/* Copyright (c) 2016 by Robert Patrick Rankin */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
(also caller's responsibility to ensure it isn't actually modified!) */
|
(also caller's responsibility to ensure it isn't actually modified!) */
|
||||||
#define nhStr(str) ((char *) str)
|
#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
|
* This stuff isn't related to lint suppression but lives here to
|
||||||
@@ -25,21 +25,28 @@
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define showdebug(file) debugcore(file, TRUE)
|
#define showdebug(file) debugcore(file, TRUE)
|
||||||
#define explicitdebug(file) debugcore(file, FALSE)
|
#define explicitdebug(file) debugcore(file, FALSE)
|
||||||
#define ifdebug(stmt) \
|
/* in case 'stmt' is pline() or something which calls pline(),
|
||||||
do { \
|
save and restore previous plnmsg code so that use of debugpline()
|
||||||
if (showdebug(__FILE__)) { \
|
doesn't change message semantics */
|
||||||
stmt; \
|
#define ifdebug(stmt) \
|
||||||
} \
|
do { \
|
||||||
|
if (showdebug(__FILE__)) { \
|
||||||
|
int save_plnmsg = iflags.last_msg; \
|
||||||
|
stmt; \
|
||||||
|
iflags.last_msg = save_plnmsg; \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
/* if we have microsoft's C runtime we can use these instead */
|
/* if we have microsoft's C runtime we can use these instead */
|
||||||
#include <crtdbg.h>
|
#include <crtdbg.h>
|
||||||
#define crtdebug(stmt) \
|
#define crtdebug(stmt) \
|
||||||
do { \
|
do { \
|
||||||
if (showdebug(__FILE__)) { \
|
if (showdebug(__FILE__)) { \
|
||||||
stmt; \
|
int save_plnmsg = iflags.last_msg; \
|
||||||
} \
|
stmt; \
|
||||||
_RPT0(_CRT_WARN, "\n"); \
|
iflags.last_msg = save_plnmsg; \
|
||||||
|
} \
|
||||||
|
_RPT0(_CRT_WARN, "\n"); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define debugpline0(str) crtdebug(_RPT0(_CRT_WARN, str))
|
#define debugpline0(str) crtdebug(_RPT0(_CRT_WARN, str))
|
||||||
#define debugpline1(fmt, arg) crtdebug(_RPT1(_CRT_WARN, fmt, arg))
|
#define debugpline1(fmt, arg) crtdebug(_RPT1(_CRT_WARN, fmt, arg))
|
||||||
|
|||||||
Reference in New Issue
Block a user