git-svn-id: https://svn.eduke32.com/eduke32@1035 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-08-26 09:05:32 +00:00
parent f0032888fe
commit f814485606

View file

@ -486,32 +486,35 @@ int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags)
if (i == -1) if (i == -1)
i = iGameVarCount; i = iGameVarCount;
if (i < MAXGAMEVARS) if (i >= MAXGAMEVARS)
{ {
// Set values error++;
if (aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM) ReportError(-1);
{ initprintf("%s:%d: error: too many gamevars!\n",compilefile,line_number);
//if(b) return 0;
//{
//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
// Set values
if ((aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM) == 0)
{ {
if (aGameVars[i].szLabel == NULL) if (aGameVars[i].szLabel == NULL)
aGameVars[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(char)); aGameVars[i].szLabel=Bcalloc(MAXVARLABEL,sizeof(char));
if (aGameVars[i].szLabel != pszLabel) if (aGameVars[i].szLabel != pszLabel)
Bstrcpy(aGameVars[i].szLabel,pszLabel); Bstrcpy(aGameVars[i].szLabel,pszLabel);
aGameVars[i].dwFlags=dwFlags; aGameVars[i].dwFlags=dwFlags;
if (aGameVars[i].plValues)
{
// only free if not system
Bfree(aGameVars[i].plValues);
aGameVars[i].plValues=NULL;
}
}
// if existing is system, they only get to change default value....
aGameVars[i].lValue=lValue; aGameVars[i].lValue=lValue;
aGameVars[i].lDefault=lValue; aGameVars[i].lDefault=lValue;
aGameVars[i].bReset=0; aGameVars[i].bReset=0;
}
if (i==iGameVarCount) if (i==iGameVarCount)
{ {
@ -519,34 +522,23 @@ int AddGameVar(const char *pszLabel, int lValue, unsigned int dwFlags)
HASH_replace(&gamevarH,aGameVars[i].szLabel,i); HASH_replace(&gamevarH,aGameVars[i].szLabel,i);
iGameVarCount++; iGameVarCount++;
} }
if (aGameVars[i].plValues && !(aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM))
{
// only free if not system
Bfree(aGameVars[i].plValues);
aGameVars[i].plValues=NULL;
}
if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERPLAYER) if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERPLAYER)
{ {
if (!aGameVars[i].plValues) if (!aGameVars[i].plValues)
aGameVars[i].plValues=Bcalloc(MAXPLAYERS,sizeof(intptr_t)); aGameVars[i].plValues=Bcalloc(MAXPLAYERS,sizeof(intptr_t));
for (j=0;j<MAXPLAYERS;j++) for (j=MAXPLAYERS-1;j>=0;j--)
aGameVars[i].plValues[j]=lValue; aGameVars[i].plValues[j]=lValue;
} }
else if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR) else if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR)
{ {
if (!aGameVars[i].plValues) if (!aGameVars[i].plValues)
aGameVars[i].plValues=Bcalloc(MAXSPRITES,sizeof(intptr_t)); aGameVars[i].plValues=Bcalloc(MAXSPRITES,sizeof(intptr_t));
for (j=0;j<MAXSPRITES;j++) for (j=MAXSPRITES-1;j>=0;j--)
aGameVars[i].plValues[j]=lValue; aGameVars[i].plValues[j]=lValue;
} }
return 1; return 1;
} }
else
{
// no room to add...
return 0;
}
}
void ResetActorGameVars(int iActor) void ResetActorGameVars(int iActor)
{ {
@ -746,9 +738,9 @@ void ResetSystemDefaults(void)
//AddLog("ResetWeaponDefaults"); //AddLog("ResetWeaponDefaults");
for (j=0;j<MAXPLAYERS;j++) for (j=MAXPLAYERS-1;j>=0;j--)
{ {
for (i=0;i<MAX_WEAPONS;i++) for (i=MAX_WEAPONS-1;i>=0;i--)
{ {
Bsprintf(aszBuf,"WEAPON%d_CLIP",i); Bsprintf(aszBuf,"WEAPON%d_CLIP",i);
aplWeaponClip[i][j]=GetGameVar(aszBuf,0, -1, j); aplWeaponClip[i][j]=GetGameVar(aszBuf,0, -1, j);