From f814485606f3350bbca52498e3c2a5bc1401fd75 Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 26 Aug 2008 09:05:32 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@1035 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/gamevars.c | 96 ++++++++++++++----------------- 1 file changed, 44 insertions(+), 52 deletions(-) diff --git a/polymer/eduke32/source/gamevars.c b/polymer/eduke32/source/gamevars.c index aa27d39ce..6c91fc073 100644 --- a/polymer/eduke32/source/gamevars.c +++ b/polymer/eduke32/source/gamevars.c @@ -486,66 +486,58 @@ int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags) if (i == -1) i = iGameVarCount; - if (i < MAXGAMEVARS) + if (i >= MAXGAMEVARS) { - // Set values - if (aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM) - { - //if(b) - //{ - //Bsprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); - //AddLog(g_szBuf); - //} - // if existing is system, they only get to change default value.... - aGameVars[i].lValue=lValue; - aGameVars[i].lDefault=lValue; - aGameVars[i].bReset=0; - } - else - { - if (aGameVars[i].szLabel == NULL) - aGameVars[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(char)); - if (aGameVars[i].szLabel != pszLabel) - Bstrcpy(aGameVars[i].szLabel,pszLabel); - aGameVars[i].dwFlags=dwFlags; - aGameVars[i].lValue=lValue; - aGameVars[i].lDefault=lValue; - aGameVars[i].bReset=0; - } + error++; + ReportError(-1); + initprintf("%s:%d: error: too many gamevars!\n",compilefile,line_number); + return 0; + } - if (i==iGameVarCount) - { - // we're adding a new one. - HASH_replace(&gamevarH,aGameVars[i].szLabel,i); - iGameVarCount++; - } - if (aGameVars[i].plValues && !(aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM)) + // Set values + if ((aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM) == 0) + { + if (aGameVars[i].szLabel == NULL) + aGameVars[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(char)); + if (aGameVars[i].szLabel != pszLabel) + Bstrcpy(aGameVars[i].szLabel,pszLabel); + aGameVars[i].dwFlags=dwFlags; + + if (aGameVars[i].plValues) { // only free if not system Bfree(aGameVars[i].plValues); aGameVars[i].plValues=NULL; } - if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERPLAYER) - { - if (!aGameVars[i].plValues) - aGameVars[i].plValues=Bcalloc(MAXPLAYERS,sizeof(intptr_t)); - for (j=0;j=0;j--) + aGameVars[i].plValues[j]=lValue; + } + else if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR) + { + if (!aGameVars[i].plValues) + aGameVars[i].plValues=Bcalloc(MAXSPRITES,sizeof(intptr_t)); + for (j=MAXSPRITES-1;j>=0;j--) + aGameVars[i].plValues[j]=lValue; + } + return 1; } void ResetActorGameVars(int iActor) @@ -746,9 +738,9 @@ void ResetSystemDefaults(void) //AddLog("ResetWeaponDefaults"); - for (j=0;j=0;j--) { - for (i=0;i=0;i--) { Bsprintf(aszBuf,"WEAPON%d_CLIP",i); aplWeaponClip[i][j]=GetGameVar(aszBuf,0, -1, j);