mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 02:30:46 +00:00
Negative gamearray access
git-svn-id: https://svn.eduke32.com/eduke32@715 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
48dae664b8
commit
9bfd183cec
3 changed files with 56 additions and 38 deletions
|
@ -1440,24 +1440,21 @@ static void transvartype(int type)
|
|||
skipcomments(); //skip comments and whitespace
|
||||
if ((*textptr == '[')) //read of array as a gamevar
|
||||
{
|
||||
|
||||
f |= (MAXGAMEVARS<<2);
|
||||
// initprintf("got an array");
|
||||
textptr++;
|
||||
i=GetADefID(label+(labelcnt<<6));
|
||||
if (i >= 0)
|
||||
{
|
||||
*scriptptr++=i+1+MAXGAMEVARS;
|
||||
transvartype(0);
|
||||
|
||||
}
|
||||
else
|
||||
if (i < 0)
|
||||
{
|
||||
error++;
|
||||
ReportError(ERROR_NOTAGAMEARRAY);
|
||||
return;
|
||||
}
|
||||
|
||||
*scriptptr++=(i|f);
|
||||
transvartype(0);
|
||||
skipcomments(); //skip comments and whitespace
|
||||
|
||||
if (*textptr != ']')
|
||||
{
|
||||
error++;
|
||||
|
@ -1521,8 +1518,8 @@ static void transvartype(int type)
|
|||
}
|
||||
if (!(error || warning) && g_ScriptDebug > 1)
|
||||
initprintf("%s:%d: debug: accepted gamevar `%s'.\n",compilefile,line_number,label+(labelcnt<<6));
|
||||
i |= f;
|
||||
*scriptptr++=i;
|
||||
|
||||
*scriptptr++=(i|f);
|
||||
}
|
||||
|
||||
static inline void transvar(void)
|
||||
|
|
|
@ -6333,21 +6333,25 @@ static int parse(void)
|
|||
{
|
||||
if (*insptr==MAXGAMEVARS) // addlogvar for a constant? Har.
|
||||
insptr++;
|
||||
else if (*insptr&(MAXGAMEVARS<<1))
|
||||
{
|
||||
m = -1;
|
||||
lVarID ^= (MAXGAMEVARS<<1);
|
||||
}
|
||||
else if (*insptr < MAXGAMEVARS+1+MAXGAMEARRAYS)
|
||||
// else if (*insptr > iGameVarCount && (*insptr < (MAXGAMEVARS<<1)+MAXGAMEVARS+1+MAXGAMEARRAYS))
|
||||
else if (*insptr&(MAXGAMEVARS<<2))
|
||||
{
|
||||
int index;
|
||||
|
||||
lVarID ^= (MAXGAMEVARS<<2);
|
||||
|
||||
if (lVarID&(MAXGAMEVARS<<1))
|
||||
{
|
||||
m = -1;
|
||||
lVarID ^= (MAXGAMEVARS<<1);
|
||||
}
|
||||
|
||||
insptr++;
|
||||
|
||||
index=GetGameVarID(*insptr++,g_i,g_p);
|
||||
if ((index < aGameArrays[lVarID-MAXGAMEVARS-1].size)&&(index>=0))
|
||||
if ((index < aGameArrays[lVarID].size)&&(index>=0))
|
||||
{
|
||||
OSD_Printf("CONLOGVAR: L=%d %s[%d] =%d\n",l, aGameArrays[lVarID-MAXGAMEVARS-1].szLabel,index,aGameArrays[lVarID-MAXGAMEVARS-1].plValues[index]);
|
||||
OSD_Printf("CONLOGVAR: L=%d %s[%d] =%d\n",l, aGameArrays[lVarID].szLabel,index,m*aGameArrays[lVarID].plValues[index]);
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
@ -6356,6 +6360,11 @@ static int parse(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (*insptr&(MAXGAMEVARS<<1))
|
||||
{
|
||||
m = -1;
|
||||
lVarID ^= (MAXGAMEVARS<<1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// invalid varID
|
||||
|
@ -7392,10 +7401,10 @@ void execute(int iActor,int iPlayer,int lDist)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Qbix: Changed variables to be aware of the sizeof *insptr
|
||||
* (wether it is int vs intptr_t), Although it is specificly cast to intptr_t*
|
||||
* which might be corrected if the code is converted to use offsets */
|
||||
if (g_t[4])
|
||||
/* Qbix: Changed variables to be aware of the sizeof *insptr
|
||||
* (wether it is int vs intptr_t), Although it is specificly cast to intptr_t*
|
||||
* which might be corrected if the code is converted to use offsets */
|
||||
if (g_t[4])
|
||||
{
|
||||
g_sp->lotag += TICSPERFRAME;
|
||||
|
||||
|
|
|
@ -532,30 +532,41 @@ int GetGameVarID(int id, int iActor, int iPlayer)
|
|||
{
|
||||
int inv = 0;
|
||||
|
||||
if (id == MAXGAMEVARS)
|
||||
{
|
||||
// OSD_Printf("GetGameVarID(): reading gamevar constant\n");
|
||||
return(*insptr++);
|
||||
}
|
||||
|
||||
if (id == g_iThisActorID)
|
||||
return iActor;
|
||||
|
||||
if (id<0 || id >= iGameVarCount)
|
||||
{
|
||||
if (id==MAXGAMEVARS)
|
||||
// if (id < (MAXGAMEVARS<<1)+MAXGAMEVARS+1+MAXGAMEARRAYS)
|
||||
if (id&(MAXGAMEVARS<<2))
|
||||
{
|
||||
// OSD_Printf("GetGameVarID(): reading gamevar constant\n");
|
||||
return(*insptr++);
|
||||
}
|
||||
if (id < MAXGAMEVARS+1+MAXGAMEARRAYS)
|
||||
{
|
||||
int index=0;
|
||||
// OSD_Printf("GetGameVarID(): reading from array\n");
|
||||
index=GetGameVarID(*insptr++,iActor,iPlayer);
|
||||
if ((index < aGameArrays[id-MAXGAMEVARS-1].size)&&(index>=0))
|
||||
inv =aGameArrays[id-MAXGAMEVARS-1].plValues[index];
|
||||
else
|
||||
int index=GetGameVarID(*insptr++,iActor,iPlayer);
|
||||
|
||||
id ^= (MAXGAMEVARS<<2);
|
||||
|
||||
if (id&(MAXGAMEVARS<<1)) // negative array access
|
||||
{
|
||||
OSD_Printf("GetGameVarID(): invalid array index (%s[%d])\n",aGameArrays[id-MAXGAMEVARS-1].szLabel,index);
|
||||
id ^= (MAXGAMEVARS<<1);
|
||||
// OSD_Printf("GetGameVarID(): reading from array\n");
|
||||
if ((index < aGameArrays[id].size)&&(index>=0))
|
||||
return(-aGameArrays[id].plValues[index]);
|
||||
OSD_Printf("GetGameVarID(): invalid array index (%s[%d])\n",aGameArrays[id].szLabel,index);
|
||||
return -1;
|
||||
}
|
||||
return(inv);
|
||||
|
||||
// OSD_Printf("GetGameVarID(): reading from array\n");
|
||||
if ((index < aGameArrays[id].size)&&(index>=0))
|
||||
return(aGameArrays[id].plValues[index]);
|
||||
OSD_Printf("GetGameVarID(): invalid array index (%s[%d])\n",aGameArrays[id].szLabel,index);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(id&(MAXGAMEVARS<<1)))
|
||||
{
|
||||
OSD_Printf("GetGameVarID(): invalid gamevar ID (%d)\n",id);
|
||||
|
@ -701,8 +712,9 @@ int GetGameVar(const char *szGameLabel, int lDefault, int iActor, int iPlayer)
|
|||
|
||||
static intptr_t *GetGameValuePtr(const char *szGameLabel)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<iGameVarCount;i++)
|
||||
int i=0;
|
||||
|
||||
for (;i<iGameVarCount;i++)
|
||||
{
|
||||
if (aGameVars[i].szLabel != NULL)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue