//------------------------------------------------------------------------- /* Copyright (C) 2005 - EDuke32 team This file is part of EDuke32 EDuke32 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ //------------------------------------------------------------------------- #include "duke3d.h" #include "gamedef.h" static void FreeGameVars(void) { // call this function as many times as needed. int i; // AddLog("FreeGameVars"); for (i=0;i (MAXVARLABEL-1)) { error++; initprintf("%s:%ld: 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) return(*insptr++); else if (id&(MAXGAMEVARS<<1)) { m=1; id ^= (MAXGAMEVARS<<1); } else { AddLog("GetGameVarID: Invalid Game ID"); return -1; } } if (id == g_iThisActorID) { return sActor; } if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) { // for the current player if (sPlayer >=0 && sPlayer < MAXPLAYERS) { //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]); return (aGameVars[id].plValues[sPlayer]); } else { if (m) return (-aGameVars[id].lValue); return (aGameVars[id].lValue); } } else if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) { // for the current actor if (sActor >= 0 && sActor <=MAXSPRITES) { if (m) 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); return (aGameVars[id].lValue); } } void SetGameVarID(int id, long lValue, short sActor, short sPlayer) { if (id<0 || id >= iGameVarCount) { AddLog("Invalid Game ID"); return; } //Bsprintf(g_szBuf,"SGVI: %d ('%s') to %ld for %d %d",id,aGameVars[id].szLabel,lValue,sActor,sPlayer); //AddLog(g_szBuf); if ((aGameVars[id].dwFlags & GAMEVAR_FLAG_PERPLAYER) && (sPlayer != -1)) { // for the current player aGameVars[id].plValues[sPlayer]=lValue; } else if ((aGameVars[id].dwFlags & GAMEVAR_FLAG_PERACTOR) && (sActor != -1)) { // for the current actor aGameVars[id].plValues[sActor]=lValue; } else if (aGameVars[id].dwFlags & GAMEVAR_FLAG_PLONG) { // set the value at pointer *((long*)aGameVars[id].lValue)=lValue; } else { aGameVars[id].lValue=lValue; } } long GetGameVar(char *szGameLabel, long lDefault, short sActor, short sPlayer) { int i; for (i=0;i