diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index cd67cfd09..0da09c221 100755 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -32,1441 +32,1441 @@ static void ResetPointerVars(void); static void FreeGameVars(void) /* called from ReadGameVars() and ResetGameVars() */ { - // call this function as many times as needed. - int i; - // AddLog("FreeGameVars"); - for (i=0;i (MAXARRAYLABEL-1)) - { - error++; - ReportError(-1); - initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",compilefile,line_number,pszLabel, MAXARRAYLABEL); - return 0; - } - for (i=0;i (MAXARRAYLABEL-1)) + { + error++; + ReportError(-1); + initprintf("%s:%d: error: array name `%s' exceeds limit of %d characters.\n",compilefile,line_number,pszLabel, MAXARRAYLABEL); + return 0; + } + for (i=0;i (MAXVARLABEL-1)) - { - error++; - ReportError(-1); - initprintf("%s:%d: error: variable name `%s' exceeds limit of %d characters.\n",compilefile,line_number,pszLabel, MAXVARLABEL); - return 0; - } - for (i=0;i (MAXVARLABEL-1)) + { + error++; + ReportError(-1); + initprintf("%s:%d: error: variable name `%s' exceeds limit of %d characters.\n",compilefile,line_number,pszLabel, MAXVARLABEL); + return 0; + } + for (i=0;i= iGameVarCount) - { -// if (id < (MAXGAMEVARS<<1)+MAXGAMEVARS+1+MAXGAMEARRAYS) - if (id&(MAXGAMEVARS<<2)) - { - int index=GetGameVarID(*insptr++,iActor,iPlayer); + if (id<0 || id >= iGameVarCount) + { +// if (id < (MAXGAMEVARS<<1)+MAXGAMEVARS+1+MAXGAMEARRAYS) + if (id&(MAXGAMEVARS<<2)) + { + int index=GetGameVarID(*insptr++,iActor,iPlayer); - id ^= (MAXGAMEVARS<<2); + id ^= (MAXGAMEVARS<<2); - if (id&(MAXGAMEVARS<<1)) // negative array access - { - m = -1; - id ^= (MAXGAMEVARS<<1); - } + if (id&(MAXGAMEVARS<<1)) // negative array access + { + m = -1; + id ^= (MAXGAMEVARS<<1); + } -// OSD_Printf("GetGameVarID(): reading from array\n"); - if ((index < aGameArrays[id].size)&&(index>=0)) - return(m * aGameArrays[id].plValues[index]); - OSD_Printf("GetGameVarID(): invalid array index (%s[%d])\n",aGameArrays[id].szLabel,index); - return -1; - } +// OSD_Printf("GetGameVarID(): reading from array\n"); + if ((index < aGameArrays[id].size)&&(index>=0)) + return(m * 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); - return -1; - } + if (!(id&(MAXGAMEVARS<<1))) + { + OSD_Printf("GetGameVarID(): invalid gamevar ID (%d)\n",id); + return -1; + } - m = -1; - id ^= (MAXGAMEVARS<<1); - } + m = -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]); - } + 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].lValue); - } + return(m * aGameVars[id].lValue); + } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) - { - // for the current actor - if (iActor >= 0 && iActor <= MAXSPRITES) - { - return(m * aGameVars[id].plValues[iActor]); - } + if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) + { + // for the current actor + if (iActor >= 0 && iActor <= MAXSPRITES) + { + return(m * aGameVars[id].plValues[iActor]); + } - 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_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_SHORTPTR) + { + return(m * (*((short*)aGameVars[id].lValue))); + } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_CHARPTR) - { - return(m * (*((char*)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); } void SetGameArrayID(int id,int index, int lValue) { - if (id<0 || id >= iGameArrayCount || !((index < aGameArrays[id].size)&&(index>=0))) - { - OSD_Printf("SetGameVarID(): tried to set invalid array ID (%d) or index out of bounds from sprite %d (%d), player %d\n",id,g_i,sprite[g_i].picnum,g_p); - return; - } - aGameArrays[id].plValues[index]=lValue; + if (id<0 || id >= iGameArrayCount || !((index < aGameArrays[id].size)&&(index>=0))) + { + OSD_Printf("SetGameVarID(): tried to set invalid array ID (%d) or index out of bounds from sprite %d (%d), player %d\n",id,g_i,sprite[g_i].picnum,g_p); + return; + } + aGameArrays[id].plValues[index]=lValue; } void SetGameVarID(int id, int lValue, int iActor, int iPlayer) { - if (id<0 || id >= iGameVarCount) - { - OSD_Printf("SetGameVarID(): tried to set invalid gamevar ID (%d) from sprite %d (%d), player %d\n",id,g_i,sprite[g_i].picnum,g_p); - return; - } - //Bsprintf(g_szBuf,"SGVI: %d ('%s') to %d for %d %d",id,aGameVars[id].szLabel,lValue,iActor,iPlayer); - //AddLog(g_szBuf); - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) - { - if (iPlayer < 0 || iPlayer > MAXPLAYERS-1) - { - OSD_Printf("SetGameVarID(): invalid player (%d) for per-player gamevar %s from sprite %d (%d), player %d\n",iPlayer,aGameVars[id].szLabel,g_i,sprite[g_i].picnum,g_p); - return; - } - // for the current player - aGameVars[id].plValues[iPlayer]=lValue; - return; - } + if (id<0 || id >= iGameVarCount) + { + OSD_Printf("SetGameVarID(): tried to set invalid gamevar ID (%d) from sprite %d (%d), player %d\n",id,g_i,sprite[g_i].picnum,g_p); + return; + } + //Bsprintf(g_szBuf,"SGVI: %d ('%s') to %d for %d %d",id,aGameVars[id].szLabel,lValue,iActor,iPlayer); + //AddLog(g_szBuf); + if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) + { + if (iPlayer < 0 || iPlayer > MAXPLAYERS-1) + { + OSD_Printf("SetGameVarID(): invalid player (%d) for per-player gamevar %s from sprite %d (%d), player %d\n",iPlayer,aGameVars[id].szLabel,g_i,sprite[g_i].picnum,g_p); + return; + } + // for the current player + aGameVars[id].plValues[iPlayer]=lValue; + return; + } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) - { - if (iActor < 0 || iActor > MAXSPRITES-1) - { - OSD_Printf("SetGameVarID(): invalid sprite (%d) for per-actor gamevar %s from sprite %d (%d), player %d\n",iActor,aGameVars[id].szLabel,g_i,sprite[g_i].picnum,g_p); - return; - } - // for the current actor - aGameVars[id].plValues[iActor]=lValue; - return; - } + if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) + { + if (iActor < 0 || iActor > MAXSPRITES-1) + { + OSD_Printf("SetGameVarID(): invalid sprite (%d) for per-actor gamevar %s from sprite %d (%d), player %d\n",iActor,aGameVars[id].szLabel,g_i,sprite[g_i].picnum,g_p); + return; + } + // for the current actor + aGameVars[id].plValues[iActor]=lValue; + return; + } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_INTPTR) - { - // set the value at pointer - *((int*)aGameVars[id].lValue)=(int)lValue; - return; - } + if (aGameVars[id].dwFlags & GAMEVAR_FLAG_INTPTR) + { + // set the value at pointer + *((int*)aGameVars[id].lValue)=(int)lValue; + return; + } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_SHORTPTR) - { - // set the value at pointer - *((short*)aGameVars[id].lValue)=(short)lValue; - return; - } + if (aGameVars[id].dwFlags & GAMEVAR_FLAG_SHORTPTR) + { + // set the value at pointer + *((short*)aGameVars[id].lValue)=(short)lValue; + return; + } - if (aGameVars[id].dwFlags & GAMEVAR_FLAG_CHARPTR) - { - // set the value at pointer - *((char*)aGameVars[id].lValue)=(char)lValue; - return; - } + if (aGameVars[id].dwFlags & GAMEVAR_FLAG_CHARPTR) + { + // set the value at pointer + *((char*)aGameVars[id].lValue)=(char)lValue; + return; + } - aGameVars[id].lValue=lValue; + aGameVars[id].lValue=lValue; } int GetGameVar(const char *szGameLabel, int lDefault, int iActor, int iPlayer) { - int i=0; - for (;i