mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-31 22:00:46 +00:00
- transitioned the gamevar instructions, still with the old backend.
# Conflicts: # source/games/duke/src/zz_gamedef.cpp
This commit is contained in:
parent
05360e14b5
commit
a1a19ab630
3 changed files with 46 additions and 288 deletions
|
@ -531,7 +531,7 @@ int transword(void) //Returns its code #
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void transnum(void)
|
int transnum(void)
|
||||||
{
|
{
|
||||||
int i, l;
|
int i, l;
|
||||||
|
|
||||||
|
@ -540,7 +540,7 @@ void transnum(void)
|
||||||
if (*textptr == 0x0a) line_number++;
|
if (*textptr == 0x0a) line_number++;
|
||||||
textptr++;
|
textptr++;
|
||||||
if (*textptr == 0)
|
if (*textptr == 0)
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -569,7 +569,7 @@ void transnum(void)
|
||||||
{
|
{
|
||||||
appendscriptvalue(labelcode[i]);
|
appendscriptvalue(labelcode[i]);
|
||||||
textptr += l;
|
textptr += l;
|
||||||
return;
|
return labelcode[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,7 +584,7 @@ void transnum(void)
|
||||||
Printf(TEXTCOLOR_ORANGE " Game Variable not expected\n");
|
Printf(TEXTCOLOR_ORANGE " Game Variable not expected\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
// 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
|
||||||
|
@ -600,6 +600,7 @@ void transnum(void)
|
||||||
}
|
}
|
||||||
appendscriptvalue(int(value)); // truncate the parsed value to 32 bit.
|
appendscriptvalue(int(value)); // truncate the parsed value to 32 bit.
|
||||||
textptr += l;
|
textptr += l;
|
||||||
|
return int(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -702,7 +703,6 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#if 0
|
|
||||||
case concmd_gamevar:
|
case concmd_gamevar:
|
||||||
// syntax: gamevar <var1> <initial value> <flags>
|
// syntax: gamevar <var1> <initial value> <flags>
|
||||||
// defines var1 and sets initial value.
|
// defines var1 and sets initial value.
|
||||||
|
@ -710,6 +710,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
// (see top of this files for flags)
|
// (see top of this files for flags)
|
||||||
getlabel(); //GetGameVarLabel();
|
getlabel(); //GetGameVarLabel();
|
||||||
// Check to see it's already defined
|
// Check to see it's already defined
|
||||||
|
popscriptvalue();
|
||||||
|
|
||||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
||||||
{
|
{
|
||||||
|
@ -719,16 +720,13 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
}
|
}
|
||||||
|
|
||||||
transnum(); // get initial value
|
transnum(); // get initial value
|
||||||
|
j = popscriptvalue();
|
||||||
|
|
||||||
transnum(); // get flags
|
transnum(); // get flags
|
||||||
AddGameVar(label + (labelcnt << 6), *(scriptptr - 2),
|
lnum = popscriptvalue();
|
||||||
(*(scriptptr - 1))
|
AddGameVar(label + (labelcnt << 6), j, lnum & (~(GAMEVAR_FLAG_DEFAULT | GAMEVAR_FLAG_SECRET)));
|
||||||
// can't define default or secret
|
|
||||||
& (~(GAMEVAR_FLAG_DEFAULT | GAMEVAR_FLAG_SECRET))
|
|
||||||
);
|
|
||||||
scriptptr -= 3; // no need to save in script...
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
case concmd_define:
|
case concmd_define:
|
||||||
getlabel();
|
getlabel();
|
||||||
checkforkeyword();
|
checkforkeyword();
|
||||||
|
@ -1169,7 +1167,6 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#if 0
|
|
||||||
case concmd_setvar:
|
case concmd_setvar:
|
||||||
case concmd_addvar:
|
case concmd_addvar:
|
||||||
// syntax: [rand|add|set]var <var1> <const1>
|
// syntax: [rand|add|set]var <var1> <const1>
|
||||||
|
@ -1180,12 +1177,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
getlabel(); //GetGameVarLabel();
|
getlabel(); //GetGameVarLabel();
|
||||||
|
|
||||||
// Check to see if it's a keyword
|
// Check to see if it's a keyword
|
||||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
checkforkeyword();
|
||||||
{
|
|
||||||
errorcount++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = GetDefID(label + (labelcnt << 6));
|
i = GetDefID(label + (labelcnt << 6));
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
|
@ -1216,12 +1208,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
getlabel(); //GetGameVarLabel();
|
getlabel(); //GetGameVarLabel();
|
||||||
|
|
||||||
// Check to see if it's a keyword
|
// Check to see if it's a keyword
|
||||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
checkforkeyword();
|
||||||
{
|
|
||||||
errorcount++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = GetDefID(label + (labelcnt << 6));
|
i = GetDefID(label + (labelcnt << 6));
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
|
@ -1241,14 +1228,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
|
|
||||||
// get the ID of the DEF
|
// get the ID of the DEF
|
||||||
getlabel(); //GetGameVarLabel();
|
getlabel(); //GetGameVarLabel();
|
||||||
|
checkforkeyword();
|
||||||
// Check to see if it's a keyword
|
|
||||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
|
||||||
{
|
|
||||||
errorcount++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = GetDefID(label + (labelcnt << 6));
|
i = GetDefID(label + (labelcnt << 6));
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
|
@ -1257,16 +1237,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
ReportError(ERROR_NOTAGAMEDEF);
|
ReportError(ERROR_NOTAGAMEDEF);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
//#ifndef EDUKE
|
|
||||||
// this was a bug: second var can be RO because it is source
|
|
||||||
if (aGameVars[i].dwFlags & GAMEVAR_FLAG_READONLY)
|
|
||||||
{
|
|
||||||
errorcount++;
|
|
||||||
ReportError(ERROR_VARREADONLY);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
//#endif
|
|
||||||
appendscriptvalue(i); // the ID of the DEF (offset into array...)
|
appendscriptvalue(i); // the ID of the DEF (offset into array...)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1278,12 +1249,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
getlabel(); //GetGameVarLabel();
|
getlabel(); //GetGameVarLabel();
|
||||||
// Check to see it's a keyword
|
// Check to see it's a keyword
|
||||||
|
|
||||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
checkforkeyword();
|
||||||
{
|
|
||||||
errorcount++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = GetDefID(label + (labelcnt << 6));
|
i = GetDefID(label + (labelcnt << 6));
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
|
@ -1298,12 +1264,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
getlabel(); //GetGameVarLabel();
|
getlabel(); //GetGameVarLabel();
|
||||||
// Check to see it's a keyword
|
// Check to see it's a keyword
|
||||||
|
|
||||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
checkforkeyword();
|
||||||
{
|
|
||||||
errorcount++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = GetDefID(label + (labelcnt << 6));
|
i = GetDefID(label + (labelcnt << 6));
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
|
@ -1323,13 +1284,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
getlabel(); //GetGameVarLabel();
|
getlabel(); //GetGameVarLabel();
|
||||||
// Check to see it's a keyword
|
// Check to see it's a keyword
|
||||||
|
|
||||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
checkforkeyword();
|
||||||
{
|
|
||||||
errorcount++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = GetDefID(label + (labelcnt << 6));
|
i = GetDefID(label + (labelcnt << 6));
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
{ // not a defined DEF
|
{ // not a defined DEF
|
||||||
|
@ -1346,7 +1301,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
// syntax: addlogvar <var>
|
// syntax: addlogvar <var>
|
||||||
|
|
||||||
// source file.
|
// source file.
|
||||||
appendscriptvalue(g_currentSourceFile); // the ID of the DEF (offset into array...)
|
appendscriptvalue(g_currentSourceFile);
|
||||||
|
|
||||||
// prints the line number in the log file.
|
// prints the line number in the log file.
|
||||||
appendscriptvalue(line_number);
|
appendscriptvalue(line_number);
|
||||||
|
@ -1355,12 +1310,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
getlabel(); //GetGameVarLabel();
|
getlabel(); //GetGameVarLabel();
|
||||||
|
|
||||||
// Check to see if it's a keyword
|
// Check to see if it's a keyword
|
||||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
checkforkeyword();
|
||||||
{
|
|
||||||
errorcount++;
|
|
||||||
ReportError(ERROR_ISAKEYWORD);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
i = GetDefID(label + (labelcnt << 6));
|
i = GetDefID(label + (labelcnt << 6));
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
|
@ -1369,7 +1319,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
ReportError(ERROR_NOTAGAMEDEF);
|
ReportError(ERROR_NOTAGAMEDEF);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
appendscriptvalue(i); // the ID of the DEF (offset into array...)
|
appendscriptvalue(i);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -1382,7 +1332,7 @@ int parsecommand(int tw) // for now just run an externally parsed command.
|
||||||
// prints the line number in the log file.
|
// prints the line number in the log file.
|
||||||
appendscriptvalue(line_number);
|
appendscriptvalue(line_number);
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
case concmd_ifp:
|
case concmd_ifp:
|
||||||
j = 0;
|
j = 0;
|
||||||
do
|
do
|
||||||
|
|
|
@ -51,6 +51,9 @@ enum GamevarFlags_t
|
||||||
GAMEVAR_NOMULTI = 0x00080000, // don't attach to multiplayer packets
|
GAMEVAR_NOMULTI = 0x00080000, // don't attach to multiplayer packets
|
||||||
GAMEVAR_Q16PTR = 0x00100000, // plValues is a pointer to a q16.16
|
GAMEVAR_Q16PTR = 0x00100000, // plValues is a pointer to a q16.16
|
||||||
GAMEVAR_SERIALIZE = 0x00200000, // write into permasaves
|
GAMEVAR_SERIALIZE = 0x00200000, // write into permasaves
|
||||||
|
GAMEVAR_FLAG_DEFAULT = GAMEVAR_DEFAULT,
|
||||||
|
GAMEVAR_FLAG_SECRET = 0x200, // placeholder
|
||||||
|
GAMEVAR_FLAG_READONLY = 0x1000, // placeholder
|
||||||
|
|
||||||
GAMEVAR_RAWQ16PTR = GAMEVAR_Q16PTR | GAMEVAR_SPECIAL, // plValues is a pointer to a q16.16 but we don't want conversion
|
GAMEVAR_RAWQ16PTR = GAMEVAR_Q16PTR | GAMEVAR_SPECIAL, // plValues is a pointer to a q16.16 but we don't want conversion
|
||||||
GAMEVAR_PTR_MASK = GAMEVAR_INT32PTR | GAMEVAR_INT16PTR | GAMEVAR_Q16PTR | GAMEVAR_RAWQ16PTR,
|
GAMEVAR_PTR_MASK = GAMEVAR_INT32PTR | GAMEVAR_INT16PTR | GAMEVAR_Q16PTR | GAMEVAR_RAWQ16PTR,
|
||||||
|
@ -70,7 +73,11 @@ typedef struct
|
||||||
intptr_t *pValues; // array of values when 'per-player', or 'per-actor'
|
intptr_t *pValues; // array of values when 'per-player', or 'per-actor'
|
||||||
};
|
};
|
||||||
intptr_t defaultValue;
|
intptr_t defaultValue;
|
||||||
uintptr_t flags;
|
union
|
||||||
|
{
|
||||||
|
uintptr_t flags;
|
||||||
|
uintptr_t dwFlags;
|
||||||
|
};
|
||||||
char * szLabel;
|
char * szLabel;
|
||||||
} gamevar_t;
|
} gamevar_t;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
@ -104,6 +111,9 @@ inline int GetGameVar(const char* szGameLabel, int defaultValue, int spriteNum,
|
||||||
return Gv_GetVarByLabel(szGameLabel, defaultValue, spriteNum, playerNum);
|
return Gv_GetVarByLabel(szGameLabel, defaultValue, spriteNum, playerNum);
|
||||||
}
|
}
|
||||||
void Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);
|
void Gv_NewVar(const char *pszLabel,intptr_t lValue,uint32_t dwFlags);
|
||||||
|
#define AddGameVar Gv_NewVar
|
||||||
|
|
||||||
|
int GetDefID(const char* label);
|
||||||
|
|
||||||
static FORCE_INLINE void A_ResetVars(int const spriteNum)
|
static FORCE_INLINE void A_ResetVars(int const spriteNum)
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,21 +83,6 @@ static intptr_t g_scriptEventOffset;
|
||||||
extern char *textptr;
|
extern char *textptr;
|
||||||
|
|
||||||
|
|
||||||
static const vec2_t varvartable[] =
|
|
||||||
{
|
|
||||||
{ concmd_ifvarvare, concmd_ifvare },
|
|
||||||
{ concmd_ifvarvarg, concmd_ifvarg },
|
|
||||||
{ concmd_ifvarvarl, concmd_ifvarl },
|
|
||||||
{ concmd_addvarvar, concmd_addvar },
|
|
||||||
{ concmd_setvarvar, concmd_setvar },
|
|
||||||
};
|
|
||||||
|
|
||||||
static inthashtable_t h_varvar = { NULL, INTHASH_SIZE(ARRAY_SIZE(varvartable)) };
|
|
||||||
|
|
||||||
static inthashtable_t *const inttables[] = {
|
|
||||||
&h_varvar,
|
|
||||||
};
|
|
||||||
|
|
||||||
char const * VM_GetKeywordForID(int32_t id)
|
char const * VM_GetKeywordForID(int32_t id)
|
||||||
{
|
{
|
||||||
// do not really need this for now...
|
// do not really need this for now...
|
||||||
|
@ -120,12 +105,6 @@ void C_InitHashes()
|
||||||
for (auto table : tables)
|
for (auto table : tables)
|
||||||
hash_init(table);
|
hash_init(table);
|
||||||
|
|
||||||
for (auto table : inttables)
|
|
||||||
inthash_init(table);
|
|
||||||
|
|
||||||
for (auto &varvar : varvartable)
|
|
||||||
inthash_add(&h_varvar, varvar.x, varvar.y, 0);
|
|
||||||
|
|
||||||
//inithashnames();
|
//inithashnames();
|
||||||
initsoundhashnames();
|
initsoundhashnames();
|
||||||
}
|
}
|
||||||
|
@ -225,7 +204,7 @@ static int32_t C_SkipComments(void)
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int GetDefID(char const *label) { return hash_find(&h_gamevars, label); }
|
int GetDefID(char const *label) { return hash_find(&h_gamevars, label); }
|
||||||
|
|
||||||
#define LAST_LABEL (label+(labelcnt<<6))
|
#define LAST_LABEL (label+(labelcnt<<6))
|
||||||
bool isaltok(const char c);
|
bool isaltok(const char c);
|
||||||
|
@ -765,7 +744,7 @@ int parsecommand(int tw); // for now just run an externally parsed command.
|
||||||
|
|
||||||
int32_t C_ParseCommand(int32_t loop)
|
int32_t C_ParseCommand(int32_t loop)
|
||||||
{
|
{
|
||||||
int32_t i, j=0, k=0, tw;
|
int32_t j=0, k=0, tw;
|
||||||
TArray<char> buffer;
|
TArray<char> buffer;
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -927,65 +906,21 @@ int32_t C_ParseCommand(int32_t loop)
|
||||||
case concmd_motoloopsnd:
|
case concmd_motoloopsnd:
|
||||||
case concmd_rndmove:
|
case concmd_rndmove:
|
||||||
case concmd_gamestartup:
|
case concmd_gamestartup:
|
||||||
|
case concmd_gamevar:
|
||||||
|
case concmd_addlogvar:
|
||||||
|
case concmd_setvar:
|
||||||
|
case concmd_addvar:
|
||||||
|
case concmd_setvarvar:
|
||||||
|
case concmd_addvarvar:
|
||||||
|
case concmd_ifvarvarg:
|
||||||
|
case concmd_ifvarvarl:
|
||||||
|
case concmd_ifvarvare:
|
||||||
|
case concmd_ifvarg:
|
||||||
|
case concmd_ifvarl:
|
||||||
|
case concmd_ifvare:
|
||||||
if (parsecommand(g_lastKeyword)) return 1;
|
if (parsecommand(g_lastKeyword)) return 1;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case concmd_gamevar:
|
|
||||||
{
|
|
||||||
// syntax: gamevar <var1> <initial value> <flags>
|
|
||||||
// defines var1 and sets initial value.
|
|
||||||
// flags are used to define usage
|
|
||||||
// (see top of this files for flags)
|
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE(isdigit(*textptr) || (*textptr == '-')))
|
|
||||||
{
|
|
||||||
errorcount++;
|
|
||||||
C_ReportError(ERROR_SYNTAXERROR);
|
|
||||||
skiptoendofline();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
scriptptr--;
|
|
||||||
|
|
||||||
C_GetNextLabelName();
|
|
||||||
|
|
||||||
if (getkeyword(label + (labelcnt << 6)) >= 0)
|
|
||||||
{
|
|
||||||
errorcount++;
|
|
||||||
C_ReportError(WARNING_VARMASKSKEYWORD);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t defaultValue = 0;
|
|
||||||
int32_t varFlags = 0;
|
|
||||||
|
|
||||||
if (C_GetKeyword() == -1)
|
|
||||||
{
|
|
||||||
C_GetNextValue(LABEL_DEFINE); // get initial value
|
|
||||||
defaultValue = *(--scriptptr);
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
|
|
||||||
while (C_GetKeyword() == -1)
|
|
||||||
C_BitOrNextValue(&j);
|
|
||||||
|
|
||||||
C_FinishBitOr(j);
|
|
||||||
varFlags = *(--scriptptr);
|
|
||||||
|
|
||||||
if (EDUKE32_PREDICT_FALSE((*(scriptptr)&GAMEVAR_USER_MASK)==(GAMEVAR_PERPLAYER|GAMEVAR_PERACTOR)))
|
|
||||||
{
|
|
||||||
warningcount++;
|
|
||||||
varFlags ^= GAMEVAR_PERPLAYER;
|
|
||||||
C_ReportError(WARNING_BADGAMEVAR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Gv_NewVar(LAST_LABEL, defaultValue, varFlags);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case concmd_onevent:
|
case concmd_onevent:
|
||||||
if (EDUKE32_PREDICT_FALSE(parsing_state || parsing_actor))
|
if (EDUKE32_PREDICT_FALSE(parsing_state || parsing_actor))
|
||||||
{
|
{
|
||||||
|
@ -1026,143 +961,6 @@ int32_t C_ParseCommand(int32_t loop)
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case concmd_addlogvar:
|
|
||||||
g_labelsOnly = 1;
|
|
||||||
C_GetNextVar();
|
|
||||||
g_labelsOnly = 0;
|
|
||||||
continue;
|
|
||||||
case concmd_setvar:
|
|
||||||
case concmd_addvar:
|
|
||||||
setvar:
|
|
||||||
{
|
|
||||||
auto ins = &scriptptr[-1];
|
|
||||||
|
|
||||||
C_GetNextVarType(GAMEVAR_READONLY);
|
|
||||||
C_GetNextValue(LABEL_DEFINE);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
case concmd_setvarvar:
|
|
||||||
case concmd_addvarvar:
|
|
||||||
{
|
|
||||||
//setvarvar:
|
|
||||||
auto ins = &scriptptr[-1];
|
|
||||||
auto tptr = textptr;
|
|
||||||
int const lnum = line_number;
|
|
||||||
|
|
||||||
C_GetNextVarType(GAMEVAR_READONLY);
|
|
||||||
C_GetNextVar();
|
|
||||||
|
|
||||||
int const opcode = inthash_find(&h_varvar, *ins & VM_INSTMASK);
|
|
||||||
|
|
||||||
if (ins[2] == GV_FLAG_CONSTANT && opcode != -1)
|
|
||||||
{
|
|
||||||
if (g_scriptDebug > 1 && !errorcount && !warningcount)
|
|
||||||
{
|
|
||||||
Printf("%s:%d: %s -> %s\n", g_scriptFileName, line_number,
|
|
||||||
VM_GetKeywordForID(*ins & VM_INSTMASK), VM_GetKeywordForID(opcode));
|
|
||||||
}
|
|
||||||
|
|
||||||
tw = opcode;
|
|
||||||
scriptWriteAtOffset(opcode | LINE_NUMBER, ins);
|
|
||||||
scriptptr = &ins[1];
|
|
||||||
textptr = tptr;
|
|
||||||
line_number = lnum;
|
|
||||||
goto setvar;
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
case concmd_ifvarvarg:
|
|
||||||
case concmd_ifvarvarl:
|
|
||||||
case concmd_ifvarvare:
|
|
||||||
{
|
|
||||||
auto const ins = &scriptptr[-1];
|
|
||||||
auto const lastScriptPtr = &scriptptr[-1] - apScript;
|
|
||||||
auto const lasttextptr = textptr;
|
|
||||||
int const lnum = line_number;
|
|
||||||
|
|
||||||
g_skipBranch = false;
|
|
||||||
|
|
||||||
C_GetNextVar();
|
|
||||||
auto const var = scriptptr;
|
|
||||||
C_GetNextVar();
|
|
||||||
|
|
||||||
if (*var == GV_FLAG_CONSTANT)
|
|
||||||
{
|
|
||||||
int const opcode = inthash_find(&h_varvar, tw);
|
|
||||||
|
|
||||||
if (opcode != -1)
|
|
||||||
{
|
|
||||||
if (g_scriptDebug > 1 && !errorcount && !warningcount)
|
|
||||||
{
|
|
||||||
Printf("%s:%d: replacing %s with %s\n", g_scriptFileName, line_number,
|
|
||||||
VM_GetKeywordForID(*ins & VM_INSTMASK), VM_GetKeywordForID(opcode));
|
|
||||||
}
|
|
||||||
|
|
||||||
scriptWriteAtOffset(opcode | LINE_NUMBER, ins);
|
|
||||||
tw = opcode;
|
|
||||||
scriptptr = &ins[1];
|
|
||||||
textptr = lasttextptr;
|
|
||||||
line_number = lnum;
|
|
||||||
goto ifvar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (C_CheckMalformedBranch(lastScriptPtr))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto const offset = scriptptr - apScript;
|
|
||||||
scriptptr++; // Leave a spot for the fail location
|
|
||||||
|
|
||||||
C_ParseCommand(0);
|
|
||||||
|
|
||||||
if (C_CheckEmptyBranch(tw, lastScriptPtr))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto const tempscrptr = apScript + offset;
|
|
||||||
scriptWritePointer((intptr_t)scriptptr, tempscrptr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
case concmd_ifvarl:
|
|
||||||
case concmd_ifvarg:
|
|
||||||
case concmd_ifvare:
|
|
||||||
{
|
|
||||||
ifvar:
|
|
||||||
auto const ins = &scriptptr[-1];
|
|
||||||
auto const lastScriptPtr = &scriptptr[-1] - apScript;
|
|
||||||
|
|
||||||
g_skipBranch = false;
|
|
||||||
|
|
||||||
C_GetNextVar();
|
|
||||||
C_GetNextValue(LABEL_DEFINE);
|
|
||||||
|
|
||||||
if (C_CheckMalformedBranch(lastScriptPtr))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// scriptUpdateOpcodeForVariableType(ins);
|
|
||||||
|
|
||||||
auto const offset = scriptptr - apScript;
|
|
||||||
scriptptr++; //Leave a spot for the fail location
|
|
||||||
|
|
||||||
C_ParseCommand(0);
|
|
||||||
|
|
||||||
if (C_CheckEmptyBranch(tw, lastScriptPtr))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto const tempscrptr = apScript + offset;
|
|
||||||
scriptWritePointer((intptr_t)scriptptr, tempscrptr);
|
|
||||||
|
|
||||||
j = C_GetKeyword();
|
|
||||||
|
|
||||||
if (j == concmd_else)
|
|
||||||
checking_ifelse++;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case concmd_endevent:
|
case concmd_endevent:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue