git-svn-id: https://svn.eduke32.com/eduke32@961 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-08-10 13:07:07 +00:00
parent a71949ed8f
commit a55cc4479a
3 changed files with 114 additions and 118 deletions

View file

@ -573,10 +573,6 @@
RelativePath=".\source\config.h" RelativePath=".\source\config.h"
> >
</File> </File>
<File
RelativePath=".\source\develop.h"
>
</File>
<File <File
RelativePath=".\source\duke3d.h" RelativePath=".\source\duke3d.h"
> >
@ -825,10 +821,6 @@
RelativePath=".\source\jmact\control.h" RelativePath=".\source\jmact\control.h"
> >
</File> </File>
<File
RelativePath=".\source\jmact\develop.h"
>
</File>
<File <File
RelativePath=".\source\jmact\file_lib.h" RelativePath=".\source\jmact\file_lib.h"
> >

View file

@ -5596,19 +5596,13 @@ static int parse(void)
{ {
int distvar = *insptr++, xvar = GetGameVarID(*insptr++, g_i, g_p), yvar = GetGameVarID(*insptr++, g_i, g_p), distx=0; int distvar = *insptr++, xvar = GetGameVarID(*insptr++, g_i, g_p), yvar = GetGameVarID(*insptr++, g_i, g_p), distx=0;
if (xvar > -1 && xvar < MAXSPRITES && yvar > -1 && yvar < MAXSPRITES) if (xvar < 0 || yvar < 0 || xvar >= MAXSPRITES || yvar >= MAXSPRITES)
{ {
switch (tw) OSD_Printf(CON_ERROR "CON_DIST/CON_LDIST: invalid sprite\n",line_num);
{ break;
case CON_DIST:
distx = dist(&sprite[xvar],&sprite[yvar]);
break;
case CON_LDIST:
distx = ldist(&sprite[xvar],&sprite[yvar]);
break;
}
} }
else OSD_Printf(CON_ERROR "CON_DIST/CON_LDIST: invalid sprite\n",line_num); if (tw == CON_DIST) distx = dist(&sprite[xvar],&sprite[yvar]);
else distx = ldist(&sprite[xvar],&sprite[yvar]);
SetGameVarID(distvar, distx, g_i, g_p); SetGameVarID(distvar, distx, g_i, g_p);
break; break;
@ -5644,12 +5638,11 @@ static int parse(void)
case CON_INITTIMER: case CON_INITTIMER:
insptr++; insptr++;
j = GetGameVarID(*insptr++, g_i, g_p); j = GetGameVarID(*insptr++, g_i, g_p);
if (timer != j) if (timer == j)
{ break;
uninittimer(); uninittimer();
inittimer(j); inittimer(j);
timer = j; timer = j;
}
break; break;
case CON_TIME: case CON_TIME:
@ -5662,9 +5655,12 @@ static int parse(void)
insptr++; insptr++;
{ {
int lIn=GetGameVarID(*insptr++, g_i, g_p); int lIn=GetGameVarID(*insptr++, g_i, g_p);
j = -1; if (g_sp->sectnum < 0 || g_sp->sectnum >= MAXSECTORS)
if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) {
j = spawn(g_i, lIn); OSD_Printf(CON_ERROR "CON_E/Q/EQSPAWNVAR: Invalid sector %d\n",line_num,g_sp->sectnum);
break;
}
j = spawn(g_i, lIn);
switch (tw) switch (tw)
{ {
case CON_EQSPAWNVAR: case CON_EQSPAWNVAR:
@ -5686,11 +5682,14 @@ static int parse(void)
case CON_QSPAWN: case CON_QSPAWN:
insptr++; insptr++;
j=-1; if (g_sp->sectnum < 0 || g_sp->sectnum >= MAXSECTORS)
{
OSD_Printf(CON_ERROR "CON_E/Q/EQSPAWN: Invalid sector %d\n",line_num,g_sp->sectnum);
insptr++;
break;
}
if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) j = spawn(g_i,*insptr++);
j = spawn(g_i,*insptr++);
else insptr++;
switch (tw) switch (tw)
{ {
@ -5718,13 +5717,19 @@ static int parse(void)
if (hittype[g_i].temp_data[9] == 0) if (hittype[g_i].temp_data[9] == 0)
hittype[g_i].temp_data[9] = 1; hittype[g_i].temp_data[9] = 1;
} }
if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
if (g_sp->sectnum < 0 || g_sp->sectnum >= MAXSECTORS)
{ {
if (tw == CON_EZSHOOT || tw == CON_ESHOOT) OSD_Printf(CON_ERROR "CON_E/Z/EZSHOOT: Invalid sector %d\n",line_num,g_sp->sectnum);
SetGameVarID(g_iReturnVarID, shoot(g_i,*insptr++), g_i, g_p); insptr++;
else shoot(g_i,*insptr++); hittype[g_i].temp_data[9]=0;
break;
} }
else insptr++;
j = shoot(g_i,*insptr++);
if (tw == CON_EZSHOOT || tw == CON_ESHOOT)
SetGameVarID(g_iReturnVarID, j, g_i, g_p);
hittype[g_i].temp_data[9]=0; hittype[g_i].temp_data[9]=0;
break; break;
@ -5745,12 +5750,17 @@ static int parse(void)
hittype[g_i].temp_data[9] = 1; hittype[g_i].temp_data[9] = 1;
} }
j=GetGameVarID(*insptr++, g_i, g_p); j=GetGameVarID(*insptr++, g_i, g_p);
if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
if (g_sp->sectnum < 0 || g_sp->sectnum >= MAXSECTORS)
{ {
lReturn = shoot(g_i, j); OSD_Printf(CON_ERROR "CON_E/Z/EZ/SHOOTVAR: Invalid sector %d\n",line_num,g_sp->sectnum);
if (tw == CON_ESHOOTVAR || tw == CON_EZSHOOTVAR) hittype[g_i].temp_data[9]=0;
SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); break;
} }
lReturn = shoot(g_i, j);
if (tw == CON_ESHOOTVAR || tw == CON_EZSHOOTVAR)
SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p);
hittype[g_i].temp_data[9]=0; hittype[g_i].temp_data[9]=0;
break; break;
} }
@ -5846,7 +5856,7 @@ static int parse(void)
if (x1 < 0 || y1 < 0 || x2 > xdim-1 || y2 > ydim-1 || x2-x1 < 2 || y2-y1 < 2) if (x1 < 0 || y1 < 0 || x2 > xdim-1 || y2 > ydim-1 || x2-x1 < 2 || y2-y1 < 2)
{ {
OSD_Printf(CON_ERROR "CON_SHOWVIEW: incorrect coordiantes\n",line_num); OSD_Printf(CON_ERROR "CON_SHOWVIEW: incorrect coordinates\n",line_num);
break; break;
} }
if (sect<0 || sect>=numsectors) if (sect<0 || sect>=numsectors)
@ -5873,7 +5883,7 @@ static int parse(void)
se40code(x,y,z,a,horiz,smoothratio); se40code(x,y,z,a,horiz,smoothratio);
#endif #endif
if (((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0) if (((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0)
#if defined(POLYMOST) && defined(USE_OPENGL) #if defined(POLYMER) && defined(USE_OPENGL)
&& (getrendermode() != 4) && (getrendermode() != 4)
#endif #endif
) )
@ -6725,7 +6735,7 @@ static int parse(void)
if (lVarID&(MAXGAMEVARS<<1)) if (lVarID&(MAXGAMEVARS<<1))
{ {
m = -1; m = -m;
lVarID ^= (MAXGAMEVARS<<1); lVarID ^= (MAXGAMEVARS<<1);
} }
@ -6746,7 +6756,7 @@ static int parse(void)
} }
else if (*insptr&(MAXGAMEVARS<<1)) else if (*insptr&(MAXGAMEVARS<<1))
{ {
m = -1; m = -m;
lVarID ^= (MAXGAMEVARS<<1); lVarID ^= (MAXGAMEVARS<<1);
} }
else else

View file

@ -33,41 +33,33 @@ extern void FreeMapState(int mapnum);
static void FreeGameVars(void) /* called from ReadGameVars() and ResetGameVars() */ static void FreeGameVars(void) /* called from ReadGameVars() and ResetGameVars() */
{ {
// call this function as many times as needed. // call this function as many times as needed.
int i; int i=(MAXGAMEVARS-1);
// AddLog("FreeGameVars"); // AddLog("FreeGameVars");
for (i=0;i<MAXGAMEVARS;i++) for (;i>=0;i--)
{ {
// aGameVars[i].lValue=0;
// if (aGameVars[i].szLabel)
//Bfree(aGameVars[i].szLabel);
// aGameVars[i].szLabel=NULL;
// aGameVars[i].dwFlags=0;
if (aGameVars[i].plValues) if (aGameVars[i].plValues)
Bfree(aGameVars[i].plValues); Bfree(aGameVars[i].plValues);
aGameVars[i].plValues=NULL; aGameVars[i].plValues=NULL;
aGameVars[i].bReset=1; aGameVars[i].bReset=1;
} if (i >= MAXGAMEARRAYS)
iGameVarCount=0; continue;
for (i=0;i<MAXGAMEARRAYS;i++)
{
if (aGameArrays[i].plValues) if (aGameArrays[i].plValues)
Bfree(aGameArrays[i].plValues); Bfree(aGameArrays[i].plValues);
aGameArrays[i].plValues=NULL; aGameArrays[i].plValues=NULL;
aGameArrays[i].bReset=1; aGameArrays[i].bReset=1;
} }
iGameArrayCount=0; iGameVarCount=iGameArrayCount=0;
return; return;
} }
static void ClearGameVars(void) static void ClearGameVars(void)
{ {
// only call this function ONCE... // only call this function ONCE...
int i; int i=(MAXGAMEVARS-1);
//AddLog("ClearGameVars"); //AddLog("ClearGameVars");
for (i=0;i<MAXGAMEVARS;i++) for (;i>=0;i--)
{ {
aGameVars[i].lValue=0; aGameVars[i].lValue=0;
if (aGameVars[i].szLabel) if (aGameVars[i].szLabel)
@ -79,10 +71,8 @@ static void ClearGameVars(void)
Bfree(aGameVars[i].plValues); Bfree(aGameVars[i].plValues);
aGameVars[i].plValues=NULL; aGameVars[i].plValues=NULL;
aGameVars[i].bReset=1; aGameVars[i].bReset=1;
} if (i >= MAXGAMEARRAYS)
iGameVarCount=0; continue;
for (i=0;i<MAXGAMEARRAYS;i++)
{
if (aGameArrays[i].szLabel) if (aGameArrays[i].szLabel)
Bfree(aGameArrays[i].szLabel); Bfree(aGameArrays[i].szLabel);
aGameArrays[i].szLabel=NULL; aGameArrays[i].szLabel=NULL;
@ -92,7 +82,7 @@ static void ClearGameVars(void)
aGameArrays[i].plValues=NULL; aGameArrays[i].plValues=NULL;
aGameArrays[i].bReset=1; aGameArrays[i].bReset=1;
} }
iGameArrayCount=0; iGameVarCount=iGameArrayCount=0;
return; return;
} }
@ -564,9 +554,9 @@ int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags)
void ResetActorGameVars(int iActor) void ResetActorGameVars(int iActor)
{ {
int i; int i=(MAXGAMEVARS-1);
// OSD_Printf("resetting vars for actor %d\n",iActor); // OSD_Printf("resetting vars for actor %d\n",iActor);
for (i=0;i<MAXGAMEVARS;i++) for (;i>=0;i--)
if ((aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR) && !(aGameVars[i].dwFlags & GAMEVAR_FLAG_NODEFAULT)) if ((aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR) && !(aGameVars[i].dwFlags & GAMEVAR_FLAG_NODEFAULT))
{ {
// OSD_Printf("reset %s (%d) to %s (%d)\n",aGameVars[i].szLabel,aGameVars[i].plValues[iActor],aDefaultGameVars[i].szLabel,aDefaultGameVars[i].lValue); // OSD_Printf("reset %s (%d) to %s (%d)\n",aGameVars[i].szLabel,aGameVars[i].plValues[iActor],aDefaultGameVars[i].szLabel,aDefaultGameVars[i].lValue);
@ -593,77 +583,81 @@ static int GetGameID(const char *szGameLabel)
int GetGameVarID(int id, int iActor, int iPlayer) int GetGameVarID(int id, int iActor, int iPlayer)
{ {
int m = 1;
if (id == MAXGAMEVARS) if (id == MAXGAMEVARS)
return(*insptr++); return(*insptr++);
if (id == g_iThisActorID) if (id == g_iThisActorID)
return iActor; return iActor;
if (id >= iGameVarCount || id<0)
{ {
if (id&(MAXGAMEVARS<<2)) int m = 1;
if (id >= iGameVarCount || id<0)
{ {
int index=GetGameVarID(*insptr++,iActor,iPlayer); if (id&(MAXGAMEVARS<<2))
id &= ~(MAXGAMEVARS<<2);
if (id&(MAXGAMEVARS<<1)) // negative array access
{ {
m = -1; int index=GetGameVarID(*insptr++,iActor,iPlayer);
id &= ~(MAXGAMEVARS<<1);
id &= ~(MAXGAMEVARS<<2);
if (id&(MAXGAMEVARS<<1)) // negative array access
{
m = -m;
id &= ~(MAXGAMEVARS<<1);
}
// OSD_Printf("GetGameVarID(): reading from array\n");
if (index >= aGameArrays[id].size || index < 0)
{
OSD_Printf(OSD_ERROR "GetGameVarID(): invalid array index (%s[%d])\n",aGameArrays[id].szLabel,index);
return -1;
}
return(m * aGameArrays[id].plValues[index]);
} }
// OSD_Printf("GetGameVarID(): reading from array\n"); if ((id&(MAXGAMEVARS<<1)) == 0)
if ((index < aGameArrays[id].size)&&(index>=0)) {
return(m * aGameArrays[id].plValues[index]); OSD_Printf(OSD_ERROR "GetGameVarID(): invalid gamevar ID (%d)\n",id);
OSD_Printf(OSD_ERROR "GetGameVarID(): invalid array index (%s[%d])\n",aGameArrays[id].szLabel,index); return -1;
return -1; }
m = -m;
id &= ~(MAXGAMEVARS<<1);
} }
if (!(id&(MAXGAMEVARS<<1))) if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER)
{ {
OSD_Printf(OSD_ERROR "GetGameVarID(): invalid gamevar ID (%d)\n",id); // for the current player
return -1; if (iPlayer < 0 || iPlayer >= MAXPLAYERS)
} {
OSD_Printf(OSD_ERROR "GetGameVarID(): invalid player ID (%d)\n",iPlayer);
m = -1; return -1;
id &= ~(MAXGAMEVARS<<1); }
}
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER)
{
// for the current player
if (iPlayer >= 0 && iPlayer < MAXPLAYERS)
{
//Bsprintf(g_szBuf,"GetGameVarID(%d, %d, %d) returns %d\n",id,iActor,iPlayer, aGameVars[id].plValues[iPlayer]);
//AddLog(g_szBuf);
return(m * aGameVars[id].plValues[iPlayer]); return(m * aGameVars[id].plValues[iPlayer]);
} }
return(m * aGameVars[id].lValue); if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR)
} {
// for the current actor
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) if (iActor < 0 || iActor >= MAXSPRITES)
{ {
// for the current actor OSD_Printf(OSD_ERROR "GetGameVarID(): invalid sprite ID (%d)\n",iActor);
if (iActor >= 0 && iActor <= MAXSPRITES) return -1;
}
return(m * aGameVars[id].plValues[iActor]); return(m * aGameVars[id].plValues[iActor]);
}
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_INTPTR)
return(m * (*((int*)aGameVars[id].lValue)));
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_SHORTPTR)
return(m * (*((short*)aGameVars[id].lValue)));
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_CHARPTR)
return(m * (*((char*)aGameVars[id].lValue)));
return(m * aGameVars[id].lValue); return(m * aGameVars[id].lValue);
} }
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_INTPTR)
return(m * (*((int*)aGameVars[id].lValue)));
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_SHORTPTR)
return(m * (*((short*)aGameVars[id].lValue)));
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_CHARPTR)
return(m * (*((char*)aGameVars[id].lValue)));
return(m * aGameVars[id].lValue);
} }
void SetGameArrayID(int id,int index, int lValue) void SetGameArrayID(int id,int index, int lValue)
@ -1401,7 +1395,7 @@ void InitGameVarPointers(void)
//AddLog("InitGameVarPointers"); //AddLog("InitGameVarPointers");
for (i=0;i<MAX_WEAPONS;i++) for (i=(MAX_WEAPONS-1);i>=0;i--)
{ {
Bsprintf(aszBuf,"WEAPON%d_CLIP",i); Bsprintf(aszBuf,"WEAPON%d_CLIP",i);
aplWeaponClip[i]=GetGameValuePtr(aszBuf); aplWeaponClip[i]=GetGameValuePtr(aszBuf);