mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +00:00
- deactivated the label type checks because the original code doesn't have them and they'd get in the way of testing.
This commit is contained in:
parent
3ab19a2f0d
commit
53e4b8bf19
6 changed files with 105 additions and 49 deletions
|
@ -47,6 +47,9 @@ int line_number;
|
||||||
int labelcnt;
|
int labelcnt;
|
||||||
int errorcount, warningcount; // was named 'error' and 'warning' which is too generic for public variables and may clash with other code.
|
int errorcount, warningcount; // was named 'error' and 'warning' which is too generic for public variables and may clash with other code.
|
||||||
int g_currentSourceFile;
|
int g_currentSourceFile;
|
||||||
|
intptr_t parsing_actor;
|
||||||
|
int parsing_state;
|
||||||
|
|
||||||
//G_EXTERN char tempbuf[MAXSECTORS << 1], buf[1024]; todo - move to compile state. tempbuf gets used nearly everywhere as scratchpad memory.
|
//G_EXTERN char tempbuf[MAXSECTORS << 1], buf[1024]; todo - move to compile state. tempbuf gets used nearly everywhere as scratchpad memory.
|
||||||
extern char tempbuf[];
|
extern char tempbuf[];
|
||||||
extern intptr_t* scriptptr;
|
extern intptr_t* scriptptr;
|
||||||
|
@ -196,6 +199,17 @@ int getkeyword(const char* text)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int findlabel(const char* text)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < labelcnt; j++)
|
||||||
|
{
|
||||||
|
if (strcmp(label + (j << 6), text) == 0)
|
||||||
|
{
|
||||||
|
return labelcode[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -421,7 +435,18 @@ void transnum(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*scriptptr = atol(textptr);
|
// Now it's getting nasty... With all of C's integer conversion functions we have to look for undefined behavior and truncation problems. This one's the least problematic approach
|
||||||
|
// that ignores octal conversion.
|
||||||
|
int64_t value;
|
||||||
|
char *outp;
|
||||||
|
bool ishex = (textptr[0] == 0 && tolower(textptr[1]) == 'x') || (textptr[0] == '-' && textptr[1] == 0 && tolower(textptr[2]) == 'x');
|
||||||
|
if (*textptr == '-') value = strtoll(textptr, &outp, ishex? 16 : 10);
|
||||||
|
else value = strtoull(textptr, &outp, ishex ? 16 : 10);
|
||||||
|
if (*outp != 0)
|
||||||
|
{
|
||||||
|
// conversion was not successful.
|
||||||
|
}
|
||||||
|
*scriptptr = int(value); // truncate the parsed value to 32 bit.
|
||||||
scriptptr++;
|
scriptptr++;
|
||||||
textptr += l;
|
textptr += l;
|
||||||
}
|
}
|
||||||
|
@ -447,6 +472,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
uint8_t done, temp_ifelse_check;// , tw;
|
uint8_t done, temp_ifelse_check;// , tw;
|
||||||
int temp_line_number;
|
int temp_line_number;
|
||||||
int temp_current_file;
|
int temp_current_file;
|
||||||
|
int lnum;
|
||||||
|
|
||||||
#if FOR_LATER // for now this should just parse a single instruction
|
#if FOR_LATER // for now this should just parse a single instruction
|
||||||
if ((errorcount + warningcount) > 12 || (*textptr == '\0') || (*(textptr + 1) == '\0')) return 1;
|
if ((errorcount + warningcount) > 12 || (*textptr == '\0') || (*(textptr + 1) == '\0')) return 1;
|
||||||
|
@ -499,20 +525,14 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < labelcnt; j++)
|
int lnum = findlabel(label + (labelcnt << 6));
|
||||||
{
|
|
||||||
if (strcmp(label + (j << 6), label + (labelcnt << 6)) == 0)
|
|
||||||
{
|
|
||||||
*scriptptr = labelcode[j];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j == labelcnt)
|
if (lnum < 0)
|
||||||
{
|
{
|
||||||
Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) State '%s' not found.\n", fn, line_number, label + (labelcnt << 6));
|
Printf(TEXTCOLOR_RED " * ERROR!(%s, line %d) State '%s' not found.\n", fn, line_number, label + (labelcnt << 6));
|
||||||
errorcount++;
|
errorcount++;
|
||||||
}
|
}
|
||||||
|
*scriptptr = lnum;
|
||||||
scriptptr++;
|
scriptptr++;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
#if 0
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
LABEL_ANY = -1,
|
LABEL_ANY = -1,
|
||||||
|
@ -42,6 +43,7 @@ enum
|
||||||
LABEL_MOVE = 32,
|
LABEL_MOVE = 32,
|
||||||
LABEL_EVENT = 0x40,
|
LABEL_EVENT = 0x40,
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LABEL_HASPARM2 1
|
#define LABEL_HASPARM2 1
|
||||||
#define LABEL_ISSTRING 2
|
#define LABEL_ISSTRING 2
|
||||||
|
|
|
@ -160,7 +160,9 @@ G_EXTERN int16_t g_cyclers[MAXCYCLERS][6];
|
||||||
G_EXTERN int16_t g_mirrorSector[64];
|
G_EXTERN int16_t g_mirrorSector[64];
|
||||||
G_EXTERN int16_t g_mirrorWall[64];
|
G_EXTERN int16_t g_mirrorWall[64];
|
||||||
G_EXTERN int32_t *labelcode;
|
G_EXTERN int32_t *labelcode;
|
||||||
|
#if 0
|
||||||
G_EXTERN int32_t *labeltype;
|
G_EXTERN int32_t *labeltype;
|
||||||
|
#endif
|
||||||
G_EXTERN ClockTicks lockclock;
|
G_EXTERN ClockTicks lockclock;
|
||||||
G_EXTERN ClockTicks ototalclock;
|
G_EXTERN ClockTicks ototalclock;
|
||||||
|
|
||||||
|
|
|
@ -6520,7 +6520,9 @@ static void G_Cleanup(void)
|
||||||
|
|
||||||
if (label != (char *)&sprite[0]) Xfree(label);
|
if (label != (char *)&sprite[0]) Xfree(label);
|
||||||
if (labelcode != (int32_t *)§or[0]) Xfree(labelcode);
|
if (labelcode != (int32_t *)§or[0]) Xfree(labelcode);
|
||||||
|
#if 0
|
||||||
if (labeltype != (int32_t*)&wall[0]) Xfree(labeltype);
|
if (labeltype != (int32_t*)&wall[0]) Xfree(labeltype);
|
||||||
|
#endif
|
||||||
Xfree(apScript);
|
Xfree(apScript);
|
||||||
Xfree(bitptr);
|
Xfree(bitptr);
|
||||||
|
|
||||||
|
@ -6544,7 +6546,9 @@ static void G_CompileScripts(void)
|
||||||
{
|
{
|
||||||
label = (char *)&sprite[0]; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816
|
label = (char *)&sprite[0]; // V8: 16384*44/64 = 11264 V7: 4096*44/64 = 2816
|
||||||
labelcode = (int32_t *)§or[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240
|
labelcode = (int32_t *)§or[0]; // V8: 4096*40/4 = 40960 V7: 1024*40/4 = 10240
|
||||||
|
#if 0
|
||||||
labeltype = (int32_t *)&wall[0]; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536
|
labeltype = (int32_t *)&wall[0]; // V8: 16384*32/4 = 131072 V7: 8192*32/4 = 65536
|
||||||
|
#endif
|
||||||
|
|
||||||
C_Compile(G_ConFile());
|
C_Compile(G_ConFile());
|
||||||
|
|
||||||
|
@ -6562,11 +6566,15 @@ static void G_CompileScripts(void)
|
||||||
|
|
||||||
Bmemcpy(newlabel, label, labelcnt*64);
|
Bmemcpy(newlabel, label, labelcnt*64);
|
||||||
Bmemcpy(newlabelcode, labelcode, labelcnt*sizeof(int32_t));
|
Bmemcpy(newlabelcode, labelcode, labelcnt*sizeof(int32_t));
|
||||||
|
#if 0
|
||||||
Bmemcpy(newlabeltype, labeltype, labelcnt*sizeof(int32_t));
|
Bmemcpy(newlabeltype, labeltype, labelcnt*sizeof(int32_t));
|
||||||
|
#endif
|
||||||
|
|
||||||
label = newlabel;
|
label = newlabel;
|
||||||
labelcode = newlabelcode;
|
labelcode = newlabelcode;
|
||||||
|
#if 0
|
||||||
labeltype = newlabeltype;
|
labeltype = newlabeltype;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Bmemset(sprite, 0, MAXSPRITES*sizeof(spritetype));
|
Bmemset(sprite, 0, MAXSPRITES*sizeof(spritetype));
|
||||||
|
|
|
@ -63,7 +63,8 @@ uint32_t g_scriptcrc;
|
||||||
char g_szBuf[1024];
|
char g_szBuf[1024];
|
||||||
|
|
||||||
static char g_szCurrentBlockName[256] = "(none)", g_szLastBlockName[256] = "NULL";
|
static char g_szCurrentBlockName[256] = "(none)", g_szLastBlockName[256] = "NULL";
|
||||||
static int32_t g_checkingIfElse, g_processingState, g_lastKeyword = -1;
|
static int32_t g_checkingIfElse, g_lastKeyword = -1;
|
||||||
|
extern int parsing_state;
|
||||||
|
|
||||||
// The pointer to the start of the case table in a switch statement.
|
// The pointer to the start of the case table in a switch statement.
|
||||||
// First entry is 'default' code.
|
// First entry is 'default' code.
|
||||||
|
@ -75,7 +76,7 @@ static int32_t C_ParseCommand(int32_t loop);
|
||||||
static int32_t C_SetScriptSize(int32_t size);
|
static int32_t C_SetScriptSize(int32_t size);
|
||||||
|
|
||||||
static intptr_t apScriptGameEventEnd[MAXEVENTS];
|
static intptr_t apScriptGameEventEnd[MAXEVENTS];
|
||||||
static intptr_t g_parsingActorPtr;
|
extern intptr_t parsing_actor;
|
||||||
static intptr_t g_scriptEventOffset;
|
static intptr_t g_scriptEventOffset;
|
||||||
extern char *textptr;
|
extern char *textptr;
|
||||||
|
|
||||||
|
@ -286,7 +287,7 @@ static int32_t C_SkipComments(void)
|
||||||
Printf("%s:%d: debug: EOF in comment!\n",g_scriptFileName,line_number);
|
Printf("%s:%d: debug: EOF in comment!\n",g_scriptFileName,line_number);
|
||||||
C_ReportError(-1);
|
C_ReportError(-1);
|
||||||
Printf("%s:%d: error: found `/*' with no `*/'.\n",g_scriptFileName,line_number);
|
Printf("%s:%d: error: found `/*' with no `*/'.\n",g_scriptFileName,line_number);
|
||||||
g_parsingActorPtr = g_processingState = g_numBraces = 0;
|
parsing_actor = parsing_state = g_numBraces = 0;
|
||||||
g_errorCnt++;
|
g_errorCnt++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -562,7 +563,7 @@ static void C_GetNextVarType(int32_t type)
|
||||||
Bstrcpy(tempbuf,LAST_LABEL);
|
Bstrcpy(tempbuf,LAST_LABEL);
|
||||||
id = hash_find(&h_labels,tempbuf);
|
id = hash_find(&h_labels,tempbuf);
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_TRUE(id>=0 && labeltype[id] & LABEL_DEFINE))
|
if (EDUKE32_PREDICT_TRUE(id>=0 /*&& labeltype[id] & LABEL_DEFINE*/))
|
||||||
{
|
{
|
||||||
if (!(g_errorCnt || g_warningCnt) && g_scriptDebug)
|
if (!(g_errorCnt || g_warningCnt) && g_scriptDebug)
|
||||||
Printf("%s:%d: debug: label `%s' in place of gamevar.\n",g_scriptFileName,line_number,label+(id<<6));
|
Printf("%s:%d: debug: label `%s' in place of gamevar.\n",g_scriptFileName,line_number,label+(id<<6));
|
||||||
|
@ -613,7 +614,8 @@ static FORCE_INLINE void C_GetManyVarsType(int32_t type, int num)
|
||||||
// LABEL_* (>0) if that type and matched
|
// LABEL_* (>0) if that type and matched
|
||||||
//
|
//
|
||||||
// *scriptptr will contain the value OR 0 if wrong type or error
|
// *scriptptr will contain the value OR 0 if wrong type or error
|
||||||
static int32_t C_GetNextValue(int32_t type)
|
#define C_GetNextValue(a) C_GetNextValue_()
|
||||||
|
static int32_t C_GetNextValue_()
|
||||||
{
|
{
|
||||||
C_SkipComments();
|
C_SkipComments();
|
||||||
|
|
||||||
|
@ -640,33 +642,37 @@ static int32_t C_GetNextValue(int32_t type)
|
||||||
|
|
||||||
if (i>=0)
|
if (i>=0)
|
||||||
{
|
{
|
||||||
if (EDUKE32_PREDICT_TRUE(labeltype[i] & type))
|
//if (EDUKE32_PREDICT_TRUE(labeltype[i] & type))
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1)
|
if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1)
|
||||||
{
|
{
|
||||||
char *gl = C_GetLabelType(labeltype[i]);
|
char *gl = C_GetLabelType(labeltype[i]);
|
||||||
Printf("%s:%d: debug: %s label `%s'.\n",g_scriptFileName,line_number,gl,label+(i<<6));
|
Printf("%s:%d: debug: %s label `%s'.\n",g_scriptFileName,line_number,gl,label+(i<<6));
|
||||||
Xfree(gl);
|
Xfree(gl);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
BITPTR_CLEAR(scriptptr-apScript);
|
BITPTR_CLEAR(scriptptr-apScript);
|
||||||
*(scriptptr++) = labelcode[i];
|
*(scriptptr++) = labelcode[i];
|
||||||
|
|
||||||
textptr += l;
|
textptr += l;
|
||||||
return labeltype[i];
|
return 0;// labeltype[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
BITPTR_CLEAR(scriptptr-apScript);
|
BITPTR_CLEAR(scriptptr-apScript);
|
||||||
*(scriptptr++) = 0;
|
*(scriptptr++) = 0;
|
||||||
textptr += l;
|
textptr += l;
|
||||||
char *el = C_GetLabelType(type);
|
char *el = C_GetLabelType(type);
|
||||||
char *gl = C_GetLabelType(labeltype[i]);
|
char *gl = C_GetLabelType(/*labeltype[i]*/0);
|
||||||
C_ReportError(-1);
|
C_ReportError(-1);
|
||||||
Printf("%s:%d: warning: expected %s, found %s.\n",g_scriptFileName,line_number,el,gl);
|
Printf("%s:%d: warning: expected %s, found %s.\n",g_scriptFileName,line_number,el,gl);
|
||||||
g_warningCnt++;
|
g_warningCnt++;
|
||||||
Xfree(el);
|
Xfree(el);
|
||||||
Xfree(gl);
|
Xfree(gl);
|
||||||
return -1; // valid label name, but wrong type
|
return -1; // valid label name, but wrong type
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE(isdigit(*textptr) == 0 && *textptr != '-'))
|
if (EDUKE32_PREDICT_FALSE(isdigit(*textptr) == 0 && *textptr != '-'))
|
||||||
|
@ -931,6 +937,8 @@ static inline void C_FinishBitOr(int32_t value)
|
||||||
*scriptptr++ = value;
|
*scriptptr++ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int parsecommand(int tw); // for now just run an externally parsed command.
|
||||||
|
|
||||||
static int32_t C_ParseCommand(int32_t loop)
|
static int32_t C_ParseCommand(int32_t loop)
|
||||||
{
|
{
|
||||||
int32_t i, j=0, k=0, tw;
|
int32_t i, j=0, k=0, tw;
|
||||||
|
@ -951,14 +959,14 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
case -2:
|
case -2:
|
||||||
return 1; //End
|
return 1; //End
|
||||||
case concmd_state:
|
case concmd_state:
|
||||||
if (!g_parsingActorPtr && g_processingState == 0)
|
if (!parsing_actor && parsing_state == 0)
|
||||||
{
|
{
|
||||||
C_GetNextLabelName();
|
C_GetNextLabelName();
|
||||||
scriptptr--;
|
scriptptr--;
|
||||||
labelcode[labelcnt] = scriptptr-apScript;
|
labelcode[labelcnt] = scriptptr-apScript;
|
||||||
labeltype[labelcnt] = LABEL_STATE;
|
//labeltype[labelcnt] = LABEL_STATE;
|
||||||
|
|
||||||
g_processingState = 1;
|
parsing_state = 1;
|
||||||
Bsprintf(g_szCurrentBlockName,"%s",label+(labelcnt<<6));
|
Bsprintf(g_szCurrentBlockName,"%s",label+(labelcnt<<6));
|
||||||
|
|
||||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
||||||
|
@ -984,6 +992,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (EDUKE32_PREDICT_FALSE((labeltype[j] & LABEL_STATE) != LABEL_STATE))
|
if (EDUKE32_PREDICT_FALSE((labeltype[j] & LABEL_STATE) != LABEL_STATE))
|
||||||
{
|
{
|
||||||
char *gl = (char *) C_GetLabelType(labeltype[j]);
|
char *gl = (char *) C_GetLabelType(labeltype[j]);
|
||||||
|
@ -995,6 +1004,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
BITPTR_CLEAR(scriptptr-apScript-1);
|
BITPTR_CLEAR(scriptptr-apScript-1);
|
||||||
continue; // valid label name, but wrong type
|
continue; // valid label name, but wrong type
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1)
|
if (!(g_errorCnt || g_warningCnt) && g_scriptDebug > 1)
|
||||||
Printf("%s:%d: debug: state label `%s'.\n", g_scriptFileName, line_number, label+(j<<6));
|
Printf("%s:%d: debug: state label `%s'.\n", g_scriptFileName, line_number, label+(j<<6));
|
||||||
|
@ -1007,7 +1017,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case concmd_ends:
|
case concmd_ends:
|
||||||
if (EDUKE32_PREDICT_FALSE(g_processingState == 0))
|
if (EDUKE32_PREDICT_FALSE(parsing_state == 0))
|
||||||
{
|
{
|
||||||
C_ReportError(-1);
|
C_ReportError(-1);
|
||||||
Printf("%s:%d: error: found `ends' without open `state'.\n",g_scriptFileName,line_number);
|
Printf("%s:%d: error: found `ends' without open `state'.\n",g_scriptFileName,line_number);
|
||||||
|
@ -1026,7 +1036,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
g_errorCnt++;
|
g_errorCnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_processingState = 0;
|
parsing_state = 0;
|
||||||
Bsprintf(g_szCurrentBlockName,"(none)");
|
Bsprintf(g_szCurrentBlockName,"(none)");
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -1113,7 +1123,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
||||||
labeltype[labelcnt] = LABEL_DEFINE;
|
//labeltype[labelcnt] = LABEL_DEFINE;
|
||||||
labelcode[labelcnt++] = *(scriptptr-1);
|
labelcode[labelcnt++] = *(scriptptr-1);
|
||||||
//if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && g_dynamicTileMapping)
|
//if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && g_dynamicTileMapping)
|
||||||
// G_ProcessDynamicTileMapping(label+((labelcnt-1)<<6),*(scriptptr-1));
|
// G_ProcessDynamicTileMapping(label+((labelcnt-1)<<6),*(scriptptr-1));
|
||||||
|
@ -1139,8 +1149,10 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case concmd_move:
|
case concmd_move:
|
||||||
if (g_parsingActorPtr || g_processingState)
|
if (parsing_actor || parsing_state)
|
||||||
{
|
{
|
||||||
|
C_GetNextValue(LABEL_MOVE | LABEL_DEFINE);
|
||||||
|
#if 0
|
||||||
if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)))
|
if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)))
|
||||||
{
|
{
|
||||||
C_ReportError(-1);
|
C_ReportError(-1);
|
||||||
|
@ -1149,6 +1161,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_number);
|
Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_number);
|
||||||
g_warningCnt++;
|
g_warningCnt++;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
while (C_GetKeyword() == -1)
|
while (C_GetKeyword() == -1)
|
||||||
|
@ -1177,7 +1190,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
||||||
labeltype[labelcnt] = LABEL_MOVE;
|
//labeltype[labelcnt] = LABEL_MOVE;
|
||||||
labelcode[labelcnt++] = scriptptr-apScript;
|
labelcode[labelcnt++] = scriptptr-apScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1268,7 +1281,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case concmd_ai:
|
case concmd_ai:
|
||||||
if (g_parsingActorPtr || g_processingState)
|
if (parsing_actor || parsing_state)
|
||||||
{
|
{
|
||||||
C_GetNextValue(LABEL_AI);
|
C_GetNextValue(LABEL_AI);
|
||||||
}
|
}
|
||||||
|
@ -1292,7 +1305,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
labeltype[labelcnt] = LABEL_AI;
|
//labeltype[labelcnt] = LABEL_AI;
|
||||||
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
||||||
labelcode[labelcnt++] = scriptptr-apScript;
|
labelcode[labelcnt++] = scriptptr-apScript;
|
||||||
}
|
}
|
||||||
|
@ -1304,6 +1317,8 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
C_GetNextValue(LABEL_ACTION);
|
C_GetNextValue(LABEL_ACTION);
|
||||||
else if (j == 2)
|
else if (j == 2)
|
||||||
{
|
{
|
||||||
|
C_GetNextValue(LABEL_MOVE | LABEL_DEFINE);
|
||||||
|
#if 0
|
||||||
if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) &&
|
if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) &&
|
||||||
(*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)))
|
(*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)))
|
||||||
{
|
{
|
||||||
|
@ -1313,6 +1328,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_number);
|
Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_number);
|
||||||
g_warningCnt++;
|
g_warningCnt++;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
k = 0;
|
k = 0;
|
||||||
while (C_GetKeyword() == -1)
|
while (C_GetKeyword() == -1)
|
||||||
|
@ -1337,7 +1353,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case concmd_action:
|
case concmd_action:
|
||||||
if (g_parsingActorPtr || g_processingState)
|
if (parsing_actor || parsing_state)
|
||||||
{
|
{
|
||||||
C_GetNextValue(LABEL_ACTION);
|
C_GetNextValue(LABEL_ACTION);
|
||||||
}
|
}
|
||||||
|
@ -1362,7 +1378,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
labeltype[labelcnt] = LABEL_ACTION;
|
//labeltype[labelcnt] = LABEL_ACTION;
|
||||||
labelcode[labelcnt] = scriptptr-apScript;
|
labelcode[labelcnt] = scriptptr-apScript;
|
||||||
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
hash_add(&h_labels,label+(labelcnt<<6),labelcnt,0);
|
||||||
labelcnt++;
|
labelcnt++;
|
||||||
|
@ -1383,7 +1399,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
|
|
||||||
case concmd_actor:
|
case concmd_actor:
|
||||||
case concmd_useractor:
|
case concmd_useractor:
|
||||||
if (EDUKE32_PREDICT_FALSE(g_processingState || g_parsingActorPtr))
|
if (EDUKE32_PREDICT_FALSE(parsing_state || parsing_actor))
|
||||||
{
|
{
|
||||||
C_ReportError(ERROR_FOUNDWITHIN);
|
C_ReportError(ERROR_FOUNDWITHIN);
|
||||||
g_errorCnt++;
|
g_errorCnt++;
|
||||||
|
@ -1391,7 +1407,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
|
|
||||||
g_numBraces = 0;
|
g_numBraces = 0;
|
||||||
scriptptr--;
|
scriptptr--;
|
||||||
g_parsingActorPtr = scriptptr - apScript;
|
parsing_actor = scriptptr - apScript;
|
||||||
|
|
||||||
if (tw == concmd_useractor)
|
if (tw == concmd_useractor)
|
||||||
{
|
{
|
||||||
|
@ -1411,8 +1427,8 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
|
|
||||||
j = hash_find(&h_labels, g_szCurrentBlockName);
|
j = hash_find(&h_labels, g_szCurrentBlockName);
|
||||||
|
|
||||||
if (j != -1)
|
//if (j != -1)
|
||||||
labeltype[j] |= LABEL_ACTOR;
|
// labeltype[j] |= LABEL_ACTOR;
|
||||||
|
|
||||||
if (tw == concmd_useractor)
|
if (tw == concmd_useractor)
|
||||||
{
|
{
|
||||||
|
@ -1439,7 +1455,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_tile[*scriptptr].execPtr = apScript + g_parsingActorPtr;
|
g_tile[*scriptptr].execPtr = apScript + parsing_actor;
|
||||||
|
|
||||||
if (tw == concmd_useractor)
|
if (tw == concmd_useractor)
|
||||||
{
|
{
|
||||||
|
@ -1452,8 +1468,8 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
|
|
||||||
for (j=0; j<4; j++)
|
for (j=0; j<4; j++)
|
||||||
{
|
{
|
||||||
BITPTR_CLEAR(g_parsingActorPtr+j);
|
BITPTR_CLEAR(parsing_actor+j);
|
||||||
*((apScript+j)+g_parsingActorPtr) = 0;
|
*((apScript+j)+parsing_actor) = 0;
|
||||||
if (j == 3)
|
if (j == 3)
|
||||||
{
|
{
|
||||||
j = 0;
|
j = 0;
|
||||||
|
@ -1485,6 +1501,8 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
case 2:
|
case 2:
|
||||||
// XXX: LABEL_MOVE|LABEL_DEFINE, what is this shit? compatibility?
|
// XXX: LABEL_MOVE|LABEL_DEFINE, what is this shit? compatibility?
|
||||||
// yep, it sure is :(
|
// yep, it sure is :(
|
||||||
|
C_GetNextValue(LABEL_MOVE | LABEL_DEFINE);
|
||||||
|
#if 0
|
||||||
if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)))
|
if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)))
|
||||||
{
|
{
|
||||||
C_ReportError(-1);
|
C_ReportError(-1);
|
||||||
|
@ -1493,19 +1511,20 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_number);
|
Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_number);
|
||||||
g_warningCnt++;
|
g_warningCnt++;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (*(scriptptr-1) >= (intptr_t)&apScript[0] && *(scriptptr-1) < (intptr_t)&apScript[g_scriptSize])
|
if (*(scriptptr-1) >= (intptr_t)&apScript[0] && *(scriptptr-1) < (intptr_t)&apScript[g_scriptSize])
|
||||||
BITPTR_SET(g_parsingActorPtr+j);
|
BITPTR_SET(parsing_actor+j);
|
||||||
else BITPTR_CLEAR(g_parsingActorPtr+j);
|
else BITPTR_CLEAR(parsing_actor+j);
|
||||||
*((apScript+j)+g_parsingActorPtr) = *(scriptptr-1);
|
*((apScript+j)+parsing_actor) = *(scriptptr-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_checkingIfElse = 0;
|
g_checkingIfElse = 0;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case concmd_onevent:
|
case concmd_onevent:
|
||||||
if (EDUKE32_PREDICT_FALSE(g_processingState || g_parsingActorPtr))
|
if (EDUKE32_PREDICT_FALSE(parsing_state || parsing_actor))
|
||||||
{
|
{
|
||||||
C_ReportError(ERROR_FOUNDWITHIN);
|
C_ReportError(ERROR_FOUNDWITHIN);
|
||||||
g_errorCnt++;
|
g_errorCnt++;
|
||||||
|
@ -1513,7 +1532,7 @@ static int32_t C_ParseCommand(int32_t loop)
|
||||||
|
|
||||||
g_numBraces = 0;
|
g_numBraces = 0;
|
||||||
scriptptr--;
|
scriptptr--;
|
||||||
g_scriptEventOffset = g_parsingActorPtr = scriptptr - apScript;
|
g_scriptEventOffset = parsing_actor = scriptptr - apScript;
|
||||||
|
|
||||||
C_SkipComments();
|
C_SkipComments();
|
||||||
j = 0;
|
j = 0;
|
||||||
|
@ -1832,6 +1851,8 @@ ifvar:
|
||||||
C_GetNextValue(LABEL_ACTION);
|
C_GetNextValue(LABEL_ACTION);
|
||||||
break;
|
break;
|
||||||
case concmd_ifmove:
|
case concmd_ifmove:
|
||||||
|
C_GetNextValue(LABEL_MOVE | LABEL_DEFINE);
|
||||||
|
#if 0
|
||||||
if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)))
|
if (EDUKE32_PREDICT_FALSE((C_GetNextValue(LABEL_MOVE|LABEL_DEFINE) == 0) && (*(scriptptr-1) != 0) && (*(scriptptr-1) != 1)))
|
||||||
{
|
{
|
||||||
C_ReportError(-1);
|
C_ReportError(-1);
|
||||||
|
@ -1839,6 +1860,7 @@ ifvar:
|
||||||
Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_number);
|
Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_number);
|
||||||
g_warningCnt++;
|
g_warningCnt++;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case concmd_ifpinventory:
|
case concmd_ifpinventory:
|
||||||
C_GetNextValue(LABEL_DEFINE);
|
C_GetNextValue(LABEL_DEFINE);
|
||||||
|
@ -1946,7 +1968,7 @@ ifvar:
|
||||||
}
|
}
|
||||||
|
|
||||||
case concmd_leftbrace:
|
case concmd_leftbrace:
|
||||||
if (EDUKE32_PREDICT_FALSE(!(g_processingState || g_parsingActorPtr || g_scriptEventOffset)))
|
if (EDUKE32_PREDICT_FALSE(!(parsing_state || parsing_actor || g_scriptEventOffset)))
|
||||||
{
|
{
|
||||||
g_errorCnt++;
|
g_errorCnt++;
|
||||||
C_ReportError(ERROR_SYNTAXERROR);
|
C_ReportError(ERROR_SYNTAXERROR);
|
||||||
|
@ -2249,13 +2271,13 @@ ifvar:
|
||||||
g_errorCnt++;
|
g_errorCnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_scriptEventOffset = g_parsingActorPtr = 0;
|
g_scriptEventOffset = parsing_actor = 0;
|
||||||
g_currentEvent = -1;
|
g_currentEvent = -1;
|
||||||
Bsprintf(g_szCurrentBlockName,"(none)");
|
Bsprintf(g_szCurrentBlockName,"(none)");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case concmd_enda:
|
case concmd_enda:
|
||||||
if (EDUKE32_PREDICT_FALSE(!g_parsingActorPtr || g_scriptEventOffset))
|
if (EDUKE32_PREDICT_FALSE(!parsing_actor || g_scriptEventOffset))
|
||||||
{
|
{
|
||||||
C_ReportError(-1);
|
C_ReportError(-1);
|
||||||
Printf("%s:%d: error: found `enda' without open `actor'.\n",g_scriptFileName,line_number);
|
Printf("%s:%d: error: found `enda' without open `actor'.\n",g_scriptFileName,line_number);
|
||||||
|
@ -2267,7 +2289,7 @@ ifvar:
|
||||||
C_ReportError(g_numBraces > 0 ? ERROR_OPENBRACKET : ERROR_CLOSEBRACKET);
|
C_ReportError(g_numBraces > 0 ? ERROR_OPENBRACKET : ERROR_CLOSEBRACKET);
|
||||||
g_errorCnt++;
|
g_errorCnt++;
|
||||||
}
|
}
|
||||||
g_parsingActorPtr = 0;
|
parsing_actor = 0;
|
||||||
Bsprintf(g_szCurrentBlockName,"(none)");
|
Bsprintf(g_szCurrentBlockName,"(none)");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -2534,8 +2556,8 @@ void C_ReportError(int32_t iError)
|
||||||
{
|
{
|
||||||
if (Bstrcmp(g_szCurrentBlockName,g_szLastBlockName))
|
if (Bstrcmp(g_szCurrentBlockName,g_szLastBlockName))
|
||||||
{
|
{
|
||||||
if (g_scriptEventOffset || g_processingState || g_parsingActorPtr)
|
if (g_scriptEventOffset || parsing_state || parsing_actor)
|
||||||
Printf("%s: In %s `%s':\n",g_scriptFileName,g_scriptEventOffset?"event":g_parsingActorPtr?"actor":"state",g_szCurrentBlockName);
|
Printf("%s: In %s `%s':\n",g_scriptFileName,g_scriptEventOffset?"event":parsing_actor?"actor":"state",g_szCurrentBlockName);
|
||||||
else Printf("%s: At top level:\n",g_scriptFileName);
|
else Printf("%s: At top level:\n",g_scriptFileName);
|
||||||
Bstrcpy(g_szLastBlockName,g_szCurrentBlockName);
|
Bstrcpy(g_szLastBlockName,g_szCurrentBlockName);
|
||||||
}
|
}
|
||||||
|
@ -2551,7 +2573,7 @@ void C_ReportError(int32_t iError)
|
||||||
Printf("%s:%d: error: expected a keyword but found `%s'.\n",g_scriptFileName,line_number,tempbuf);
|
Printf("%s:%d: error: expected a keyword but found `%s'.\n",g_scriptFileName,line_number,tempbuf);
|
||||||
break;
|
break;
|
||||||
case ERROR_FOUNDWITHIN:
|
case ERROR_FOUNDWITHIN:
|
||||||
Printf("%s:%d: error: found `%s' within %s.\n",g_scriptFileName,line_number,tempbuf,g_parsingActorPtr?"an actor":"a state");
|
Printf("%s:%d: error: found `%s' within %s.\n",g_scriptFileName,line_number,tempbuf,parsing_actor?"an actor":"a state");
|
||||||
break;
|
break;
|
||||||
case ERROR_ISAKEYWORD:
|
case ERROR_ISAKEYWORD:
|
||||||
Printf("%s:%d: error: symbol `%s' is a keyword.\n",g_scriptFileName,line_number,label+(labelcnt<<6));
|
Printf("%s:%d: error: symbol `%s' is a keyword.\n",g_scriptFileName,line_number,label+(labelcnt<<6));
|
||||||
|
|
|
@ -425,6 +425,7 @@ static int osdcmd_printtimes(CCmdFuncPtr UNUSED(parm))
|
||||||
|
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
for (int ii=0; ii<labelcnt; ii++)
|
for (int ii=0; ii<labelcnt; ii++)
|
||||||
{
|
{
|
||||||
if (labelcode[ii] == i && labeltype[ii] & LABEL_ACTOR)
|
if (labelcode[ii] == i && labeltype[ii] & LABEL_ACTOR)
|
||||||
|
@ -433,6 +434,7 @@ static int osdcmd_printtimes(CCmdFuncPtr UNUSED(parm))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (!buf[0]) Bsprintf(buf, "%d", i);
|
if (!buf[0]) Bsprintf(buf, "%d", i);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue