mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
- safety commit
This commit is contained in:
parent
56975d3ee2
commit
248e0503d8
2 changed files with 57 additions and 80 deletions
|
@ -53,6 +53,7 @@ int g_currentSourceFile;
|
|||
intptr_t parsing_actor;
|
||||
int parsing_state;
|
||||
int num_squigilly_brackets;
|
||||
int checking_ifelse;
|
||||
|
||||
//G_EXTERN char tempbuf[MAXSECTORS << 1], buf[1024]; todo - move to compile state. tempbuf gets used nearly everywhere as scratchpad memory.
|
||||
extern char tempbuf[];
|
||||
|
@ -252,6 +253,7 @@ void skipblockcomment()
|
|||
if (*textptr == 0) return; // reached the end of the file
|
||||
textptr++;
|
||||
}
|
||||
textptr += 2;
|
||||
}
|
||||
|
||||
bool skipcomments()
|
||||
|
@ -373,6 +375,11 @@ static void setscriptvalue(int offset, int value)
|
|||
script[offset] = value;
|
||||
}
|
||||
|
||||
int scriptpos()
|
||||
{
|
||||
return script.Size();
|
||||
}
|
||||
|
||||
// store addresses as offsets
|
||||
static void setscriptaddress(int offset, int* address)
|
||||
{
|
||||
|
@ -396,6 +403,11 @@ void pushlabeladdress()
|
|||
labelcode.Push(script.Size());
|
||||
}
|
||||
|
||||
void reservescriptspace(int space)
|
||||
{
|
||||
script.Reserve(space);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Helpers to write to the old script buffer while using the new interface. Allows to test the parser before implementing the rest.
|
||||
|
@ -423,6 +435,11 @@ static int popscriptvalue()
|
|||
return *--scriptptr;
|
||||
}
|
||||
|
||||
int scriptpos()
|
||||
{
|
||||
return int(scriptptr - apScript);
|
||||
}
|
||||
|
||||
void appendlabeladdress(int offset = 0)
|
||||
{
|
||||
labelcode[labelcnt++] = int(scriptptr - apScript) + offset;
|
||||
|
@ -435,6 +452,11 @@ void appendlabelvalue(int value)
|
|||
labelcnt++;
|
||||
}
|
||||
|
||||
void reservescriptspace(int space)
|
||||
{
|
||||
scriptptr += space;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -899,15 +921,13 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
getlabel();
|
||||
checkforkeyword();
|
||||
|
||||
for (i = 0; i < labelcnt; i++)
|
||||
if (strcmp(label + (labelcnt << 6), label + (i << 6)) == 0)
|
||||
{
|
||||
warningcount++;
|
||||
Printf(TEXTCOLOR_RED " * WARNING.(%s, line %d) Duplicate ai '%s' ignored.\n", fn, line_number, label + (labelcnt << 6));
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == labelcnt) appendlabeladdress();
|
||||
lnum = findlabel(label + (labelcnt << 6));
|
||||
if (lnum >= 0)
|
||||
{
|
||||
warningcount++;
|
||||
Printf(TEXTCOLOR_RED " * WARNING.(%s, line %d) Duplicate ai '%s' ignored.\n", fn, line_number, label + (labelcnt << 6));
|
||||
}
|
||||
else appendlabeladdress();
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
|
@ -932,7 +952,6 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
}
|
||||
return 0;
|
||||
|
||||
#if 0
|
||||
case concmd_action:
|
||||
if (parsing_actor || parsing_state)
|
||||
transnum();
|
||||
|
@ -940,25 +959,15 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
{
|
||||
popscriptvalue();
|
||||
getlabel();
|
||||
// Check to see it's already defined
|
||||
checkforkeyword();
|
||||
|
||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
||||
lnum = findlabel(label + (labelcnt << 6));
|
||||
if (lnum >= 0)
|
||||
{
|
||||
errorcount++;
|
||||
ReportError(ERROR_ISAKEYWORD);
|
||||
return 0;
|
||||
warningcount++;
|
||||
Printf(TEXTCOLOR_RED " * WARNING.(%s, line %d) Duplicate event '%s' ignored.\n", fn, line_number, label + (labelcnt << 6));
|
||||
}
|
||||
|
||||
for (i = 0; i < labelcnt; i++)
|
||||
if (strcmp(label + (labelcnt << 6), label + (i << 6)) == 0)
|
||||
{
|
||||
warningcount++;
|
||||
Printf(TEXTCOLOR_RED " * WARNING.(%s, line %d) Duplicate event '%s' ignored.\n", fn, line_number, label + (labelcnt << 6));
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == labelcnt)
|
||||
labelcode[labelcnt++] = (intptr_t)scriptptr;
|
||||
else appendlabeladdress();
|
||||
|
||||
for (j = 0; j < 5; j++)
|
||||
{
|
||||
|
@ -973,6 +982,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
return 0;
|
||||
|
||||
case concmd_actor:
|
||||
{
|
||||
if (parsing_state)
|
||||
{
|
||||
Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) Found 'actor' within 'state'.\n", fn, line_number);
|
||||
|
@ -987,23 +997,27 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
|
||||
num_squigilly_brackets = 0;
|
||||
popscriptvalue();
|
||||
parsing_actor = scriptptr;
|
||||
parsing_actor = scriptpos();
|
||||
|
||||
transnum();
|
||||
popscriptvalue();
|
||||
actorscrptr[*scriptptr] = parsing_actor;
|
||||
lnum = popscriptvalue();
|
||||
#if 1
|
||||
g_tile[lnum].execPtr = apScript + parsing_actor; // TRANSITIONAL should only store an index
|
||||
#else
|
||||
//actorscrptr[lnum] = parsing_actor;
|
||||
#endif
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
*(parsing_actor + j) = 0;
|
||||
setscriptvalue(parsing_actor + j, 0);
|
||||
if (j == 3)
|
||||
{
|
||||
j = 0;
|
||||
while (keyword() == -1)
|
||||
{
|
||||
transnum();
|
||||
popscriptvalue();
|
||||
j |= *scriptptr;
|
||||
|
||||
j |= popscriptvalue();
|
||||
}
|
||||
appendscriptvalue(j);
|
||||
break;
|
||||
|
@ -1012,19 +1026,22 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
{
|
||||
if (keyword() >= 0)
|
||||
{
|
||||
scriptptr += (4 - j);
|
||||
reservescriptspace(4 - j);
|
||||
break;
|
||||
}
|
||||
transnum();
|
||||
setscriptvalue(parsing_actor + j, 0);
|
||||
|
||||
*(parsing_actor + j) = *(scriptptr - 1);
|
||||
//*(parsing_actor + j) = *(scriptptr - 1);
|
||||
}
|
||||
}
|
||||
|
||||
checking_ifelse = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
case concmd_onevent:
|
||||
if (parsing_state)
|
||||
{
|
||||
|
|
|
@ -959,6 +959,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
|||
case concmd_move:
|
||||
case concmd_music:
|
||||
case concmd_ai:
|
||||
case concmd_action:
|
||||
parsecommand(g_lastKeyword);
|
||||
continue;
|
||||
|
||||
|
@ -1038,50 +1039,6 @@ static int32_t C_ParseCommand(int32_t loop)
|
|||
continue;
|
||||
|
||||
|
||||
case concmd_action:
|
||||
if (parsing_actor || parsing_state)
|
||||
{
|
||||
C_GetNextValue(LABEL_ACTION);
|
||||
}
|
||||
else
|
||||
{
|
||||
scriptptr--;
|
||||
C_GetNextLabelName();
|
||||
// Check to see it's already defined
|
||||
|
||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
||||
{
|
||||
errorcount++;
|
||||
C_ReportError(ERROR_ISAKEYWORD);
|
||||
continue;
|
||||
}
|
||||
|
||||
i = findlabel(label+(labelcnt<<6));
|
||||
if (EDUKE32_PREDICT_FALSE(i>=0))
|
||||
{
|
||||
warningcount++;
|
||||
Printf("%s:%d: warning: duplicate action `%s' ignored.\n",g_scriptFileName,line_number,label+(labelcnt<<6));
|
||||
}
|
||||
else
|
||||
{
|
||||
//labeltype[labelcnt] = LABEL_ACTION;
|
||||
labelcode[labelcnt] = scriptptr-apScript;
|
||||
labelcnt++;
|
||||
}
|
||||
|
||||
for (j=ACTION_PARAM_COUNT-1; j>=0; j--)
|
||||
{
|
||||
if (C_GetKeyword() != -1) break;
|
||||
C_GetNextValue(LABEL_DEFINE);
|
||||
}
|
||||
for (k=j; k>=0; k--)
|
||||
{
|
||||
BITPTR_CLEAR(scriptptr-apScript);
|
||||
*(scriptptr++) = 0;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
case concmd_actor:
|
||||
case concmd_useractor:
|
||||
if (EDUKE32_PREDICT_FALSE(parsing_state || parsing_actor))
|
||||
|
@ -1199,8 +1156,11 @@ static int32_t C_ParseCommand(int32_t loop)
|
|||
#endif
|
||||
break;
|
||||
}
|
||||
if (*(scriptptr-1) >= (intptr_t)&apScript[0] && *(scriptptr-1) < (intptr_t)&apScript[g_scriptSize])
|
||||
BITPTR_SET(parsing_actor+j);
|
||||
if (*(scriptptr - 1) >= (intptr_t)&apScript[0] && *(scriptptr - 1) < (intptr_t)&apScript[g_scriptSize])
|
||||
{
|
||||
int a = 0;
|
||||
BITPTR_SET(parsing_actor + j);
|
||||
}
|
||||
else BITPTR_CLEAR(parsing_actor+j);
|
||||
*((apScript+j)+parsing_actor) = *(scriptptr-1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue