Add Cvar_RemoveAlias.

Now aliases can be deleted (needed for menus).
This commit is contained in:
Bill Currie 2011-07-05 21:59:47 +09:00
parent a7291943f7
commit 6114156b49
2 changed files with 21 additions and 4 deletions

View file

@ -84,6 +84,7 @@ cvar_t *Cvar_Get (const char *name, const char *value, int cvarflags,
cvar_t *Cvar_FindAlias (const char *alias_name);
cvar_t *Cvar_MakeAlias (const char *name, cvar_t *cvar);
cvar_t *Cvar_RemoveAlias (const char *name);
// equivelants to "<name> <variable>" typed at the console
void Cvar_Set (cvar_t *var, const char *value);

View file

@ -76,7 +76,7 @@ Cvar_FindAlias (const char *alias_name)
{
cvar_alias_t *alias;
alias = (cvar_alias_t*) Hash_Find (calias_hash, alias_name);
alias = (cvar_alias_t *) Hash_Find (calias_hash, alias_name);
if (alias)
return alias->cvar;
return 0;
@ -85,7 +85,7 @@ Cvar_FindAlias (const char *alias_name)
cvar_t *
Cvar_MakeAlias (const char *name, cvar_t *cvar)
{
cvar_alias_t *alias;
cvar_alias_t *alias;
cvar_t *var;
if (Cmd_Exists (name)) {
@ -115,6 +115,22 @@ Cvar_MakeAlias (const char *name, cvar_t *cvar)
return cvar;
}
cvar_t *
Cvar_RemoveAlias (const char *name)
{
cvar_alias_t *alias;
cvar_t *var;
alias = (cvar_alias_t *) Hash_Find (calias_hash, name);
if (!alias) {
Sys_Printf ("Cvar_RemoveAlias: %s is not an alias\n", name);
return 0;
}
var = alias->cvar;
Hash_Free (calias_hash, Hash_Del (calias_hash, name));
return var;
}
VISIBLE float
Cvar_VariableValue (const char *var_name)
{
@ -570,7 +586,7 @@ cvar_get_key (void *c, void *unused)
static void
calias_free (void *c, void *unused)
{
cvar_alias_t *calias = (cvar_alias_t*)c;
cvar_alias_t *calias = (cvar_alias_t *) c;
free (calias->name);
free (calias);
}
@ -578,7 +594,7 @@ calias_free (void *c, void *unused)
static const char *
calias_get_key (void *c, void *unused)
{
cvar_alias_t *calias = (cvar_alias_t*)c;
cvar_alias_t *calias = (cvar_alias_t *) c;
return calias->name;
}