mirror of
https://git.code.sf.net/p/quake/newtree
synced 2025-01-23 00:10:50 +00:00
cvars and commands are now ALWAYS sorted. This way, cmdlist and cvarlist are
more usable. Downside is tab completion is affected.
This commit is contained in:
parent
86a7e3b749
commit
50ce499a61
2 changed files with 31 additions and 22 deletions
|
@ -618,6 +618,7 @@ void
|
||||||
Cmd_AddCommand (char *cmd_name, xcommand_t function, char *description)
|
Cmd_AddCommand (char *cmd_name, xcommand_t function, char *description)
|
||||||
{
|
{
|
||||||
cmd_function_t *cmd;
|
cmd_function_t *cmd;
|
||||||
|
cmd_function_t **c;
|
||||||
|
|
||||||
if (host_initialized) // because hunk allocation would get
|
if (host_initialized) // because hunk allocation would get
|
||||||
// stomped
|
// stomped
|
||||||
|
@ -639,9 +640,12 @@ Cmd_AddCommand (char *cmd_name, xcommand_t function, char *description)
|
||||||
cmd->name = cmd_name;
|
cmd->name = cmd_name;
|
||||||
cmd->function = function;
|
cmd->function = function;
|
||||||
cmd->description = description;
|
cmd->description = description;
|
||||||
cmd->next = cmd_functions;
|
|
||||||
cmd_functions = cmd;
|
|
||||||
Hash_Add (cmd_hash, cmd);
|
Hash_Add (cmd_hash, cmd);
|
||||||
|
for (c = &cmd_functions; *c; c = &(*c)->next)
|
||||||
|
if (strcmp ((*c)->name, cmd->name) >=0)
|
||||||
|
break;
|
||||||
|
cmd->next = *c;
|
||||||
|
*c = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -509,37 +509,42 @@ cvar_t *
|
||||||
Cvar_Get (char *name, char *string, int cvarflags, char *description)
|
Cvar_Get (char *name, char *string, int cvarflags, char *description)
|
||||||
{
|
{
|
||||||
|
|
||||||
cvar_t *v;
|
cvar_t *var;
|
||||||
|
|
||||||
if (Cmd_Exists (name)) {
|
if (Cmd_Exists (name)) {
|
||||||
Con_Printf ("Cvar_Get: %s is a command\n", name);
|
Con_Printf ("Cvar_Get: %s is a command\n", name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
v = Cvar_FindVar (name);
|
var = Cvar_FindVar (name);
|
||||||
if (!v) {
|
if (!var) {
|
||||||
v = (cvar_t *) calloc (1, sizeof (cvar_t));
|
cvar_t **v;
|
||||||
|
var = (cvar_t *) calloc (1, sizeof (cvar_t));
|
||||||
|
|
||||||
// Cvar doesn't exist, so we create it
|
// Cvar doesn't exist, so we create it
|
||||||
v->next = cvar_vars;
|
var->name = strdup (name);
|
||||||
cvar_vars = v;
|
var->string = strdup (string);
|
||||||
v->name = strdup (name);
|
var->flags = cvarflags;
|
||||||
v->string = strdup (string);
|
var->description = description;
|
||||||
v->flags = cvarflags;
|
var->value = atof (var->string);
|
||||||
v->description = description;
|
var->int_val = atoi (var->string);
|
||||||
v->value = atof (v->string);
|
sscanf (var->string, "%f %f %f",
|
||||||
v->int_val = atoi (v->string);
|
&var->vec[0], &var->vec[1], &var->vec[2]);
|
||||||
sscanf (v->string, "%f %f %f",
|
Hash_Add (cvar_hash, var);
|
||||||
&v->vec[0], &v->vec[1], &v->vec[2]);
|
|
||||||
Hash_Add (cvar_hash, v);
|
for (v = &cvar_vars; *v; v = &(*v)->next)
|
||||||
|
if (strcmp ((*v)->name, var->name) >= 0)
|
||||||
|
break;
|
||||||
|
var->next = *v;
|
||||||
|
*v = var;
|
||||||
} else {
|
} else {
|
||||||
// Cvar does exist, so we update the flags and return.
|
// Cvar does exist, so we update the flags and return.
|
||||||
v->flags &= ~CVAR_USER_CREATED;
|
var->flags &= ~CVAR_USER_CREATED;
|
||||||
v->flags |= cvarflags;
|
var->flags |= cvarflags;
|
||||||
v->description = description;
|
var->description = description;
|
||||||
}
|
}
|
||||||
Cvar_Info (v);
|
Cvar_Info (var);
|
||||||
|
|
||||||
return v;
|
return var;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue