From 31e89f12b29830caf080ea93de56905645bb2b90 Mon Sep 17 00:00:00 2001 From: terminx Date: Mon, 11 Jan 2016 05:05:10 +0000 Subject: [PATCH] Clean up a couple instances of direct usage of a magic number in the CON compiler. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@5534 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gamedef.c | 10 +++++----- polymer/eduke32/source/gamedef.h | 2 ++ polymer/eduke32/source/gameexec.c | 2 -- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 340382287..386e88008 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -2123,7 +2123,7 @@ static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr) C_ReportError(-1); g_numCompilerWarnings++; initprintf("%s:%d: warning: malformed `%s' branch\n",g_szScriptFileName,g_lineNumber, - keyw[*(g_scriptPtr) & 0xFFF]); + keyw[*(g_scriptPtr) & VM_INSTMASK]); return 1; } return 0; @@ -2140,7 +2140,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr) return 0; } - if ((*(g_scriptPtr) & 0xFFF) != CON_NULLOP || *(g_scriptPtr)>>12 != IFELSE_MAGIC) + if ((*(g_scriptPtr) & VM_INSTMASK) != CON_NULLOP || *(g_scriptPtr)>>12 != IFELSE_MAGIC) g_ifElseAborted = 0; if (EDUKE32_PREDICT_FALSE(g_ifElseAborted)) @@ -2149,7 +2149,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr) g_numCompilerWarnings++; g_scriptPtr = lastScriptPtr + &script[0]; initprintf("%s:%d: warning: empty `%s' branch\n",g_szScriptFileName,g_lineNumber, - keyw[*(g_scriptPtr) & 0xFFF]); + keyw[*(g_scriptPtr) & VM_INSTMASK]); *(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12)); return 1; } @@ -5106,13 +5106,13 @@ repeatcase: g_numBraces--; if ((*(g_scriptPtr-2)>>12) == (IFELSE_MAGIC) && - ((*(g_scriptPtr-2) & 0xFFF) == CON_LEFTBRACE)) // rewrite "{ }" into "nullop" + ((*(g_scriptPtr-2) & VM_INSTMASK) == CON_LEFTBRACE)) // rewrite "{ }" into "nullop" { // initprintf("%s:%d: rewriting empty braces '{ }' as 'nullop' from right\n",g_szScriptFileName,g_lineNumber); *(g_scriptPtr-2) = CON_NULLOP + (IFELSE_MAGIC<<12); g_scriptPtr -= 2; - if (C_GetKeyword() != CON_ELSE && (*(g_scriptPtr-2)&0xFFF) != CON_ELSE) + if (C_GetKeyword() != CON_ELSE && (*(g_scriptPtr-2) & VM_INSTMASK) != CON_ELSE) g_ifElseAborted = 1; else g_ifElseAborted = 0; diff --git a/polymer/eduke32/source/gamedef.h b/polymer/eduke32/source/gamedef.h index 3f5d94d5e..cd8e584ac 100644 --- a/polymer/eduke32/source/gamedef.h +++ b/polymer/eduke32/source/gamedef.h @@ -38,6 +38,8 @@ extern "C" { #define MAXCHEATLEN 20 #define NUMCHEATCODES (int32_t)ARRAY_SIZE(CheatStrings) +#define VM_INSTMASK 0xfff + extern intptr_t const * insptr; extern void VM_ScriptInfo(intptr_t const *ptr, int32_t range); diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 679c3af2b..64ad1b9fb 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -83,8 +83,6 @@ GAMEEXEC_STATIC void VM_Execute(int32_t loop); # include "gamestructures.c" #endif -#define VM_INSTMASK 0xfff - #define VM_CONDITIONAL(xxx) \ { \ if ((xxx) || ((insptr = (intptr_t *)*(insptr + 1)) && (((*insptr) & VM_INSTMASK) == CON_ELSE))) \