From 31775358e61cbf05040ec9a9539e2c925b6e9482 Mon Sep 17 00:00:00 2001 From: terminx Date: Mon, 18 Dec 2006 21:29:55 +0000 Subject: [PATCH] Death to local variables git-svn-id: https://svn.eduke32.com/eduke32@430 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/build/src/polymost.c | 6 +- polymer/eduke32/source/gameexec.c | 573 ++++++++++-------------------- polymer/eduke32/source/gamevars.c | 81 +++-- 3 files changed, 233 insertions(+), 427 deletions(-) diff --git a/polymer/build/src/polymost.c b/polymer/build/src/polymost.c index 35d5aaf73..52518198e 100644 --- a/polymer/build/src/polymost.c +++ b/polymer/build/src/polymost.c @@ -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 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 FOGSCALE 0.0000640 +#define FOGSCALE 0.0000680 #define PI 3.14159265358979323 -float shadescale = 1.250; +float shadescale = 1.050; static double gyxscale, gxyaspect, gviewxrange, ghalfx, grhalfxdown10, grhalfxdown10x, ghoriz; static double gcosang, gsinang, gcosang2, gsinang2; @@ -4990,7 +4990,7 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm) return OSDCMD_OK; } 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 { float fval = atof(parm->parms[0]); diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 0379b400c..af0efc670 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -3616,12 +3616,6 @@ static int parse(void) { 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(*it == 1668249134L) gameexit("\nERR"); @@ -3633,14 +3627,15 @@ static int parse(void) switch (tw) { case CON_REDEFINEQUOTE: + insptr++; { - int q, i; - insptr++; - q = *insptr++; - i = *insptr++; + int q = *insptr++, i = *insptr++; if (fta_quotes[q] == NULL || redefined_quotes[i] == NULL) + { 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; } @@ -4222,9 +4217,7 @@ SKIPJIBS: case CON_STATE: { - long *tempscrptr; - - tempscrptr = insptr+2; + long *tempscrptr=insptr+2; insptr = (long *) *(insptr+1); while (1) if (parse()) break; @@ -4273,12 +4266,9 @@ SKIPJIBS: case CON_OPERATEACTIVATORS: case CON_SETASPECT: case CON_SSP: + insptr++; { - long var1, var2; - - insptr++; - - var1 = GetGameVarID(*insptr++,g_i,g_p); + int var1 = GetGameVarID(*insptr++,g_i,g_p), var2; if (tw == CON_OPERATEACTIVATORS && *insptr == g_iThisActorID) { var2 = g_p; @@ -4308,16 +4298,11 @@ SKIPJIBS: } case CON_CANSEESPR: + insptr++; { - long lVar1, lVar2, lVar3; + int lVar1 = GetGameVarID(*insptr++,g_i,g_p), lVar2 = GetGameVarID(*insptr++,g_i,g_p); - insptr++; - - 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, + SetGameVarID(*insptr++, 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); break; } @@ -4325,11 +4310,9 @@ SKIPJIBS: case CON_OPERATERESPAWNS: case CON_OPERATEMASTERSWITCHES: case CON_CHECKACTIVATORMOTION: + insptr++; { - long var1; - - insptr++; - var1 = GetGameVarID(*insptr++,g_i,g_p); + int var1 = GetGameVarID(*insptr++,g_i,g_p); switch (tw) { @@ -4352,14 +4335,16 @@ SKIPJIBS: break; case CON_QSTRLEN: + insptr++; { - int i,j; - insptr++; - i=*insptr++; + int i=*insptr++; j=GetGameVarID(*insptr++, g_i, g_p); - if (fta_quotes[j] != NULL) - SetGameVarID(i,Bstrlen(fta_quotes[j]),g_i,g_p); - else SetGameVarID(i,-1,g_i,g_p); + if (fta_quotes[j] == NULL) + { + SetGameVarID(i,-1,g_i,g_p); + break; + } + SetGameVarID(i,Bstrlen(fta_quotes[j]),g_i,g_p); break; } @@ -4368,11 +4353,9 @@ SKIPJIBS: case CON_QSTRCPY: case CON_CHANGESPRITESTAT: case CON_CHANGESPRITESECT: + insptr++; { - int i,j; - insptr++; - - i = GetGameVarID(*insptr++, g_i, g_p); + int i = GetGameVarID(*insptr++, g_i, g_p), j; if (tw == CON_GETPNAME && *insptr == g_iThisActorID) { j = g_p; @@ -4412,39 +4395,16 @@ SKIPJIBS: } case CON_STARTLEVEL: + insptr++; // skip command { // from 'level' cheat in game.c (about line 6250) - long volnume; - long levnume; - int i; - - insptr++; // skip command - volnume=GetGameVarID(*insptr++,g_i,g_p); - levnume=GetGameVarID(*insptr++,g_i,g_p); + int volnume=GetGameVarID(*insptr++,g_i,g_p), levnume=GetGameVarID(*insptr++,g_i,g_p); 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; - } 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; - } ud.m_volume_number = ud.volume_number = volnume; ud.m_level_number = ud.level_number = levnume; @@ -4622,10 +4582,9 @@ SKIPJIBS: } case CON_INITTIMER: + insptr++; { - short i; - insptr++; - i = GetGameVarID(*insptr++, g_i, g_p); + int i = GetGameVarID(*insptr++, g_i, g_p); if (timer != i) { uninittimer(); @@ -4644,12 +4603,10 @@ SKIPJIBS: case CON_ESPAWNVAR: case CON_EQSPAWNVAR: 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) lReturn = spawn(g_i, lIn); switch (tw) @@ -4699,9 +4656,8 @@ SKIPJIBS: case CON_EZSHOOT: case CON_ZSHOOT: { - long lReturn=-1; - insptr++; + if (tw == CON_ZSHOOT || tw == CON_EZSHOOT) { 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) { - lReturn = shoot(g_i,*insptr++); 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++; @@ -4750,11 +4706,9 @@ SKIPJIBS: case CON_STOPSOUNDVAR: case CON_SOUNDONCEVAR: case CON_GLOBALSOUNDVAR: + insptr++; { - int sound; - - insptr++; - sound=GetGameVarID(*insptr++, g_i, g_p); + int sound=GetGameVarID(*insptr++, g_i, g_p); switch (tw) { @@ -4779,9 +4733,9 @@ SKIPJIBS: case CON_GUNIQHUDID: insptr++; { - int i=GetGameVarID(*insptr++, g_i, g_p); - if (i < MAXUNIQHUDID-1) - guniqhudid = i; + j=GetGameVarID(*insptr++, g_i, g_p); + if (j < MAXUNIQHUDID-1) + guniqhudid = j; break; } @@ -5495,13 +5449,12 @@ SKIPJIBS: } case CON_ADDLOGVAR: + insptr++; { - long l,m=1,lVarID; + int m=1; char szBuf[256]; - insptr++; - l=*insptr++; // l=Line number, *instpr=varID - - lVarID = *insptr; + long l=*insptr++, lVarID = *insptr; + if ((lVarID >= iGameVarCount) || lVarID < 0) { if (*insptr==MAXGAMEVARS) // addlogvar for a constant? Har. @@ -5732,6 +5685,7 @@ good: case CON_FINDPLAYER: case CON_FINDOTHERPLAYER: + insptr++; { // syntax findnearactorvar // gets the sprite ID of the nearest actor within max dist @@ -5739,10 +5693,7 @@ good: // -1 for none found // short j=0; - long var1, d; - - insptr++; - var1 = *insptr++; + long var1 = *insptr++, d; if (tw == CON_FINDPLAYER) j=findplayer(&sprite[g_i],&d); else if (tw == CON_FINDOTHERPLAYER) j=findotherplayer(g_i,&d); @@ -5890,18 +5841,10 @@ good: } case CON_GETANGLETOTARGET: - { - int i; - short ang; - - insptr++; - i=*insptr++; - + insptr++; // 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(i, ang, g_i, g_p); + SetGameVarID(*insptr++, getangle(hittype[g_i].lastvx-g_sp->x,hittype[g_i].lastvy-g_sp->y), g_i, g_p); break; - } case CON_ANGOFFVAR: insptr++; @@ -5915,22 +5858,19 @@ good: case CON_CHECKAVAILWEAPON: case CON_CHECKAVAILINVEN: - { - int i = g_p; - - insptr++; + insptr++; + j = g_p; 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) - checkavailweapon(&ps[i]); - else checkavailinven(&ps[i]); + checkavailweapon(&ps[j]); + else checkavailinven(&ps[j]); } break; - } case CON_GETPLAYERANGLE: insptr++; @@ -5955,378 +5895,269 @@ good: break; case CON_SETVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, *insptr++, g_i, g_p); + insptr++; + SetGameVarID(*insptr, *(insptr+1), g_i, g_p); + insptr += 2; break; - } case CON_SETVARVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + insptr++; + SetGameVarID(*insptr, GetGameVarID(*(insptr+1), g_i, g_p), g_i, g_p); + insptr += 2; break; - } case CON_RANDVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, mulscale(krand(), *(insptr++)+1, 16), g_i, g_p); + insptr++; + SetGameVarID(*insptr, mulscale(krand(), *(insptr+1)+1, 16), g_i, g_p); + insptr += 2; break; - } case CON_DISPLAYRANDVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, mulscale(rand(), *(insptr++)+1, 15), g_i, g_p); + insptr++; + SetGameVarID(*insptr, mulscale(rand(), *(insptr+1)+1, 15), g_i, g_p); + insptr += 2; break; - } case CON_MULVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, GetGameVarID(i, g_i, g_p) * *insptr++, g_i, g_p); + insptr++; + SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) * *(insptr+1), g_i, g_p); + insptr += 2; break; - } case CON_DIVVAR: - insptr++; - { - int i=*insptr++; - if ((*insptr) == 0) + insptr++; + if (*(insptr+1) == 0) 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; - } case CON_MODVAR: - insptr++; - { - int i=*insptr++; - if (*insptr == 0) + insptr++; + if (*(insptr+1) == 0) 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; - } case CON_ANDVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i,GetGameVarID(i, g_i, g_p) & *insptr++, g_i, g_p); + insptr++; + SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p) & *(insptr+1), g_i, g_p); + insptr += 2; break; - } case CON_ORVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i,GetGameVarID(i, g_i, g_p) | *insptr++, g_i, g_p); + insptr++; + SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p) | *(insptr+1), g_i, g_p); + insptr += 2; break; - } case CON_XORVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i,GetGameVarID(i, g_i, g_p) ^ *insptr++, g_i, g_p); + insptr++; + SetGameVarID(*insptr,GetGameVarID(*insptr, g_i, g_p) ^ *(insptr+1), g_i, g_p); + insptr += 2; break; - } case CON_RANDVARVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i,mulscale(krand(), GetGameVarID(*insptr++, g_i, g_p)+1, 16), g_i, g_p); + insptr++; + j=*insptr++; + SetGameVarID(j,mulscale(krand(), GetGameVarID(*insptr++, g_i, g_p)+1, 16), g_i, g_p); break; - } case CON_DISPLAYRANDVARVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i,mulscale(rand(), GetGameVarID(*insptr++, g_i, g_p)+1, 15), g_i, g_p); + insptr++; + j=*insptr++; + SetGameVarID(j,mulscale(rand(), GetGameVarID(*insptr++, g_i, g_p)+1, 15), g_i, g_p); break; - } case CON_GMAXAMMO: - insptr++; - { - int i=GetGameVarID(*insptr++, g_i, g_p); - SetGameVarID(*insptr++, max_ammo_amount[i], g_i, g_p); + insptr++; + j=GetGameVarID(*insptr++, g_i, g_p); + SetGameVarID(*insptr++, max_ammo_amount[j], g_i, g_p); break; - } case CON_SMAXAMMO: - insptr++; - { - int i=GetGameVarID(*insptr++, g_i, g_p); - max_ammo_amount[i]=GetGameVarID(*insptr++, g_i, g_p); + insptr++; + j=GetGameVarID(*insptr++, g_i, g_p); + max_ammo_amount[j]=GetGameVarID(*insptr++, g_i, g_p); break; - } case CON_MULVARVAR: - insptr++; - { - int i=*insptr++; - int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p); - - SetGameVarID(i, l1*l2, g_i, g_p); + insptr++; + j=*insptr++; + SetGameVarID(j, GetGameVarID(j, g_i, g_p)*GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); break; - } case CON_DIVVARVAR: - insptr++; - { - int i=*insptr++; - int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p); - - if (l2==0) - gameexit("CON_DIVVARVAR: Divide by zero."); + insptr++; + j=*insptr++; + { + int l2=GetGameVarID(*insptr++, g_i, g_p); - SetGameVarID(i, l1/l2 , g_i, g_p); - break; - } + if (l2==0) + gameexit("CON_DIVVARVAR: Divide by zero."); + + SetGameVarID(j, GetGameVarID(j, g_i, g_p)/l2 , g_i, g_p); + break; + } case CON_MODVARVAR: - insptr++; - { - int i=*insptr++; - int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p); - - if (l2==0) - gameexit("CON_MODVARVAR: Mod by zero."); + insptr++; + j=*insptr++; + { + int l2=GetGameVarID(*insptr++, g_i, g_p); - SetGameVarID(i, l1 % l2, g_i, g_p); - break; - } + if (l2==0) + gameexit("CON_MODVARVAR: Mod by zero."); + + SetGameVarID(j, GetGameVarID(j, g_i, g_p) % l2, g_i, g_p); + break; + } case CON_ANDVARVAR: - insptr++; - { - int i=*insptr++; - int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p); - - SetGameVarID(i, l1 & l2 , g_i, g_p); + insptr++; + j=*insptr++; + SetGameVarID(j, GetGameVarID(j, g_i, g_p) & GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); break; - } case CON_XORVARVAR: - insptr++; - { - int i=*insptr++; - int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p); - - SetGameVarID(i, l1 ^ l2 , g_i, g_p); + insptr++; + j=*insptr++; + SetGameVarID(j, GetGameVarID(j, g_i, g_p) ^ GetGameVarID(*insptr++, g_i, g_p) , g_i, g_p); break; - } case CON_ORVARVAR: - insptr++; - { - int i=*insptr++; - int l1=GetGameVarID(i, g_i, g_p), l2=GetGameVarID(*insptr++, g_i, g_p); - - SetGameVarID(i, l1 | l2 , g_i, g_p); + insptr++; + j=*insptr++; + SetGameVarID(j, GetGameVarID(j, g_i, g_p) | GetGameVarID(*insptr++, g_i, g_p) , g_i, g_p); break; - } case CON_SUBVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, GetGameVarID(i, g_i, g_p) - *insptr++, g_i, g_p); + insptr++; + SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) - *(insptr+1), g_i, g_p); + insptr += 2; break; - } case CON_SUBVARVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, GetGameVarID(i, g_i, g_p) - GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + insptr++; + j=*insptr++; + SetGameVarID(j, GetGameVarID(j, g_i, g_p) - GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); break; - } case CON_ADDVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, GetGameVarID(i, g_i, g_p) + *insptr++, g_i, g_p); + insptr++; + SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) + *(insptr+1), g_i, g_p); + insptr += 2; break; - } case CON_SHIFTVARL: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, GetGameVarID(i, g_i, g_p) << *insptr++, g_i, g_p); + insptr++; + SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) << *(insptr+1), g_i, g_p); + insptr += 2; break; - } case CON_SHIFTVARR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, GetGameVarID(i, g_i, g_p) >> *insptr++, g_i, g_p); + insptr++; + SetGameVarID(*insptr, GetGameVarID(*insptr, g_i, g_p) >> *(insptr+1), g_i, g_p); + insptr += 2; break; - } case CON_SIN: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, sintable[GetGameVarID(*insptr++, g_i, g_p)&2047], g_i, g_p); + insptr++; + SetGameVarID(*insptr, sintable[GetGameVarID(*(insptr+1), g_i, g_p)&2047], g_i, g_p); + insptr += 2; break; - } case CON_COS: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, sintable[(GetGameVarID(*insptr++, g_i, g_p)+512)&2047], g_i, g_p); + insptr++; + SetGameVarID(*insptr, sintable[(GetGameVarID(*(insptr+1), g_i, g_p)+512)&2047], g_i, g_p); + insptr += 2; break; - } case CON_ADDVARVAR: - insptr++; - { - int i=*insptr++; - SetGameVarID(i, GetGameVarID(i, g_i, g_p) + GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); + insptr++; + j=*insptr++; + SetGameVarID(j, GetGameVarID(j, g_i, g_p) + GetGameVarID(*insptr++, g_i, g_p), g_i, g_p); break; - } case CON_SPGETLOTAG: - { insptr++; SetGameVarID(g_iLoTagID, g_sp->lotag, g_i, g_p); break; - } case CON_SPGETHITAG: - { insptr++; SetGameVarID(g_iHiTagID, g_sp->hitag, g_i, g_p); break; - } case CON_SECTGETLOTAG: - { insptr++; SetGameVarID(g_iLoTagID, sector[g_sp->sectnum].lotag, g_i, g_p); break; - } case CON_SECTGETHITAG: - { insptr++; SetGameVarID(g_iHiTagID, sector[g_sp->sectnum].hitag, g_i, g_p); break; - } case CON_GETTEXTUREFLOOR: - { insptr++; SetGameVarID(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_i, g_p); break; - } case CON_STARTTRACK: - { insptr++; music_select=*insptr++; if (music_fn[ud.volume_number][(unsigned char)music_select] != NULL) playmusic(&music_fn[ud.volume_number][(unsigned char)music_select][0]); break; - } case CON_GETTEXTURECEILING: - { insptr++; SetGameVarID(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_i, g_p); break; - } case CON_IFVARVARAND: - insptr++; - { - int i=*insptr++; - j=0; - if (GetGameVarID(i, g_i, g_p) & GetGameVarID(*(insptr), g_i, g_p)) - j=1; - parseifelse(j); + insptr++; + j=*insptr++; + parseifelse(GetGameVarID(j, g_i, g_p) & GetGameVarID(*(insptr), g_i, g_p)); break; - } case CON_IFVARVARN: - insptr++; - { - int i=*insptr++; - j=0; - if (GetGameVarID(i, g_i, g_p) != GetGameVarID(*(insptr), g_i, g_p)) - j=1; - parseifelse(j); + insptr++; + j=*insptr++; + parseifelse(GetGameVarID(j, g_i, g_p) != GetGameVarID(*(insptr), g_i, g_p)); break; - } case CON_IFVARVARE: - insptr++; - { - int i=*insptr++; - j=0; - if (GetGameVarID(i, g_i, g_p) == GetGameVarID(*(insptr), g_i, g_p)) - j=1; - parseifelse(j); + insptr++; + j=*insptr++; + parseifelse(GetGameVarID(j, g_i, g_p) == GetGameVarID(*(insptr), g_i, g_p)); break; - } case CON_IFVARVARG: - insptr++; - { - int i=*insptr++; - j=0; - if (GetGameVarID(i, g_i, g_p) > GetGameVarID(*(insptr), g_i, g_p)) - j=1; - parseifelse(j); + insptr++; + j=*insptr++; + parseifelse(GetGameVarID(j, g_i, g_p) > GetGameVarID(*(insptr), g_i, g_p)); break; - } case CON_IFVARVARL: - insptr++; - { - int i=*insptr++; - j=0; - if (GetGameVarID(i, g_i, g_p) < GetGameVarID(*(insptr), g_i, g_p)) - j=1; - parseifelse(j); + insptr++; + j=*insptr++; + parseifelse(GetGameVarID(j, g_i, g_p) < GetGameVarID(*(insptr), g_i, g_p)); break; - } case CON_IFVARE: - insptr++; - { - int i=*insptr++; - j=0; - if (GetGameVarID(i, g_i, g_p) == *insptr) - j=1; - parseifelse(j); + insptr++; + j=*insptr++; + parseifelse(GetGameVarID(j, g_i, g_p) == *insptr); break; - } case CON_IFVARN: - insptr++; - { - int i=*insptr++; - j=0; - if (GetGameVarID(i, g_i, g_p) != *insptr) - j=1; - parseifelse(j); + insptr++; + j=*insptr++; + parseifelse(GetGameVarID(j, g_i, g_p) != *insptr); break; - } case CON_WHILEVARN: { @@ -6368,37 +6199,22 @@ good: } case CON_IFVARAND: - insptr++; - { - int i=*insptr++; - j=0; - if (GetGameVarID(i, g_i, g_p) & *insptr) - j=1; - parseifelse(j); + insptr++; + j=*insptr++; + parseifelse(GetGameVarID(j, g_i, g_p) & *insptr); break; - } case CON_IFVARG: - insptr++; - { - int i=*insptr++; - j=0; - if (GetGameVarID(i, g_i, g_p) > *insptr) - j=1; - parseifelse(j); + insptr++; + j=*insptr++; + parseifelse(GetGameVarID(j, g_i, g_p) > *insptr); break; - } case CON_IFVARL: - insptr++; - { - int i=*insptr++; - j=0; - if (GetGameVarID(i, g_i, g_p) < *insptr) - j=1; - parseifelse(j); + insptr++; + j=*insptr++; + parseifelse(GetGameVarID(j, g_i, g_p) < *insptr); break; - } case CON_IFPHEALTHL: insptr++; @@ -6462,13 +6278,12 @@ good: 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)) { - int i=0; - for (;ipicnum); diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index 1a72aa45b..43c931d41 100755 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -413,26 +413,26 @@ static int GetGameID(char *szGameLabel) 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==MAXGAMEVARS) return(*insptr++); - else if (id&(MAXGAMEVARS<<1)) - { - m=1; - id ^= (MAXGAMEVARS<<1); - } - else + + if (!id&(MAXGAMEVARS<<1)) { AddLog("GetGameVarID: Invalid Game ID"); return -1; } + + inv=1; + id ^= (MAXGAMEVARS<<1); } - if (id == g_iThisActorID) - { - return sActor; - } + if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) { // 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]); //AddLog(g_szBuf); - if (m) return (-aGameVars[id].plValues[sPlayer]); + if (inv) return (-aGameVars[id].plValues[sPlayer]); return (aGameVars[id].plValues[sPlayer]); } - else - { - if (m) return (-aGameVars[id].lValue); - return (aGameVars[id].lValue); - } + + if (inv) 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 if (sActor >= 0 && sActor <=MAXSPRITES) { - if (m) return (-aGameVars[id].plValues[sActor]); + if (inv) return (-aGameVars[id].plValues[sActor]); return (aGameVars[id].plValues[sActor]); } - else - { - 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); + + if (inv) 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) @@ -488,27 +484,30 @@ void SetGameVarID(int id, long lValue, short sActor, short sPlayer) { // for the current player 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 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 *((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) { - int i; - for (i=0;i