From fabbcdcf5676d0c15a63d5f5da4ad9ae81d9add2 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 4 Dec 2011 21:19:41 +0000 Subject: [PATCH] CON parser cleanup: when getting a value from labelcode[], assume that it represents a pointer into the script for label types other than LABEL_DEFINE instead of checking inclusion of the value in the script bounds. This assertion was tested with WGR2 SVN. git-svn-id: https://svn.eduke32.com/eduke32@2150 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gamedef.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 007dbcd03..44e813777 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -1664,9 +1664,18 @@ static int32_t C_GetNextValue(int32_t type) initprintf("%s:%d: debug: accepted %s label `%s'.\n",g_szScriptFileName,g_lineNumber,gl,label+(i<<6)); Bfree(gl); } +#if 0 if (labeltype[i] != LABEL_DEFINE && labelcode[i] >= (intptr_t)&script[0] && labelcode[i] < (intptr_t)&script[g_scriptSize]) bitptr[(g_scriptPtr-script)>>3] |= (BITPTR_POINTER<<((g_scriptPtr-script)&7)); - else bitptr[(g_scriptPtr-script)>>3] &= ~(BITPTR_POINTER<<((g_scriptPtr-script)&7)); + else + bitptr[(g_scriptPtr-script)>>3] &= ~(BITPTR_POINTER<<((g_scriptPtr-script)&7)); +#else + if ((labeltype[i]&LABEL_DEFINE)==0) + bitptr[(g_scriptPtr-script)>>3] |= (BITPTR_POINTER<<((g_scriptPtr-script)&7)); + else // the 'define' label type is the only one that doesn't reference the script + bitptr[(g_scriptPtr-script)>>3] &= ~(BITPTR_POINTER<<((g_scriptPtr-script)&7)); +#endif + *(g_scriptPtr++) = labelcode[i]; textptr += l; return labeltype[i]; @@ -1956,9 +1965,14 @@ static int32_t C_ParseCommand(int32_t loop) if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1) initprintf("%s:%d: debug: accepted state label `%s'.\n",g_szScriptFileName,g_lineNumber,label+(j<<6)); *g_scriptPtr = labelcode[j]; +#if 0 if (labelcode[j] >= (intptr_t)&script[0] && labelcode[j] < (intptr_t)&script[g_scriptSize]) bitptr[(g_scriptPtr-script)>>3] |= (BITPTR_POINTER<<((g_scriptPtr-script)&7)); else bitptr[(g_scriptPtr-script)>>3] &= ~(BITPTR_POINTER<<((g_scriptPtr-script)&7)); +#else + // 'state' type labels are always script addresses, as far as I can see + bitptr[(g_scriptPtr-script)>>3] |= (BITPTR_POINTER<<((g_scriptPtr-script)&7)); +#endif g_scriptPtr++; continue; }