Death to local variables

git-svn-id: https://svn.eduke32.com/eduke32@430 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-12-18 21:29:55 +00:00
parent 19115146ac
commit 31775358e6
3 changed files with 233 additions and 427 deletions

View file

@ -81,10 +81,10 @@ static double dxb1[MAXWALLSB], dxb2[MAXWALLSB];
#define USEZBUFFER 1 //1:use zbuffer (slow, nice sprite rendering), 0:no zbuffer (fast, bad sprite rendering) #define USEZBUFFER 1 //1:use zbuffer (slow, nice sprite rendering), 0:no zbuffer (fast, bad sprite rendering)
#define LINTERPSIZ 4 //log2 of interpolation size. 4:pretty fast&acceptable quality, 0:best quality/slow! #define LINTERPSIZ 4 //log2 of interpolation size. 4:pretty fast&acceptable quality, 0:best quality/slow!
#define DEPTHDEBUG 0 //1:render distance instead of texture, for debugging only!, 0:default #define DEPTHDEBUG 0 //1:render distance instead of texture, for debugging only!, 0:default
#define FOGSCALE 0.0000640 #define FOGSCALE 0.0000680
#define PI 3.14159265358979323 #define PI 3.14159265358979323
float shadescale = 1.250; float shadescale = 1.050;
static double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz; static double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz;
static double gcosang, gsinang, gcosang2, gsinang2; static double gcosang, gsinang, gcosang2, gsinang2;
@ -4990,7 +4990,7 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm)
return OSDCMD_OK; return OSDCMD_OK;
} }
else if (!Bstrcasecmp(parm->name, "r_shadescale")) { else if (!Bstrcasecmp(parm->name, "r_shadescale")) {
if (showval) { OSD_Printf("r_shadescale is %d\n", shadescale); } if (showval) { OSD_Printf("r_shadescale is %g\n", shadescale); }
else else
{ {
float fval = atof(parm->parms[0]); float fval = atof(parm->parms[0]);

View file

@ -3616,12 +3616,6 @@ static int parse(void)
{ {
long j, l, s, tw; long j, l, s, tw;
if (!(error || warning) && condebug)
{
// Bsprintf(g_szBuf," * DEBUG! Executing: %s",keyw[*insptr]);
// AddLog(g_szBuf);
}
if (killit_flag) return 1; if (killit_flag) return 1;
// if(*it == 1668249134L) gameexit("\nERR"); // if(*it == 1668249134L) gameexit("\nERR");
@ -3633,14 +3627,15 @@ static int parse(void)
switch (tw) switch (tw)
{ {
case CON_REDEFINEQUOTE: case CON_REDEFINEQUOTE:
insptr++;
{ {
int q, i; int q = *insptr++, i = *insptr++;
insptr++;
q = *insptr++;
i = *insptr++;
if (fta_quotes[q] == NULL || redefined_quotes[i] == NULL) if (fta_quotes[q] == NULL || redefined_quotes[i] == NULL)
{
OSD_Printf("%s %d null quote %d %d\n",__FILE__,__LINE__,q,i); OSD_Printf("%s %d null quote %d %d\n",__FILE__,__LINE__,q,i);
else Bstrcpy(fta_quotes[q],redefined_quotes[i]); break;
}
Bstrcpy(fta_quotes[q],redefined_quotes[i]);
break; break;
} }
@ -4222,9 +4217,7 @@ SKIPJIBS:
case CON_STATE: case CON_STATE:
{ {
long *tempscrptr; long *tempscrptr=insptr+2;
tempscrptr = insptr+2;
insptr = (long *) *(insptr+1); insptr = (long *) *(insptr+1);
while (1) if (parse()) break; while (1) if (parse()) break;
@ -4273,12 +4266,9 @@ SKIPJIBS:
case CON_OPERATEACTIVATORS: case CON_OPERATEACTIVATORS:
case CON_SETASPECT: case CON_SETASPECT:
case CON_SSP: case CON_SSP:
insptr++;
{ {
long var1, var2; int var1 = GetGameVarID(*insptr++,g_i,g_p), var2;
insptr++;
var1 = GetGameVarID(*insptr++,g_i,g_p);
if (tw == CON_OPERATEACTIVATORS && *insptr == g_iThisActorID) if (tw == CON_OPERATEACTIVATORS && *insptr == g_iThisActorID)
{ {
var2 = g_p; var2 = g_p;
@ -4308,16 +4298,11 @@ SKIPJIBS:
} }
case CON_CANSEESPR: case CON_CANSEESPR:
insptr++;
{ {
long lVar1, lVar2, lVar3; int lVar1 = GetGameVarID(*insptr++,g_i,g_p), lVar2 = GetGameVarID(*insptr++,g_i,g_p);
insptr++; SetGameVarID(*insptr++, cansee(sprite[lVar1].x,sprite[lVar1].y,sprite[lVar1].z,sprite[lVar1].sectnum,
lVar1 = GetGameVarID(*insptr++,g_i,g_p);
lVar2 = GetGameVarID(*insptr++,g_i,g_p);
lVar3 = *insptr++;
SetGameVarID(lVar3, cansee(sprite[lVar1].x,sprite[lVar1].y,sprite[lVar1].z,sprite[lVar1].sectnum,
sprite[lVar2].x,sprite[lVar2].y,sprite[lVar2].z,sprite[lVar2].sectnum), g_i, g_p); sprite[lVar2].x,sprite[lVar2].y,sprite[lVar2].z,sprite[lVar2].sectnum), g_i, g_p);
break; break;
} }
@ -4325,11 +4310,9 @@ SKIPJIBS:
case CON_OPERATERESPAWNS: case CON_OPERATERESPAWNS:
case CON_OPERATEMASTERSWITCHES: case CON_OPERATEMASTERSWITCHES:
case CON_CHECKACTIVATORMOTION: case CON_CHECKACTIVATORMOTION:
insptr++;
{ {
long var1; int var1 = GetGameVarID(*insptr++,g_i,g_p);
insptr++;
var1 = GetGameVarID(*insptr++,g_i,g_p);
switch (tw) switch (tw)
{ {
@ -4352,14 +4335,16 @@ SKIPJIBS:
break; break;
case CON_QSTRLEN: case CON_QSTRLEN:
insptr++;
{ {
int i,j; int i=*insptr++;
insptr++;
i=*insptr++;
j=GetGameVarID(*insptr++, g_i, g_p); j=GetGameVarID(*insptr++, g_i, g_p);
if (fta_quotes[j] != NULL) if (fta_quotes[j] == NULL)
SetGameVarID(i,Bstrlen(fta_quotes[j]),g_i,g_p); {
else SetGameVarID(i,-1,g_i,g_p); SetGameVarID(i,-1,g_i,g_p);
break;
}
SetGameVarID(i,Bstrlen(fta_quotes[j]),g_i,g_p);
break; break;
} }
@ -4368,11 +4353,9 @@ SKIPJIBS:
case CON_QSTRCPY: case CON_QSTRCPY:
case CON_CHANGESPRITESTAT: case CON_CHANGESPRITESTAT:
case CON_CHANGESPRITESECT: case CON_CHANGESPRITESECT:
insptr++;
{ {
int i,j; int i = GetGameVarID(*insptr++, g_i, g_p), j;
insptr++;
i = GetGameVarID(*insptr++, g_i, g_p);
if (tw == CON_GETPNAME && *insptr == g_iThisActorID) if (tw == CON_GETPNAME && *insptr == g_iThisActorID)
{ {
j = g_p; j = g_p;
@ -4412,39 +4395,16 @@ SKIPJIBS:
} }
case CON_STARTLEVEL: case CON_STARTLEVEL:
insptr++; // skip command
{ {
// from 'level' cheat in game.c (about line 6250) // from 'level' cheat in game.c (about line 6250)
long volnume; int volnume=GetGameVarID(*insptr++,g_i,g_p), levnume=GetGameVarID(*insptr++,g_i,g_p);
long levnume;
int i;
insptr++; // skip command
volnume=GetGameVarID(*insptr++,g_i,g_p);
levnume=GetGameVarID(*insptr++,g_i,g_p);
if (volnume > MAXVOLUMES-1 || volnume < 0) if (volnume > MAXVOLUMES-1 || volnume < 0)
{
/*
if(g_cmddebug&CMDDEBUG_COMPILE)
{
Bsprintf(g_szBuf,"startlevel: Invalid Volume number: %ld. Command ignored.",volnume);
AddLog(g_szBuf);
}
*/
break; break;
}
if (levnume > MAXLEVELS-1 || levnume < 0) if (levnume > MAXLEVELS-1 || levnume < 0)
{
/*
if(g_cmddebug&CMDDEBUG_COMPILE)
{
Bsprintf(g_szBuf,"startlevel: Invalid Level number: %ld. Command ignored.",levnume);
AddLog(g_szBuf);
}
*/
break; break;
}
ud.m_volume_number = ud.volume_number = volnume; ud.m_volume_number = ud.volume_number = volnume;
ud.m_level_number = ud.level_number = levnume; ud.m_level_number = ud.level_number = levnume;
@ -4622,10 +4582,9 @@ SKIPJIBS:
} }
case CON_INITTIMER: case CON_INITTIMER:
insptr++;
{ {
short i; int i = GetGameVarID(*insptr++, g_i, g_p);
insptr++;
i = GetGameVarID(*insptr++, g_i, g_p);
if (timer != i) if (timer != i)
{ {
uninittimer(); uninittimer();
@ -4644,12 +4603,10 @@ SKIPJIBS:
case CON_ESPAWNVAR: case CON_ESPAWNVAR:
case CON_EQSPAWNVAR: case CON_EQSPAWNVAR:
case CON_QSPAWNVAR: case CON_QSPAWNVAR:
insptr++;
{ {
long lIn, lReturn=-1; int lIn=GetGameVarID(*insptr++, g_i, g_p), lReturn=-1;
insptr++;
lIn=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 = spawn(g_i, lIn); lReturn = spawn(g_i, lIn);
switch (tw) switch (tw)
@ -4699,9 +4656,8 @@ SKIPJIBS:
case CON_EZSHOOT: case CON_EZSHOOT:
case CON_ZSHOOT: case CON_ZSHOOT:
{ {
long lReturn=-1;
insptr++; insptr++;
if (tw == CON_ZSHOOT || tw == CON_EZSHOOT) if (tw == CON_ZSHOOT || tw == CON_EZSHOOT)
{ {
hittype[g_i].temp_data[9] = GetGameVarID(*insptr++, g_i, g_p); hittype[g_i].temp_data[9] = GetGameVarID(*insptr++, g_i, g_p);
@ -4710,9 +4666,9 @@ SKIPJIBS:
} }
if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS) if (g_sp->sectnum >= 0 && g_sp->sectnum < MAXSECTORS)
{ {
lReturn = shoot(g_i,*insptr++);
if (tw == CON_EZSHOOT || tw == CON_ESHOOT) if (tw == CON_EZSHOOT || tw == CON_ESHOOT)
SetGameVarID(g_iReturnVarID, lReturn, g_i, g_p); SetGameVarID(g_iReturnVarID, shoot(g_i,*insptr++), g_i, g_p);
else shoot(g_i,*insptr++);
} }
else insptr++; else insptr++;
@ -4750,11 +4706,9 @@ SKIPJIBS:
case CON_STOPSOUNDVAR: case CON_STOPSOUNDVAR:
case CON_SOUNDONCEVAR: case CON_SOUNDONCEVAR:
case CON_GLOBALSOUNDVAR: case CON_GLOBALSOUNDVAR:
insptr++;
{ {
int sound; int sound=GetGameVarID(*insptr++, g_i, g_p);
insptr++;
sound=GetGameVarID(*insptr++, g_i, g_p);
switch (tw) switch (tw)
{ {
@ -4779,9 +4733,9 @@ SKIPJIBS:
case CON_GUNIQHUDID: case CON_GUNIQHUDID:
insptr++; insptr++;
{ {
int i=GetGameVarID(*insptr++, g_i, g_p); j=GetGameVarID(*insptr++, g_i, g_p);
if (i < MAXUNIQHUDID-1) if (j < MAXUNIQHUDID-1)
guniqhudid = i; guniqhudid = j;
break; break;
} }
@ -5495,13 +5449,12 @@ SKIPJIBS:
} }
case CON_ADDLOGVAR: case CON_ADDLOGVAR:
insptr++;
{ {
long l,m=1,lVarID; int m=1;
char szBuf[256]; char szBuf[256];
insptr++; long l=*insptr++, lVarID = *insptr;
l=*insptr++; // l=Line number, *instpr=varID
lVarID = *insptr;
if ((lVarID >= iGameVarCount) || lVarID < 0) if ((lVarID >= iGameVarCount) || lVarID < 0)
{ {
if (*insptr==MAXGAMEVARS) // addlogvar for a constant? Har. if (*insptr==MAXGAMEVARS) // addlogvar for a constant? Har.
@ -5732,6 +5685,7 @@ good:
case CON_FINDPLAYER: case CON_FINDPLAYER:
case CON_FINDOTHERPLAYER: case CON_FINDOTHERPLAYER:
insptr++;
{ {
// syntax findnearactorvar <type> <maxdistvar> <getvar> // syntax findnearactorvar <type> <maxdistvar> <getvar>
// gets the sprite ID of the nearest actor within max dist // gets the sprite ID of the nearest actor within max dist
@ -5739,10 +5693,7 @@ good:
// -1 for none found // -1 for none found
// <type> <maxdistvarid> <varid> // <type> <maxdistvarid> <varid>
short j=0; short j=0;
long var1, d; long var1 = *insptr++, d;
insptr++;
var1 = *insptr++;
if (tw == CON_FINDPLAYER) j=findplayer(&sprite[g_i],&d); if (tw == CON_FINDPLAYER) j=findplayer(&sprite[g_i],&d);
else if (tw == CON_FINDOTHERPLAYER) j=findotherplayer(g_i,&d); else if (tw == CON_FINDOTHERPLAYER) j=findotherplayer(g_i,&d);
@ -5890,18 +5841,10 @@ good:
} }
case CON_GETANGLETOTARGET: case CON_GETANGLETOTARGET:
{ insptr++;
int i;
short ang;
insptr++;
i=*insptr++;
// hittype[g_i].lastvx and lastvy are last known location of target. // hittype[g_i].lastvx and lastvy are last known location of target.
ang=getangle(hittype[g_i].lastvx-g_sp->x,hittype[g_i].lastvy-g_sp->y); SetGameVarID(*insptr++, getangle(hittype[g_i].lastvx-g_sp->x,hittype[g_i].lastvy-g_sp->y), g_i, g_p);
SetGameVarID(i, ang, g_i, g_p);
break; break;
}
case CON_ANGOFFVAR: case CON_ANGOFFVAR:
insptr++; insptr++;
@ -5915,22 +5858,19 @@ good:
case CON_CHECKAVAILWEAPON: case CON_CHECKAVAILWEAPON:
case CON_CHECKAVAILINVEN: case CON_CHECKAVAILINVEN:
{ insptr++;
int i = g_p; j = g_p;
insptr++;
if (*insptr != g_iThisActorID) if (*insptr != g_iThisActorID)
i=GetGameVarID(*insptr++, g_i, g_p); j=GetGameVarID(*insptr++, g_i, g_p);
if (i < MAXPLAYERS) if (j < MAXPLAYERS)
{ {
if (tw == CON_CHECKAVAILWEAPON) if (tw == CON_CHECKAVAILWEAPON)
checkavailweapon(&ps[i]); checkavailweapon(&ps[j]);
else checkavailinven(&ps[i]); else checkavailinven(&ps[j]);
} }
break; break;
}
case CON_GETPLAYERANGLE: case CON_GETPLAYERANGLE:
insptr++; insptr++;
@ -5955,378 +5895,269 @@ good:
break; break;
case CON_SETVAR: case CON_SETVAR:
insptr++; insptr++;
{ SetGameVarID(*insptr, *(insptr+1), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, *insptr++, g_i, g_p);
break; break;
}
case CON_SETVARVAR: case CON_SETVARVAR:
insptr++; insptr++;
{ SetGameVarID(*insptr, GetGameVarID(*(insptr+1), g_i, g_p), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, GetGameVarID(*insptr++, g_i, g_p), g_i, g_p);
break; break;
}
case CON_RANDVAR: case CON_RANDVAR:
insptr++; insptr++;
{ SetGameVarID(*insptr, mulscale(krand(), *(insptr+1)+1, 16), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, mulscale(krand(), *(insptr++)+1, 16), g_i, g_p);
break; break;
}
case CON_DISPLAYRANDVAR: case CON_DISPLAYRANDVAR:
insptr++; insptr++;
{ SetGameVarID(*insptr, mulscale(rand(), *(insptr+1)+1, 15), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, mulscale(rand(), *(insptr++)+1, 15), g_i, g_p);
break; break;
}
case CON_MULVAR: case CON_MULVAR:
insptr++; insptr++;
{ SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) * *(insptr+1), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, GetGameVarID(i, g_i, g_p) * *insptr++, g_i, g_p);
break; break;
}
case CON_DIVVAR: case CON_DIVVAR:
insptr++; insptr++;
{ if (*(insptr+1) == 0)
int i=*insptr++;
if ((*insptr) == 0)
gameexit("CON_DIVVAR: Divide by zero."); gameexit("CON_DIVVAR: Divide by zero.");
SetGameVarID(i, GetGameVarID(i, g_i, g_p) / *insptr++, g_i, g_p); SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) / *(insptr+1), g_i, g_p);
insptr += 2;
break; break;
}
case CON_MODVAR: case CON_MODVAR:
insptr++; insptr++;
{ if (*(insptr+1) == 0)
int i=*insptr++;
if (*insptr == 0)
gameexit("CON_MODVAR: Mod by zero."); gameexit("CON_MODVAR: Mod by zero.");
SetGameVarID(i,GetGameVarID(i, g_i, g_p)%*insptr++, g_i, g_p); SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p)%*(insptr+1), g_i, g_p);
insptr += 2;
break; break;
}
case CON_ANDVAR: case CON_ANDVAR:
insptr++; insptr++;
{ SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p) & *(insptr+1), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i,GetGameVarID(i, g_i, g_p) & *insptr++, g_i, g_p);
break; break;
}
case CON_ORVAR: case CON_ORVAR:
insptr++; insptr++;
{ SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p) | *(insptr+1), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i,GetGameVarID(i, g_i, g_p) | *insptr++, g_i, g_p);
break; break;
}
case CON_XORVAR: case CON_XORVAR:
insptr++; insptr++;
{ SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p) ^ *(insptr+1), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i,GetGameVarID(i, g_i, g_p) ^ *insptr++, g_i, g_p);
break; break;
}
case CON_RANDVARVAR: case CON_RANDVARVAR:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; SetGameVarID(j,mulscale(krand(), GetGameVarID(*insptr++, g_i, g_p)+1, 16), g_i, g_p);
SetGameVarID(i,mulscale(krand(), GetGameVarID(*insptr++, g_i, g_p)+1, 16), g_i, g_p);
break; break;
}
case CON_DISPLAYRANDVARVAR: case CON_DISPLAYRANDVARVAR:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; SetGameVarID(j,mulscale(rand(), GetGameVarID(*insptr++, g_i, g_p)+1, 15), g_i, g_p);
SetGameVarID(i,mulscale(rand(), GetGameVarID(*insptr++, g_i, g_p)+1, 15), g_i, g_p);
break; break;
}
case CON_GMAXAMMO: case CON_GMAXAMMO:
insptr++; insptr++;
{ j=GetGameVarID(*insptr++, g_i, g_p);
int i=GetGameVarID(*insptr++, g_i, g_p); SetGameVarID(*insptr++, max_ammo_amount[j], g_i, g_p);
SetGameVarID(*insptr++, max_ammo_amount[i], g_i, g_p);
break; break;
}
case CON_SMAXAMMO: case CON_SMAXAMMO:
insptr++; insptr++;
{ j=GetGameVarID(*insptr++, g_i, g_p);
int i=GetGameVarID(*insptr++, g_i, g_p); max_ammo_amount[j]=GetGameVarID(*insptr++, g_i, g_p);
max_ammo_amount[i]=GetGameVarID(*insptr++, g_i, g_p);
break; break;
}
case CON_MULVARVAR: case CON_MULVARVAR:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; SetGameVarID(j, GetGameVarID(j, g_i, g_p)*GetGameVarID(*insptr++, g_i, g_p), g_i, g_p);
int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p);
SetGameVarID(i, l1*l2, g_i, g_p);
break; break;
}
case CON_DIVVARVAR: case CON_DIVVARVAR:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; {
int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p); int l2=GetGameVarID(*insptr++, g_i, g_p);
if (l2==0)
gameexit("CON_DIVVARVAR: Divide by zero.");
SetGameVarID(i, l1/l2 , g_i, g_p); if (l2==0)
break; gameexit("CON_DIVVARVAR: Divide by zero.");
}
SetGameVarID(j, GetGameVarID(j, g_i, g_p)/l2 , g_i, g_p);
break;
}
case CON_MODVARVAR: case CON_MODVARVAR:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; {
int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p); int l2=GetGameVarID(*insptr++, g_i, g_p);
if (l2==0)
gameexit("CON_MODVARVAR: Mod by zero.");
SetGameVarID(i, l1 % l2, g_i, g_p); if (l2==0)
break; gameexit("CON_MODVARVAR: Mod by zero.");
}
SetGameVarID(j, GetGameVarID(j, g_i, g_p) % l2, g_i, g_p);
break;
}
case CON_ANDVARVAR: case CON_ANDVARVAR:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; SetGameVarID(j, GetGameVarID(j, g_i, g_p) & GetGameVarID(*insptr++, g_i, g_p), g_i, g_p);
int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p);
SetGameVarID(i, l1 & l2 , g_i, g_p);
break; break;
}
case CON_XORVARVAR: case CON_XORVARVAR:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; SetGameVarID(j, GetGameVarID(j, g_i, g_p) ^ GetGameVarID(*insptr++, g_i, g_p) , g_i, g_p);
int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p);
SetGameVarID(i, l1 ^ l2 , g_i, g_p);
break; break;
}
case CON_ORVARVAR: case CON_ORVARVAR:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; SetGameVarID(j, GetGameVarID(j, g_i, g_p) | GetGameVarID(*insptr++, g_i, g_p) , g_i, g_p);
int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p);
SetGameVarID(i, l1 | l2 , g_i, g_p);
break; break;
}
case CON_SUBVAR: case CON_SUBVAR:
insptr++; insptr++;
{ SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) - *(insptr+1), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, GetGameVarID(i, g_i, g_p) - *insptr++, g_i, g_p);
break; break;
}
case CON_SUBVARVAR: case CON_SUBVARVAR:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; SetGameVarID(j, GetGameVarID(j, g_i, g_p) - GetGameVarID(*insptr++, g_i, g_p), g_i, g_p);
SetGameVarID(i, GetGameVarID(i, g_i, g_p) - GetGameVarID(*insptr++, g_i, g_p), g_i, g_p);
break; break;
}
case CON_ADDVAR: case CON_ADDVAR:
insptr++; insptr++;
{ SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) + *(insptr+1), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, GetGameVarID(i, g_i, g_p) + *insptr++, g_i, g_p);
break; break;
}
case CON_SHIFTVARL: case CON_SHIFTVARL:
insptr++; insptr++;
{ SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) << *(insptr+1), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, GetGameVarID(i, g_i, g_p) << *insptr++, g_i, g_p);
break; break;
}
case CON_SHIFTVARR: case CON_SHIFTVARR:
insptr++; insptr++;
{ SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) >> *(insptr+1), g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, GetGameVarID(i, g_i, g_p) >> *insptr++, g_i, g_p);
break; break;
}
case CON_SIN: case CON_SIN:
insptr++; insptr++;
{ SetGameVarID(*insptr, sintable[GetGameVarID(*(insptr+1), g_i, g_p)&2047], g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, sintable[GetGameVarID(*insptr++, g_i, g_p)&2047], g_i, g_p);
break; break;
}
case CON_COS: case CON_COS:
insptr++; insptr++;
{ SetGameVarID(*insptr, sintable[(GetGameVarID(*(insptr+1), g_i, g_p)+512)&2047], g_i, g_p);
int i=*insptr++; insptr += 2;
SetGameVarID(i, sintable[(GetGameVarID(*insptr++, g_i, g_p)+512)&2047], g_i, g_p);
break; break;
}
case CON_ADDVARVAR: case CON_ADDVARVAR:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; SetGameVarID(j, GetGameVarID(j, g_i, g_p) + GetGameVarID(*insptr++, g_i, g_p), g_i, g_p);
SetGameVarID(i, GetGameVarID(i, g_i, g_p) + GetGameVarID(*insptr++, g_i, g_p), g_i, g_p);
break; break;
}
case CON_SPGETLOTAG: case CON_SPGETLOTAG:
{
insptr++; insptr++;
SetGameVarID(g_iLoTagID, g_sp->lotag, g_i, g_p); SetGameVarID(g_iLoTagID, g_sp->lotag, g_i, g_p);
break; break;
}
case CON_SPGETHITAG: case CON_SPGETHITAG:
{
insptr++; insptr++;
SetGameVarID(g_iHiTagID, g_sp->hitag, g_i, g_p); SetGameVarID(g_iHiTagID, g_sp->hitag, g_i, g_p);
break; break;
}
case CON_SECTGETLOTAG: case CON_SECTGETLOTAG:
{
insptr++; insptr++;
SetGameVarID(g_iLoTagID, sector[g_sp->sectnum].lotag, g_i, g_p); SetGameVarID(g_iLoTagID, sector[g_sp->sectnum].lotag, g_i, g_p);
break; break;
}
case CON_SECTGETHITAG: case CON_SECTGETHITAG:
{
insptr++; insptr++;
SetGameVarID(g_iHiTagID, sector[g_sp->sectnum].hitag, g_i, g_p); SetGameVarID(g_iHiTagID, sector[g_sp->sectnum].hitag, g_i, g_p);
break; break;
}
case CON_GETTEXTUREFLOOR: case CON_GETTEXTUREFLOOR:
{
insptr++; insptr++;
SetGameVarID(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_i, g_p); SetGameVarID(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_i, g_p);
break; break;
}
case CON_STARTTRACK: case CON_STARTTRACK:
{
insptr++; insptr++;
music_select=*insptr++; music_select=*insptr++;
if (music_fn[ud.volume_number][(unsigned char)music_select] != NULL) if (music_fn[ud.volume_number][(unsigned char)music_select] != NULL)
playmusic(&music_fn[ud.volume_number][(unsigned char)music_select][0]); playmusic(&music_fn[ud.volume_number][(unsigned char)music_select][0]);
break; break;
}
case CON_GETTEXTURECEILING: case CON_GETTEXTURECEILING:
{
insptr++; insptr++;
SetGameVarID(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_i, g_p); SetGameVarID(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_i, g_p);
break; break;
}
case CON_IFVARVARAND: case CON_IFVARVARAND:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; parseifelse(GetGameVarID(j, g_i, g_p) & GetGameVarID(*(insptr), g_i, g_p));
j=0;
if (GetGameVarID(i, g_i, g_p) & GetGameVarID(*(insptr), g_i, g_p))
j=1;
parseifelse(j);
break; break;
}
case CON_IFVARVARN: case CON_IFVARVARN:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; parseifelse(GetGameVarID(j, g_i, g_p) != GetGameVarID(*(insptr), g_i, g_p));
j=0;
if (GetGameVarID(i, g_i, g_p) != GetGameVarID(*(insptr), g_i, g_p))
j=1;
parseifelse(j);
break; break;
}
case CON_IFVARVARE: case CON_IFVARVARE:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; parseifelse(GetGameVarID(j, g_i, g_p) == GetGameVarID(*(insptr), g_i, g_p));
j=0;
if (GetGameVarID(i, g_i, g_p) == GetGameVarID(*(insptr), g_i, g_p))
j=1;
parseifelse(j);
break; break;
}
case CON_IFVARVARG: case CON_IFVARVARG:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; parseifelse(GetGameVarID(j, g_i, g_p) > GetGameVarID(*(insptr), g_i, g_p));
j=0;
if (GetGameVarID(i, g_i, g_p) > GetGameVarID(*(insptr), g_i, g_p))
j=1;
parseifelse(j);
break; break;
}
case CON_IFVARVARL: case CON_IFVARVARL:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; parseifelse(GetGameVarID(j, g_i, g_p) < GetGameVarID(*(insptr), g_i, g_p));
j=0;
if (GetGameVarID(i, g_i, g_p) < GetGameVarID(*(insptr), g_i, g_p))
j=1;
parseifelse(j);
break; break;
}
case CON_IFVARE: case CON_IFVARE:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; parseifelse(GetGameVarID(j, g_i, g_p) == *insptr);
j=0;
if (GetGameVarID(i, g_i, g_p) == *insptr)
j=1;
parseifelse(j);
break; break;
}
case CON_IFVARN: case CON_IFVARN:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; parseifelse(GetGameVarID(j, g_i, g_p) != *insptr);
j=0;
if (GetGameVarID(i, g_i, g_p) != *insptr)
j=1;
parseifelse(j);
break; break;
}
case CON_WHILEVARN: case CON_WHILEVARN:
{ {
@ -6368,37 +6199,22 @@ good:
} }
case CON_IFVARAND: case CON_IFVARAND:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; parseifelse(GetGameVarID(j, g_i, g_p) & *insptr);
j=0;
if (GetGameVarID(i, g_i, g_p) & *insptr)
j=1;
parseifelse(j);
break; break;
}
case CON_IFVARG: case CON_IFVARG:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; parseifelse(GetGameVarID(j, g_i, g_p) > *insptr);
j=0;
if (GetGameVarID(i, g_i, g_p) > *insptr)
j=1;
parseifelse(j);
break; break;
}
case CON_IFVARL: case CON_IFVARL:
insptr++; insptr++;
{ j=*insptr++;
int i=*insptr++; parseifelse(GetGameVarID(j, g_i, g_p) < *insptr);
j=0;
if (GetGameVarID(i, g_i, g_p) < *insptr)
j=1;
parseifelse(j);
break; break;
}
case CON_IFPHEALTHL: case CON_IFPHEALTHL:
insptr++; insptr++;
@ -6462,13 +6278,12 @@ good:
if (ps[g_p].knee_incs == 0 && sprite[ps[g_p].i].xrepeat >= 40) if (ps[g_p].knee_incs == 0 && sprite[ps[g_p].i].xrepeat >= 40)
if (cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+(16<<8),sprite[ps[g_p].i].sectnum)) if (cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sectnum,ps[g_p].posx,ps[g_p].posy,ps[g_p].posz+(16<<8),sprite[ps[g_p].i].sectnum))
{ {
int i=0; for (j=0;j<MAXPLAYERS;j++)
for (;i<MAXPLAYERS;i++)
{ {
if (ps[i].actorsqu == g_i) if (ps[j].actorsqu == g_i)
break; break;
} }
if (i == MAXPLAYERS) if (j == MAXPLAYERS)
{ {
ps[g_p].knee_incs = 1; ps[g_p].knee_incs = 1;
if (ps[g_p].weapon_pos == 0) if (ps[g_p].weapon_pos == 0)
@ -6578,29 +6393,21 @@ good:
break; break;
case CON_SPRITEFLAGS: case CON_SPRITEFLAGS:
{
insptr++; insptr++;
actorspriteflags[g_i] = GetGameVarID(*insptr++, g_i, g_p); actorspriteflags[g_i] = GetGameVarID(*insptr++, g_i, g_p);
break; break;
}
case CON_GETCURRADDRESS: case CON_GETCURRADDRESS:
{
int i;
insptr++; insptr++;
j=*insptr++;
i=*insptr++; SetGameVarID(j, (long)insptr, g_i, g_p);
SetGameVarID(i, (long)insptr, g_i, g_p);
break; break;
}
case CON_JUMP: case CON_JUMP:
insptr++; insptr++;
{ j = GetGameVarID(*insptr++, g_i, g_p);
int ptr = GetGameVarID(*insptr++, g_i, g_p); insptr = (long *)j;
insptr = (long *)ptr;
break; break;
}
default: default:
OSD_Printf("fatal error: default processing: prev inst: %ld, curr inst: %ld, next inst: %ld\ncurrent actor: %d (%d)\n",*(insptr-1),*insptr,*(insptr+1),g_i,g_sp->picnum); OSD_Printf("fatal error: default processing: prev inst: %ld, curr inst: %ld, next inst: %ld\ncurrent actor: %d (%d)\n",*(insptr-1),*insptr,*(insptr+1),g_i,g_sp->picnum);

View file

@ -413,26 +413,26 @@ static int GetGameID(char *szGameLabel)
long GetGameVarID(int id, short sActor, short sPlayer) long GetGameVarID(int id, short sActor, short sPlayer)
{ {
int m=0; int inv=0;
if (id == g_iThisActorID)
return sActor;
if (id<0 || id >= iGameVarCount) if (id<0 || id >= iGameVarCount)
{ {
if (id==MAXGAMEVARS) if (id==MAXGAMEVARS)
return(*insptr++); return(*insptr++);
else if (id&(MAXGAMEVARS<<1))
{ if (!id&(MAXGAMEVARS<<1))
m=1;
id ^= (MAXGAMEVARS<<1);
}
else
{ {
AddLog("GetGameVarID: Invalid Game ID"); AddLog("GetGameVarID: Invalid Game ID");
return -1; return -1;
} }
inv=1;
id ^= (MAXGAMEVARS<<1);
} }
if (id == g_iThisActorID)
{
return sActor;
}
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER)
{ {
// for the current player // for the current player
@ -440,39 +440,35 @@ long GetGameVarID(int id, short sActor, short sPlayer)
{ {
//Bsprintf(g_szBuf,"GetGameVarID(%d, %d, %d) returns %ld\n",id,sActor,sPlayer, aGameVars[id].plValues[sPlayer]); //Bsprintf(g_szBuf,"GetGameVarID(%d, %d, %d) returns %ld\n",id,sActor,sPlayer, aGameVars[id].plValues[sPlayer]);
//AddLog(g_szBuf); //AddLog(g_szBuf);
if (m) return (-aGameVars[id].plValues[sPlayer]); if (inv) return (-aGameVars[id].plValues[sPlayer]);
return (aGameVars[id].plValues[sPlayer]); return (aGameVars[id].plValues[sPlayer]);
} }
else
{ if (inv) return (-aGameVars[id].lValue);
if (m) return (-aGameVars[id].lValue); return (aGameVars[id].lValue);
return (aGameVars[id].lValue);
}
} }
else if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR)
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR)
{ {
// for the current actor // for the current actor
if (sActor >= 0 && sActor <=MAXSPRITES) if (sActor >= 0 && sActor <=MAXSPRITES)
{ {
if (m) return (-aGameVars[id].plValues[sActor]); if (inv) return (-aGameVars[id].plValues[sActor]);
return (aGameVars[id].plValues[sActor]); return (aGameVars[id].plValues[sActor]);
} }
else
{ if (inv) return (-aGameVars[id].lValue);
if (m) return (-aGameVars[id].lValue);
return (aGameVars[id].lValue);
}
}
else if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG)
{
if (m) return -(*((long*)aGameVars[id].lValue));
return(*((long*)aGameVars[id].lValue));
}
else
{
if (m) return (-aGameVars[id].lValue);
return (aGameVars[id].lValue); return (aGameVars[id].lValue);
} }
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG)
{
if (inv) return -(*((long*)aGameVars[id].lValue));
return(*((long*)aGameVars[id].lValue));
}
if (inv) return (-aGameVars[id].lValue);
return (aGameVars[id].lValue);
} }
void SetGameVarID(int id, long lValue, short sActor, short sPlayer) void SetGameVarID(int id, long lValue, short sActor, short sPlayer)
@ -488,27 +484,30 @@ void SetGameVarID(int id, long lValue, short sActor, short sPlayer)
{ {
// for the current player // for the current player
aGameVars[id].plValues[sPlayer]=lValue; aGameVars[id].plValues[sPlayer]=lValue;
return;
} }
else if ((aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) && (sActor != -1))
if ((aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) && (sActor != -1))
{ {
// for the current actor // for the current actor
aGameVars[id].plValues[sActor]=lValue; aGameVars[id].plValues[sActor]=lValue;
return;
} }
else if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG)
if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG)
{ {
// set the value at pointer // set the value at pointer
*((long*)aGameVars[id].lValue)=lValue; *((long*)aGameVars[id].lValue)=lValue;
return;
} }
else
{ aGameVars[id].lValue=lValue;
aGameVars[id].lValue=lValue;
}
} }
long GetGameVar(char *szGameLabel, long lDefault, short sActor, short sPlayer) long GetGameVar(char *szGameLabel, long lDefault, short sActor, short sPlayer)
{ {
int i; int i=0;
for (i=0;i<iGameVarCount;i++) for (;i<iGameVarCount;i++)
{ {
if (aGameVars[i].szLabel != NULL) if (aGameVars[i].szLabel != NULL)
{ {