mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 04:50:42 +00:00
- progress
# Conflicts: # source/games/duke/src/zz_gamedef.cpp
This commit is contained in:
parent
49e7fa20e8
commit
56975d3ee2
2 changed files with 87 additions and 279 deletions
|
@ -37,6 +37,9 @@ into many sub-files.
|
|||
#include "memarena.h"
|
||||
#include "printf.h"
|
||||
#include "filesystem.h"
|
||||
#include "mapinfo.h"
|
||||
#include "menu.h"
|
||||
#include "global.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
@ -100,6 +103,7 @@ void SortCommands()
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
enum
|
||||
{
|
||||
ERROR_ISAKEYWORD = 1,
|
||||
|
@ -113,6 +117,12 @@ enum
|
|||
ERROR_CLOSEBRACKET,
|
||||
ERROR_NOENDSWITCH
|
||||
};
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
ERROR_PARMUNDEFINED = 20,
|
||||
};
|
||||
|
||||
void ReportError(int iError)
|
||||
{
|
||||
|
@ -236,7 +246,7 @@ void skipwhitespace()
|
|||
|
||||
void skipblockcomment()
|
||||
{
|
||||
while (*textptr != '*' && textptr[1] != '/')
|
||||
while (*textptr != '*' || textptr[1] != '/')
|
||||
{
|
||||
if (*textptr == '\n') line_number++;
|
||||
if (*textptr == 0) return; // reached the end of the file
|
||||
|
@ -291,6 +301,38 @@ bool isaltok(char c)
|
|||
return c > 0 && (isalnum(c) || c == '{' || c == '}' || c == '/' || c == '*' || c == '-' || c == '_' || c == '.');
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int keyword(void)
|
||||
{
|
||||
int i;
|
||||
const char* temptextptr;
|
||||
|
||||
skipcomments();
|
||||
temptextptr = textptr;
|
||||
|
||||
while (isaltok(*temptextptr) == 0)
|
||||
{
|
||||
temptextptr++;
|
||||
if (*temptextptr == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (isaltok(*temptextptr))
|
||||
{
|
||||
tempbuf[i] = *(temptextptr++);
|
||||
i++;
|
||||
}
|
||||
tempbuf[i] = 0;
|
||||
|
||||
return getkeyword(tempbuf);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -301,6 +343,8 @@ void getlabel(void)
|
|||
{
|
||||
long i;
|
||||
|
||||
skipcomments();
|
||||
|
||||
while (isalnum(*textptr & 0xff) == 0)
|
||||
{
|
||||
if (*textptr == 0x0a) line_number++;
|
||||
|
@ -340,9 +384,11 @@ static void appendscriptvalue(int value)
|
|||
script.Push(value);
|
||||
}
|
||||
|
||||
static void popscriptvalue()
|
||||
static int popscriptvalue()
|
||||
{
|
||||
script.Pop();
|
||||
int p;
|
||||
script.Pop(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
void pushlabeladdress()
|
||||
|
@ -372,14 +418,20 @@ static void appendscriptvalue(int value)
|
|||
scriptWriteValue(value);
|
||||
}
|
||||
|
||||
static void popscriptvalue()
|
||||
static int popscriptvalue()
|
||||
{
|
||||
scriptptr--;
|
||||
return *--scriptptr;
|
||||
}
|
||||
|
||||
void pushlabeladdress()
|
||||
void appendlabeladdress(int offset = 0)
|
||||
{
|
||||
labelcode[labelcnt++] = int(scriptptr - apScript);
|
||||
labelcode[labelcnt++] = int(scriptptr - apScript) + offset;
|
||||
labelcnt++;
|
||||
}
|
||||
|
||||
void appendlabelvalue(int value)
|
||||
{
|
||||
labelcode[labelcnt++] = value;
|
||||
labelcnt++;
|
||||
}
|
||||
|
||||
|
@ -398,6 +450,8 @@ int transword(void) //Returns its code #
|
|||
{
|
||||
int i, l;
|
||||
|
||||
skipcomments();
|
||||
|
||||
while (isaltok(*textptr) == 0)
|
||||
{
|
||||
if (*textptr == 0x0a) line_number++;
|
||||
|
@ -591,7 +645,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
{
|
||||
getlabel();
|
||||
popscriptvalue();
|
||||
pushlabeladdress();
|
||||
appendlabeladdress();
|
||||
|
||||
parsing_state = 1;
|
||||
|
||||
|
@ -669,34 +723,25 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
);
|
||||
scriptptr -= 3; // no need to save in script...
|
||||
return 0;
|
||||
|
||||
#endif
|
||||
case concmd_define:
|
||||
getlabel();
|
||||
// Check to see it's already defined
|
||||
|
||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
||||
checkforkeyword();
|
||||
lnum = findlabel(label + (labelcnt << 6));
|
||||
if (lnum >= 0)
|
||||
{
|
||||
errorcount++;
|
||||
ReportError(ERROR_ISAKEYWORD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < labelcnt; i++)
|
||||
{
|
||||
if (strcmp(label + (labelcnt << 6), label + (i << 6)) == 0)
|
||||
{
|
||||
warningcount++;
|
||||
ReportError(WARNING_DUPLICATEDEFINITION);
|
||||
break;
|
||||
}
|
||||
warningcount++;
|
||||
ReportError(WARNING_DUPLICATEDEFINITION);
|
||||
break;
|
||||
}
|
||||
|
||||
transnum();
|
||||
if (i == labelcnt)
|
||||
i = popscriptvalue();
|
||||
if (lnum < 0)
|
||||
{
|
||||
labelcode[labelcnt++] = *(scriptptr - 1);
|
||||
appendlabelvalue(i);
|
||||
}
|
||||
scriptptr -= 2;
|
||||
popscriptvalue();
|
||||
return 0;
|
||||
|
||||
case concmd_palfrom:
|
||||
|
@ -735,12 +780,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
getlabel();
|
||||
// Check to see it's already defined
|
||||
|
||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
||||
{
|
||||
errorcount++;
|
||||
ReportError(ERROR_ISAKEYWORD);
|
||||
return 0;
|
||||
}
|
||||
checkforkeyword();
|
||||
|
||||
for (i = 0; i < labelcnt; i++)
|
||||
if (strcmp(label + (labelcnt << 6), label + (i << 6)) == 0)
|
||||
|
@ -750,7 +790,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
break;
|
||||
}
|
||||
if (i == labelcnt)
|
||||
labelcode[labelcnt++] = (intptr_t)scriptptr;
|
||||
appendlabeladdress();
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
if (keyword() >= 0) break;
|
||||
|
@ -798,8 +838,9 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
i++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
#if 0
|
||||
case concmd_include:
|
||||
{
|
||||
popscriptvalue();
|
||||
|
@ -848,6 +889,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
case concmd_ai:
|
||||
if (parsing_actor || parsing_state)
|
||||
transnum();
|
||||
|
@ -855,13 +897,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
{
|
||||
popscriptvalue();
|
||||
getlabel();
|
||||
|
||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
||||
{
|
||||
errorcount++;
|
||||
ReportError(ERROR_ISAKEYWORD);
|
||||
return 0;
|
||||
}
|
||||
checkforkeyword();
|
||||
|
||||
for (i = 0; i < labelcnt; i++)
|
||||
if (strcmp(label + (labelcnt << 6), label + (i << 6)) == 0)
|
||||
|
@ -871,8 +907,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
break;
|
||||
}
|
||||
|
||||
if (i == labelcnt)
|
||||
labelcode[labelcnt++] = (intptr_t)scriptptr;
|
||||
if (i == labelcnt) appendlabeladdress();
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
|
@ -883,8 +918,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
|||
while (keyword() == -1)
|
||||
{
|
||||
transnum();
|
||||
popscriptvalue();
|
||||
k |= *scriptptr;
|
||||
k |= popscriptvalue();
|
||||
}
|
||||
appendscriptvalue(k);
|
||||
return 0;
|
||||
|
@ -898,6 +932,7 @@ 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();
|
||||
|
|
|
@ -954,6 +954,11 @@ static int32_t C_ParseCommand(int32_t loop)
|
|||
return 1; //End
|
||||
case concmd_state:
|
||||
case concmd_ends:
|
||||
case concmd_define:
|
||||
case concmd_palfrom:
|
||||
case concmd_move:
|
||||
case concmd_music:
|
||||
case concmd_ai:
|
||||
parsecommand(g_lastKeyword);
|
||||
continue;
|
||||
|
||||
|
@ -1011,168 +1016,6 @@ static int32_t C_ParseCommand(int32_t loop)
|
|||
continue;
|
||||
}
|
||||
|
||||
case concmd_define:
|
||||
{
|
||||
C_GetNextLabelName();
|
||||
|
||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
||||
{
|
||||
errorcount++;
|
||||
C_ReportError(ERROR_ISAKEYWORD);
|
||||
continue;
|
||||
}
|
||||
|
||||
C_GetNextValue(LABEL_DEFINE);
|
||||
|
||||
i = findlabel(label+(labelcnt<<6));
|
||||
if (i>=0)
|
||||
{
|
||||
// if (i >= g_numDefaultLabels)
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE(labelcode[i] != *(scriptptr-1)))
|
||||
{
|
||||
warningcount++;
|
||||
Printf("%s:%d: warning: ignored redefinition of `%s' to %d (old: %d).\n",g_scriptFileName,
|
||||
line_number,label+(labelcnt<<6), (int32_t)(*(scriptptr-1)), labelcode[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//labeltype[labelcnt] = LABEL_DEFINE;
|
||||
labelcode[labelcnt++] = *(scriptptr-1);
|
||||
//if (*(scriptptr-1) >= 0 && *(scriptptr-1) < MAXTILES && g_dynamicTileMapping)
|
||||
// G_ProcessDynamicTileMapping(label+((labelcnt-1)<<6),*(scriptptr-1));
|
||||
}
|
||||
scriptptr -= 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
case concmd_palfrom:
|
||||
for (j=3; j>=0; j--)
|
||||
{
|
||||
if (C_GetKeyword() == -1)
|
||||
C_GetNextValue(LABEL_DEFINE);
|
||||
else break;
|
||||
}
|
||||
|
||||
while (j>-1)
|
||||
{
|
||||
BITPTR_CLEAR(scriptptr-apScript);
|
||||
*scriptptr++ = 0;
|
||||
j--;
|
||||
}
|
||||
continue;
|
||||
|
||||
case concmd_move:
|
||||
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)))
|
||||
{
|
||||
C_ReportError(-1);
|
||||
BITPTR_CLEAR(scriptptr-apScript-1);
|
||||
*(scriptptr-1) = 0;
|
||||
Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_number);
|
||||
warningcount++;
|
||||
}
|
||||
#endif
|
||||
|
||||
j = 0;
|
||||
while (C_GetKeyword() == -1)
|
||||
C_BitOrNextValue(&j);
|
||||
|
||||
C_FinishBitOr(j);
|
||||
}
|
||||
else
|
||||
{
|
||||
scriptptr--;
|
||||
C_GetNextLabelName();
|
||||
// Check to see it's already defined
|
||||
|
||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
||||
{
|
||||
errorcount++;
|
||||
C_ReportError(ERROR_ISAKEYWORD);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((i = findlabel(label+(labelcnt<<6))) >= 0))
|
||||
{
|
||||
warningcount++;
|
||||
Printf("%s:%d: warning: duplicate move `%s' ignored.\n",g_scriptFileName,line_number,label+(labelcnt<<6));
|
||||
}
|
||||
else
|
||||
{
|
||||
//labeltype[labelcnt] = LABEL_MOVE;
|
||||
labelcode[labelcnt++] = scriptptr-apScript;
|
||||
}
|
||||
|
||||
for (j=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;
|
||||
scriptptr++;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
case concmd_music:
|
||||
{
|
||||
// NOTE: this doesn't get stored in the PCode...
|
||||
|
||||
// music 1 stalker.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid
|
||||
// thecall.mid ahgeez.mid dethtoll.mid streets.mid watrwld1.mid snake1.mid
|
||||
scriptptr--;
|
||||
C_GetNextValue(LABEL_DEFINE); // Volume Number (0/4)
|
||||
scriptptr--;
|
||||
|
||||
k = *scriptptr-1; // 0-based volume number. -1 or MAXVOLUMES: "special"
|
||||
if (k == -1)
|
||||
k = MAXVOLUMES;
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE((unsigned)k >= MAXVOLUMES+1)) // if it's not background or special music
|
||||
{
|
||||
errorcount++;
|
||||
C_ReportError(-1);
|
||||
Printf("%s:%d: error: volume number must be between 0 and MAXVOLUMES+1=%d.\n",
|
||||
g_scriptFileName, line_number, MAXVOLUMES+1);
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
i = 0;
|
||||
// get the file name...
|
||||
while (C_GetKeyword() == -1)
|
||||
{
|
||||
C_SkipComments();
|
||||
|
||||
j = 0;
|
||||
tempbuf[j] = '/';
|
||||
while (isaltok(*(textptr+j)))
|
||||
{
|
||||
tempbuf[j+1] = textptr[j];
|
||||
j++;
|
||||
}
|
||||
tempbuf[j+1] = '\0';
|
||||
|
||||
C_DefineMusic(k, i, tempbuf);
|
||||
|
||||
textptr += j;
|
||||
|
||||
if (i >= MAXLEVELS)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
case concmd_include:
|
||||
scriptptr--;
|
||||
|
||||
|
@ -1194,76 +1037,6 @@ static int32_t C_ParseCommand(int32_t loop)
|
|||
C_Include(tempbuf);
|
||||
continue;
|
||||
|
||||
case concmd_ai:
|
||||
if (parsing_actor || parsing_state)
|
||||
{
|
||||
C_GetNextValue(LABEL_AI);
|
||||
}
|
||||
else
|
||||
{
|
||||
scriptptr--;
|
||||
C_GetNextLabelName();
|
||||
|
||||
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 ai `%s' ignored.\n",g_scriptFileName,line_number,label+(labelcnt<<6));
|
||||
}
|
||||
else
|
||||
{
|
||||
//labeltype[labelcnt] = LABEL_AI;
|
||||
labelcode[labelcnt++] = scriptptr-apScript;
|
||||
}
|
||||
|
||||
for (j=0; j<3; j++)
|
||||
{
|
||||
if (C_GetKeyword() != -1) break;
|
||||
if (j == 1)
|
||||
C_GetNextValue(LABEL_ACTION);
|
||||
else if (j == 2)
|
||||
{
|
||||
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)))
|
||||
{
|
||||
C_ReportError(-1);
|
||||
BITPTR_CLEAR(scriptptr-apScript-1);
|
||||
*(scriptptr-1) = 0;
|
||||
Printf("%s:%d: warning: expected a move, found a constant.\n",g_scriptFileName,line_number);
|
||||
warningcount++;
|
||||
}
|
||||
#endif
|
||||
|
||||
k = 0;
|
||||
while (C_GetKeyword() == -1)
|
||||
C_BitOrNextValue(&k);
|
||||
|
||||
C_FinishBitOr(k);
|
||||
j = 666;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (j == 666)
|
||||
continue;
|
||||
|
||||
for (k=j; k<3; k++)
|
||||
{
|
||||
BITPTR_CLEAR(scriptptr-apScript);
|
||||
*scriptptr = 0;
|
||||
scriptptr++;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
case concmd_action:
|
||||
if (parsing_actor || parsing_state)
|
||||
|
|
Loading…
Reference in a new issue