Expand use of VM_GetKeywordForID to all other references to vm_keywords[].

Fixes printing of incorrect keywords, reported by Trooper Dan.

git-svn-id: https://svn.eduke32.com/eduke32@6485 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-10-16 03:32:34 +00:00
parent b3455b7b4d
commit d6682d58d3
4 changed files with 11 additions and 12 deletions

View file

@ -111,7 +111,7 @@ static char *C_GetLabelType(int32_t type)
return Xstrdup(x);
}
tokenmap_t const vm_keywords[] =
static tokenmap_t const vm_keywords[] =
{
{ "action", CON_ACTION },
{ "activate", CON_ACTIVATE },
@ -1610,7 +1610,7 @@ static int32_t C_GetNextKeyword(void) //Returns its code #
g_scriptPtr++;
if (!(g_errorCnt || g_warningCnt) && g_scriptDebug)
initprintf("%s:%d: debug: keyword `%s'.\n",g_scriptFileName,g_lineNumber,vm_keywords[i].token);
initprintf("%s:%d: debug: keyword `%s'.\n", g_scriptFileName, g_lineNumber, tempbuf);
return i;
}
@ -2186,7 +2186,7 @@ static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr)
C_ReportError(-1);
g_warningCnt++;
initprintf("%s:%d: warning: malformed `%s' branch\n",g_scriptFileName,g_lineNumber,
vm_keywords[*(g_scriptPtr) & VM_INSTMASK].token);
VM_GetKeywordForID(*(g_scriptPtr) & VM_INSTMASK));
return 1;
}
return 0;
@ -2195,7 +2195,7 @@ static int32_t C_CheckMalformedBranch(intptr_t lastScriptPtr)
static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr)
{
// ifrnd and the others actually do something when the condition is executed
if ((Bstrncmp(vm_keywords[tw].token, "if", 2) && tw != CON_ELSE) ||
if ((Bstrncmp(VM_GetKeywordForID(tw), "if", 2) && tw != CON_ELSE) ||
tw == CON_IFRND || tw == CON_IFHITWEAPON || tw == CON_IFCANSEE || tw == CON_IFCANSEETARGET ||
tw == CON_IFPDISTL || tw == CON_IFPDISTG || tw == CON_IFGOTWEAPONCE)
{
@ -2212,7 +2212,7 @@ static int32_t C_CheckEmptyBranch(int32_t tw, intptr_t lastScriptPtr)
g_warningCnt++;
g_scriptPtr = lastScriptPtr + &apScript[0];
initprintf("%s:%d: warning: empty `%s' branch\n",g_scriptFileName,g_lineNumber,
vm_keywords[*(g_scriptPtr) & VM_INSTMASK].token);
VM_GetKeywordForID(*(g_scriptPtr) & VM_INSTMASK));
*(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12));
return 1;
}

View file

@ -202,7 +202,6 @@ typedef struct {
int32_t val;
} tokenmap_t;
extern const tokenmap_t vm_keywords[];
extern const tokenmap_t iter_tokens[];
extern char const * VM_GetKeywordForID(int32_t id);

View file

@ -3849,7 +3849,7 @@ finish_qsprintf:
index=Gv_GetVarX(*insptr++);
if (EDUKE32_PREDICT_TRUE((unsigned)index < (unsigned)aGameArrays[lVarID].size))
{
OSD_Printf(OSDTEXT_GREEN "%s: L=%d %s[%d] =%d\n", vm_keywords[g_tw].token, g_errorLineNum,
OSD_Printf(OSDTEXT_GREEN "CONLOGVAR: L=%d %s[%d] =%d\n", g_errorLineNum,
aGameArrays[lVarID].szLabel, index,
(int32_t)(m*Gv_GetArrayValue(lVarID, index)));
continue;
@ -3874,7 +3874,7 @@ finish_qsprintf:
Gv_GetVarX(*insptr++);
continue;
}
OSD_Printf(OSDTEXT_GREEN "%s: L=%d %d %d\n",vm_keywords[g_tw].token,g_errorLineNum,index,Gv_GetVar(*insptr++,index,vm.playerNum));
OSD_Printf(OSDTEXT_GREEN "CONLOGVAR: L=%d %d %d\n",g_errorLineNum,index,Gv_GetVar(*insptr++,index,vm.playerNum));
continue;
}
}
@ -5269,7 +5269,7 @@ finish_qsprintf:
CON_ERRPRINTF("invalid iterator type %d", iterType);
continue;
badindex:
OSD_Printf(OSD_ERROR "Line %d, %s %s: index %d out of range!\n", g_errorLineNum, vm_keywords[g_tw].token,
OSD_Printf(OSD_ERROR "Line %d, for %s: index %d out of range!\n", g_errorLineNum,
iter_tokens[iterType].token, nIndex);
continue;
}

View file

@ -100,12 +100,12 @@ static FORCE_INLINE int32_t VM_OnEvent(int nEventID, int spriteNum, int playerNu
}
#define CON_ERRPRINTF(Text, ...) do { \
OSD_Printf("Line %d, %s: " Text, g_errorLineNum, vm_keywords[g_tw].token, ## __VA_ARGS__); \
OSD_Printf("Line %d, %s: " Text, g_errorLineNum, VM_GetKeywordForID(g_tw), ## __VA_ARGS__); \
} while (0)
#define CON_CRITICALERRPRINTF(Text, ...) do { \
OSD_Printf("Line %d, %s: " Text, g_errorLineNum, vm_keywords[g_tw].token, ## __VA_ARGS__); \
wm_msgbox(APPNAME, "Line %d, %s: " Text, g_errorLineNum, vm_keywords[g_tw].token, ## __VA_ARGS__); \
OSD_Printf("Line %d, %s: " Text, g_errorLineNum, VM_GetKeywordForID(g_tw), ## __VA_ARGS__); \
wm_msgbox(APPNAME, "Line %d, %s: " Text, g_errorLineNum, VM_GetKeywordForID(g_tw), ## __VA_ARGS__); \
} while (0)
void G_GetTimeDate(int32_t * const pValues);