if (Cmd_Argc(cmd) == 1)
{
Con_Print("Current alias commands:\n");
- for (a = cmd->alias ; a ; a=a->next)
+ for (a = cmd->userdefined->alias ; a ; a=a->next)
Con_Printf("%s : %s", a->name, a->value);
return;
}
}
// if the alias already exists, reuse it
- for (a = cmd->alias ; a ; a=a->next)
+ for (a = cmd->userdefined->alias ; a ; a=a->next)
{
if (!strcmp(s, a->name))
{
a = (cmdalias_t *)Z_Malloc (sizeof(cmdalias_t));
strlcpy (a->name, s, sizeof (a->name));
// insert it at the right alphanumeric position
- for( prev = NULL, current = cmd->alias ; current && strcmp( current->name, a->name ) < 0 ; prev = current, current = current->next )
+ for( prev = NULL, current = cmd->userdefined->alias ; current && strcmp( current->name, a->name ) < 0 ; prev = current, current = current->next )
;
if( prev ) {
prev->next = a;
} else {
- cmd->alias = a;
+ cmd->userdefined->alias = a;
}
a->next = current;
}
{
s = Cmd_Argv(cmd, i);
p = NULL;
- for(a = cmd->alias; a; p = a, a = a->next)
+ for(a = cmd->userdefined->alias; a; p = a, a = a->next)
{
if(!strcmp(s, a->name))
{
if (a->initstate) // we can not remove init aliases
continue;
- if(a == cmd->alias)
- cmd->alias = a->next;
+ if(a == cmd->userdefined->alias)
+ cmd->userdefined->alias = a->next;
if(p)
p->next = a->next;
Z_Free(a->value);
}
count = 0;
- for (func = cmd->functions; func; func = func->next)
+ for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ {
+ if (partial && (ispattern ? !matchpattern_with_separator(func->name, partial, false, "", false) : strncmp(partial, func->name, len)))
+ continue;
+ Con_Printf("%s : %s\n", func->name, func->description);
+ count++;
+ }
+ for (func = cmd->engine_functions; func; func = func->next)
{
if (partial && (ispattern ? !matchpattern_with_separator(func->name, partial, false, "", false) : strncmp(partial, func->name, len)))
continue;
Con_Printf ("cvar ^3%s^7 is \"%s\" [\"%s\"] %s\n", cvar->name, cvar->string, cvar->defstring, cvar->description);
count++;
}
- for (func = cmd->functions; func; func = func->next)
+ for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ {
+ if (!matchpattern_with_separator(func->name, partial, true, "", false))
+ if (!matchpattern_with_separator(func->description, partial, true, "", false))
+ continue;
+ Con_Printf("command ^2%s^7: %s\n", func->name, func->description);
+ count++;
+ }
+ for (func = cmd->engine_functions; func; func = func->next)
{
if (!matchpattern_with_separator(func->name, partial, true, "", false))
if (!matchpattern_with_separator(func->description, partial, true, "", false))
Con_Printf("command ^2%s^7: %s\n", func->name, func->description);
count++;
}
- for (alias = cmd->alias; alias; alias = alias->next)
+ for (alias = cmd->userdefined->alias; alias; alias = alias->next)
{
// procede here a bit differently as an alias value always got a final \n
if (!matchpattern_with_separator(alias->name, partial, true, "", false))
// client console can see server cvars because the user may start a server
cmd_client.cvars = &cvars_all;
cmd_client.cvars_flagsmask = CVAR_CLIENT | CVAR_SERVER;
+ cmd_client.userdefined = &cmd_userdefined_all;
// stuffcmd from server has access to the reasonable client things, but it probably doesn't need to access the client's server-only cvars
cmd_clientfromserver.cvars = &cvars_all;
cmd_clientfromserver.cvars_flagsmask = CVAR_CLIENT;
+ cmd_clientfromserver.userdefined = &cmd_userdefined_all;
// dedicated server console can only see server cvars, there is no client
cmd_server.cvars = &cvars_all;
cmd_server.cvars_flagsmask = CVAR_SERVER;
+ cmd_server.userdefined = &cmd_userdefined_all;
// server commands received from clients have no reason to access cvars, cvar expansion seems perilous.
cmd_serverfromclient.cvars = &cvars_null;
cmd_serverfromclient.cvars_flagsmask = 0;
+ cmd_serverfromclient.userdefined = &cmd_userdefined_null;
}
void Cmd_Init_Commands(qboolean dedicated_server)
return;
}
- // fail if the command already exists in this interpreter
- for (func = cmd->functions; func; func = func->next)
- if (!strcmp(cmd_name, func->name))
- break;
-
- if (func)
+ if (function)
{
- // command already defined...
- if (function)
- Con_Printf("Cmd_AddCommand: %s already defined\n", cmd_name);
- else //[515]: csqc
- func->csqcfunc = true;
+ // fail if the command already exists in this interpreter
+ for (func = cmd->engine_functions; func; func = func->next)
+ {
+ if (!strcmp(cmd_name, func->name))
+ {
+ Con_Printf("Cmd_AddCommand: %s already defined\n", cmd_name);
+ return;
+ }
+ }
+
+ func = (cmd_function_t *)Mem_Alloc(cmd->mempool, sizeof(cmd_function_t));
+ func->name = cmd_name;
+ func->function = function;
+ func->description = description;
+ func->next = cmd->engine_functions;
+
+ // insert it at the right alphanumeric position
+ for (prev = NULL, current = cmd->engine_functions; current && strcmp(current->name, func->name) < 0; prev = current, current = current->next)
+ ;
+ if (prev) {
+ prev->next = func;
+ }
+ else {
+ cmd->engine_functions = func;
+ }
+ func->next = current;
}
else
{
+ // mark csqcfunc if the function already exists in the csqc_functions list
+ for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ {
+ if (!strcmp(cmd_name, func->name))
+ {
+ func->csqcfunc = true; //[515]: csqc
+ return;
+ }
+ }
+
+
func = (cmd_function_t *)Mem_Alloc(cmd->mempool, sizeof(cmd_function_t));
func->name = cmd_name;
func->function = function;
func->description = description;
- if (!function) //[515]: csqc
- func->csqcfunc = true;
- func->next = cmd->functions;
+ func->csqcfunc = true; //[515]: csqc
+ func->next = cmd->userdefined->csqc_functions;
// insert it at the right alphanumeric position
- for (prev = NULL, current = cmd->functions; current && strcmp(current->name, func->name) < 0; prev = current, current = current->next)
+ for (prev = NULL, current = cmd->userdefined->csqc_functions; current && strcmp(current->name, func->name) < 0; prev = current, current = current->next)
;
if (prev) {
prev->next = func;
}
else {
- cmd->functions = func;
+ cmd->userdefined->csqc_functions = func;
}
func->next = current;
}
{
cmd_function_t *func;
- for (func=cmd->functions ; func ; func=func->next)
+ for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ if (!strcmp(cmd_name, func->name))
+ return true;
+
+ for (func=cmd->engine_functions ; func ; func=func->next)
if (!strcmp (cmd_name,func->name))
return true;
return NULL;
// check functions
- for (func = cmd->functions; func; func = func->next)
+ for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ if (!strncasecmp(partial, func->name, len))
+ return func->name;
+
+ for (func = cmd->engine_functions; func; func = func->next)
if (!strncasecmp(partial, func->name, len))
return func->name;
return 0;
// Loop through the command list and count all partial matches
- for (func = cmd->functions; func; func = func->next)
+ for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ if (!strncasecmp(partial, func->name, len))
+ h++;
+
+ for (func = cmd->engine_functions; func; func = func->next)
if (!strncasecmp(partial, func->name, len))
h++;
len = strlen(partial);
buf = (const char **)Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *));
- // Loop through the alias list and print all matches
- for (func = cmd->functions; func; func = func->next)
+ // Loop through the functions lists and print all matches
+ for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ if (!strncasecmp(partial, func->name, len))
+ buf[bpos++] = func->name;
+ for (func = cmd->engine_functions; func; func = func->next)
if (!strncasecmp(partial, func->name, len))
buf[bpos++] = func->name;
cmd_function_t *func;
size_t len = strlen(partial);
// Loop through the command list and print all matches
- for (func = cmd->functions; func; func = func->next)
+ for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ if (!strncasecmp(partial, func->name, len))
+ Con_Printf("^2%s^7: %s\n", func->name, func->description);
+ for (func = cmd->engine_functions; func; func = func->next)
if (!strncasecmp(partial, func->name, len))
Con_Printf("^2%s^7: %s\n", func->name, func->description);
}
return NULL;
// Check functions
- for (alias = cmd->alias; alias; alias = alias->next)
+ for (alias = cmd->userdefined->alias; alias; alias = alias->next)
if (!strncasecmp(partial, alias->name, len))
return alias->name;
cmdalias_t *alias;
size_t len = strlen(partial);
// Loop through the alias list and print all matches
- for (alias = cmd->alias; alias; alias = alias->next)
+ for (alias = cmd->userdefined->alias; alias; alias = alias->next)
if (!strncasecmp(partial, alias->name, len))
Con_Printf("^5%s^7: %s", alias->name, alias->value);
}
return 0;
// Loop through the command list and count all partial matches
- for (alias = cmd->alias; alias; alias = alias->next)
+ for (alias = cmd->userdefined->alias; alias; alias = alias->next)
if (!strncasecmp(partial, alias->name, len))
h++;
len = strlen(partial);
buf = (const char **)Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *));
// Loop through the alias list and print all matches
- for (alias = cmd->alias; alias; alias = alias->next)
+ for (alias = cmd->userdefined->alias; alias; alias = alias->next)
if (!strncasecmp(partial, alias->name, len))
buf[bpos++] = alias->name;
void Cmd_ClearCsqcFuncs (cmd_state_t *cmd)
{
cmd_function_t *func;
- for (func = cmd->functions; func; func = func->next)
+ for (func = cmd->userdefined->csqc_functions; func; func = func->next)
func->csqcfunc = false;
}
goto done; // no tokens
// check functions
- for (func = cmd->functions; func; func=func->next)
+ for (func = cmd->userdefined->csqc_functions; func; func = func->next)
{
- if (!strcasecmp (cmd->argv[0], func->name))
+ if (!strcasecmp(cmd->argv[0], func->name))
{
- if (func->csqcfunc && CL_VM_ConsoleCommand (text)) //[515]: csqc
+ if (func->csqcfunc && CL_VM_ConsoleCommand(text)) //[515]: csqc
goto done;
+ break;
+ }
+ }
+
+ for (func = cmd->engine_functions; func; func=func->next)
+ {
+ if (!strcasecmp (cmd->argv[0], func->name))
+ {
switch (src)
{
case src_command:
}
// check alias
- for (a=cmd->alias ; a ; a=a->next)
+ for (a=cmd->userdefined->alias ; a ; a=a->next)
{
if (!strcasecmp (cmd->argv[0], a->name))
{
cmd_state_t *cmd = cmd_iter->cmd;
cmd_function_t *f;
cmdalias_t *a;
- for (f = cmd->functions; f; f = f->next)
+ for (f = cmd->userdefined->csqc_functions; f; f = f->next)
+ f->initstate = true;
+ for (f = cmd->engine_functions; f; f = f->next)
f->initstate = true;
- for (a = cmd->alias; a; a = a->next)
+ for (a = cmd->userdefined->alias; a; a = a->next)
{
a->initstate = true;
a->initialvalue = Mem_strdup(zonemempool, a->value);
cmd_state_t *cmd = cmd_iter->cmd;
cmd_function_t *f, **fp;
cmdalias_t *a, **ap;
- for (fp = &cmd->functions; (f = *fp);)
+ for (fp = &cmd->userdefined->csqc_functions; (f = *fp);)
+ {
+ if (f->initstate)
+ fp = &f->next;
+ else
+ {
+ // destroy this command, it didn't exist at init
+ Con_DPrintf("Cmd_RestoreInitState: Destroying command %s\n", f->name);
+ *fp = f->next;
+ Z_Free(f);
+ }
+ }
+ for (fp = &cmd->engine_functions; (f = *fp);)
{
if (f->initstate)
fp = &f->next;
Z_Free(f);
}
}
- for (ap = &cmd->alias; (a = *ap);)
+ for (ap = &cmd->userdefined->alias; (a = *ap);)
{
if (a->initstate)
{