cvars can use callbacks now. Use Cvar_ForceSet inside to undo the change.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2188 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2006-04-11 20:42:05 +00:00
parent 7d89845224
commit b12ead1a7d
2 changed files with 9 additions and 1 deletions

View file

@ -695,7 +695,11 @@ cvar_t *Cvar_SetCore (cvar_t *var, const char *value, qboolean force)
if (latch)
{
if (strcmp(latch, value))
{
var->modified++; //only modified if it changed.
if (var->callback)
var->callback(var, latch);
}
Z_Free (latch); // free the old value string
}

View file

@ -67,12 +67,16 @@ typedef struct cvar_s
//free style :)
char *name2;
void (*callback) (struct cvar_s *var, char *oldvalue);
char *defaultstr; //default
qbyte restriction;
} cvar_t;
#define FCVAR(ConsoleName,ConsoleName2,Value,Flags) {ConsoleName, Value, NULL, Flags, 0, 0, 0, ConsoleName2}
#define FCVARC(ConsoleName,ConsoleName2,Value,Flags,Callback) {ConsoleName, Value, NULL, Flags, 0, 0, 0, ConsoleName2, Callback}
#define FCVAR(ConsoleName,ConsoleName2,Value,Flags) FCVARC(ConsoleName, ConsoleName2, Value, Flags, NULL)
#define SCVARF(ConsoleName,Value, Flags) FCVAR(ConsoleName, NULL, Value, Flags)
#define SCVARC(ConsoleName,Value,Callback) FCVARC(ConsoleName, NULL, Value, 0, Callback)
#define SCVAR(ConsoleName,Value) FCVAR(ConsoleName, NULL, Value, 0)
typedef struct cvar_group_s