ref: 666e8da5fdc204a0406139f660a6a674210f156c
parent: f5446def0c1df4cc00899f65331b643a75391cda
author: Simon Howard <[email protected]>
date: Fri Jan 5 16:07:03 EST 2018
hexen: Add extra context for assertion failures. If bugs are encountered, it may be helpful to get some extra detail about the context in which the assertation failed, including the offset inside the BEHAVIOR lump.
--- a/src/hexen/p_acs.c
+++ b/src/hexen/p_acs.c
@@ -184,6 +184,7 @@
// PRIVATE DATA DEFINITIONS ------------------------------------------------
+static char EvalContext[64];
static acs_t *ACScript;
static unsigned int PCodeOffset;
static byte SpecArgs[8];
@@ -322,7 +323,7 @@
va_start(args, fmt);
M_vsnprintf(buf, sizeof(buf), fmt, args);
va_end(args);
- I_Error("ACS assertation failure: %s", buf);
+ I_Error("ACS assertation failure: in %s: %s", EvalContext, buf);
}
//==========================================================================
@@ -361,6 +362,7 @@
static int ReadScriptVar(void)
{
int var = ReadCodeInt();
+ ACSAssert(0, "testing error messages");
ACSAssert(var >= 0, "negative script variable: %d < 0", var);
ACSAssert(var < MAX_ACS_SCRIPT_VARS,
"invalid script variable: %d >= %d", var, MAX_ACS_SCRIPT_VARS);
@@ -454,6 +456,9 @@
ActionCodeBase = W_CacheLumpNum(lump, PU_LEVEL);
ActionCodeSize = W_LumpLength(lump);
+ M_snprintf(EvalContext, sizeof(EvalContext),
+ "header parsing of lump #%d", lump);
+
header = (acsHeader_t *) ActionCodeBase;
PCodeOffset = LONG(header->infoOffset);
@@ -792,7 +797,11 @@
do
{
+ M_snprintf(EvalContext, sizeof(EvalContext), "script %d @0x%x",
+ ACSInfo[script->infoIndex].number, PCodeOffset);
cmd = ReadCodeInt();
+ M_snprintf(EvalContext, sizeof(EvalContext), "script %d @0x%x, cmd=%d",
+ ACSInfo[script->infoIndex].number, PCodeOffset, cmd);
ACSAssert(cmd >= 0, "negative ACS instruction %d", cmd);
ACSAssert(cmd < arrlen(PCodeCmds),
"invalid ACS instruction %d (maybe this WAD is designed "