mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-13 07:58:04 +00:00
After some refactoring, several CON error checks done at runtime stood out as things that could be determined at script compile time. They have been moved.
git-svn-id: https://svn.eduke32.com/eduke32@7271 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
3d4d640be3
commit
8f7e842beb
2 changed files with 13 additions and 54 deletions
|
@ -3284,7 +3284,6 @@ DO_DEFSTATE:
|
||||||
case CON_MAIL:
|
case CON_MAIL:
|
||||||
case CON_MONEY:
|
case CON_MONEY:
|
||||||
case CON_PAPER:
|
case CON_PAPER:
|
||||||
case CON_QUOTE:
|
|
||||||
case CON_SAVE:
|
case CON_SAVE:
|
||||||
case CON_SAVENN:
|
case CON_SAVENN:
|
||||||
case CON_SLEEPTIME:
|
case CON_SLEEPTIME:
|
||||||
|
@ -3294,6 +3293,16 @@ DO_DEFSTATE:
|
||||||
C_GetNextValue(LABEL_DEFINE);
|
C_GetNextValue(LABEL_DEFINE);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
case CON_QUOTE:
|
||||||
|
C_GetNextValue(LABEL_DEFINE);
|
||||||
|
if (EDUKE32_PREDICT_FALSE(((unsigned)g_scriptPtr[-1] >= MAXQUOTES) || apStrings[g_scriptPtr[-1]] == NULL))
|
||||||
|
{
|
||||||
|
g_errorCnt++;
|
||||||
|
C_ReportError(-1);
|
||||||
|
initprintf("%s:%d: error: invalid quote\n", g_scriptFileName, g_lineNumber);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
|
||||||
case CON_ELSE:
|
case CON_ELSE:
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_FALSE(!g_checkingIfElse))
|
if (EDUKE32_PREDICT_FALSE(!g_checkingIfElse))
|
||||||
|
@ -3303,7 +3312,7 @@ DO_DEFSTATE:
|
||||||
g_warningCnt++;
|
g_warningCnt++;
|
||||||
C_ReportError(-1);
|
C_ReportError(-1);
|
||||||
|
|
||||||
initprintf("%s:%d: warning: found `else' with no `if'.\n", g_scriptFileName, g_lineNumber);
|
initprintf("%s:%d: warning: found `else' with no `if'\n", g_scriptFileName, g_lineNumber);
|
||||||
|
|
||||||
if (C_GetKeyword() == CON_LEFTBRACE)
|
if (C_GetKeyword() == CON_LEFTBRACE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1754,31 +1754,16 @@ next_instruction:
|
||||||
|
|
||||||
case CON_MODVAR_GLOBAL:
|
case CON_MODVAR_GLOBAL:
|
||||||
insptr++;
|
insptr++;
|
||||||
if (EDUKE32_PREDICT_FALSE(insptr[1] == 0))
|
|
||||||
{
|
|
||||||
CON_CRITICALERRPRINTF("mod by zero!\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
aGameVars[*insptr].global %= insptr[1];
|
aGameVars[*insptr].global %= insptr[1];
|
||||||
insptr += 2;
|
insptr += 2;
|
||||||
continue;
|
continue;
|
||||||
case CON_MODVAR_ACTOR:
|
case CON_MODVAR_ACTOR:
|
||||||
insptr++;
|
insptr++;
|
||||||
if (EDUKE32_PREDICT_FALSE(insptr[1] == 0))
|
|
||||||
{
|
|
||||||
CON_CRITICALERRPRINTF("mod by zero!\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
aGameVars[*insptr].pValues[vm.spriteNum & (MAXSPRITES-1)] %= insptr[1];
|
aGameVars[*insptr].pValues[vm.spriteNum & (MAXSPRITES-1)] %= insptr[1];
|
||||||
insptr += 2;
|
insptr += 2;
|
||||||
continue;
|
continue;
|
||||||
case CON_MODVAR_PLAYER:
|
case CON_MODVAR_PLAYER:
|
||||||
insptr++;
|
insptr++;
|
||||||
if (EDUKE32_PREDICT_FALSE(insptr[1] == 0))
|
|
||||||
{
|
|
||||||
CON_CRITICALERRPRINTF("mod by zero!\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
aGameVars[*insptr].pValues[vm.playerNum & (MAXPLAYERS-1)] %= insptr[1];
|
aGameVars[*insptr].pValues[vm.playerNum & (MAXPLAYERS-1)] %= insptr[1];
|
||||||
insptr += 2;
|
insptr += 2;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1928,23 +1913,14 @@ next_instruction:
|
||||||
|
|
||||||
case CON_DIVVAR_GLOBAL:
|
case CON_DIVVAR_GLOBAL:
|
||||||
insptr++;
|
insptr++;
|
||||||
if (EDUKE32_PREDICT_FALSE(insptr[1] == 0))
|
|
||||||
{
|
|
||||||
CON_CRITICALERRPRINTF("divide by zero!\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
aGameVars[*insptr].global = tabledivide32(aGameVars[*insptr].global, insptr[1]);
|
aGameVars[*insptr].global = tabledivide32(aGameVars[*insptr].global, insptr[1]);
|
||||||
insptr += 2;
|
insptr += 2;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
case CON_DIVVAR_PLAYER:
|
case CON_DIVVAR_PLAYER:
|
||||||
{
|
{
|
||||||
insptr++;
|
insptr++;
|
||||||
if (EDUKE32_PREDICT_FALSE(insptr[1] == 0))
|
|
||||||
{
|
|
||||||
CON_CRITICALERRPRINTF("divide by zero!\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto &v = aGameVars[*insptr].pValues[vm.playerNum & (MAXPLAYERS - 1)];
|
auto &v = aGameVars[*insptr].pValues[vm.playerNum & (MAXPLAYERS - 1)];
|
||||||
|
|
||||||
v = tabledivide32(v, insptr[1]);
|
v = tabledivide32(v, insptr[1]);
|
||||||
|
@ -1955,17 +1931,13 @@ next_instruction:
|
||||||
case CON_DIVVAR_ACTOR:
|
case CON_DIVVAR_ACTOR:
|
||||||
{
|
{
|
||||||
insptr++;
|
insptr++;
|
||||||
if (EDUKE32_PREDICT_FALSE(insptr[1] == 0))
|
|
||||||
{
|
|
||||||
CON_CRITICALERRPRINTF("divide by zero!\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto &v = aGameVars[*insptr].pValues[vm.spriteNum & (MAXSPRITES - 1)];
|
auto &v = aGameVars[*insptr].pValues[vm.spriteNum & (MAXSPRITES - 1)];
|
||||||
|
|
||||||
v = tabledivide32(v, insptr[1]);
|
v = tabledivide32(v, insptr[1]);
|
||||||
insptr += 2;
|
insptr += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
case CON_DIVVARVAR:
|
case CON_DIVVARVAR:
|
||||||
insptr++;
|
insptr++;
|
||||||
|
@ -2194,11 +2166,6 @@ next_instruction:
|
||||||
|
|
||||||
case CON_DIVVAR:
|
case CON_DIVVAR:
|
||||||
insptr++;
|
insptr++;
|
||||||
if (EDUKE32_PREDICT_FALSE(insptr[1] == 0))
|
|
||||||
{
|
|
||||||
CON_CRITICALERRPRINTF("divide by zero!\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Gv_DivVar(*insptr, insptr[1]);
|
Gv_DivVar(*insptr, insptr[1]);
|
||||||
insptr += 2;
|
insptr += 2;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2235,12 +2202,6 @@ next_instruction:
|
||||||
|
|
||||||
case CON_MODVAR:
|
case CON_MODVAR:
|
||||||
insptr++;
|
insptr++;
|
||||||
if (EDUKE32_PREDICT_FALSE(insptr[1] == 0))
|
|
||||||
{
|
|
||||||
CON_CRITICALERRPRINTF("mod by zero!\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Gv_ModVar(*insptr, insptr[1]);
|
Gv_ModVar(*insptr, insptr[1]);
|
||||||
insptr += 2;
|
insptr += 2;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2815,11 +2776,6 @@ badindex:
|
||||||
int const strIndex = *insptr++;
|
int const strIndex = *insptr++;
|
||||||
int const XstrIndex = *insptr++;
|
int const XstrIndex = *insptr++;
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE((apStrings[strIndex] == NULL || apXStrings[XstrIndex] == NULL)))
|
|
||||||
{
|
|
||||||
CON_ERRPRINTF("invalid source quote %d or destination quote %d\n", XstrIndex, strIndex);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Bstrcpy(apStrings[strIndex], apXStrings[XstrIndex]);
|
Bstrcpy(apStrings[strIndex], apXStrings[XstrIndex]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -6333,12 +6289,6 @@ badindex:
|
||||||
case CON_QUOTE:
|
case CON_QUOTE:
|
||||||
insptr++;
|
insptr++;
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned)(*insptr) >= MAXQUOTES) || apStrings[*insptr] == NULL)
|
|
||||||
{
|
|
||||||
CON_ERRPRINTF("invalid quote %d\n", (int32_t)(*insptr));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS))
|
if (EDUKE32_PREDICT_FALSE((unsigned)vm.playerNum >= MAXPLAYERS))
|
||||||
{
|
{
|
||||||
CON_ERRPRINTF("invalid player %d\n", vm.playerNum);
|
CON_ERRPRINTF("invalid player %d\n", vm.playerNum);
|
||||||
|
|
Loading…
Reference in a new issue