}
count = 0;
- for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ for (func = cmd->userdefined->qc_functions; func; func = func->next)
{
if (partial && (ispattern ? !matchpattern_with_separator(func->name, partial, false, "", false) : strncmp(partial, func->name, len)))
continue;
}
}
}
- for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ for (func = cmd->userdefined->qc_functions; func; func = func->next)
{
if (!matchpattern_with_separator(func->name, partial, true, "", false))
if (!matchpattern_with_separator(func->description, partial, true, "", false))
}
else
{
- // mark csqcfunc if the function already exists in the csqc_functions list
- for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ // mark qcfunc if the function already exists in the qc_functions list
+ for (func = cmd->userdefined->qc_functions; func; func = func->next)
{
if (!strcmp(cmd_name, func->name))
{
- func->csqcfunc = true; //[515]: csqc
+ func->qcfunc = true; //[515]: csqc
continue;
}
}
func->name = cmd_name;
func->function = function;
func->description = description;
- func->csqcfunc = true; //[515]: csqc
- func->next = cmd->userdefined->csqc_functions;
+ func->qcfunc = true; //[515]: csqc
+ func->next = cmd->userdefined->qc_functions;
func->autofunc = false;
// insert it at the right alphanumeric position
- for (prev = NULL, current = cmd->userdefined->csqc_functions; current && strcmp(current->name, func->name) < 0; prev = current, current = current->next)
+ for (prev = NULL, current = cmd->userdefined->qc_functions; current && strcmp(current->name, func->name) < 0; prev = current, current = current->next)
;
if (prev) {
prev->next = func;
}
else {
- cmd->userdefined->csqc_functions = func;
+ cmd->userdefined->qc_functions = func;
}
func->next = current;
}
{
cmd_function_t *func;
- for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ for (func = cmd->userdefined->qc_functions; func; func = func->next)
if (!strcmp(cmd_name, func->name))
return true;
return NULL;
// check functions
- for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ for (func = cmd->userdefined->qc_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->userdefined->csqc_functions; func; func = func->next)
+ for (func = cmd->userdefined->qc_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 functions lists and print all matches
- for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ for (func = cmd->userdefined->qc_functions; func; func = func->next)
if (!strncasecmp(partial, func->name, len))
buf[bpos++] = func->name;
for (func = cmd->engine_functions; func; func = func->next)
cmd_function_t *func;
size_t len = strlen(partial);
// Loop through the command list and print all matches
- for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ for (func = cmd->userdefined->qc_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)
void Cmd_ClearCSQCCommands (cmd_state_t *cmd)
{
cmd_function_t *func;
- cmd_function_t **next = &cmd->userdefined->csqc_functions;
+ cmd_function_t **next = &cmd->userdefined->qc_functions;
while(*next)
{
goto done; // no tokens
// check functions
- for (func = cmd->userdefined->csqc_functions; func; func = func->next)
+ for (func = cmd->userdefined->qc_functions; func; func = func->next)
{
if (!strcasecmp(cmd->argv[0], func->name))
{
- if (func->csqcfunc && CL_VM_ConsoleCommand(text)) //[515]: csqc
- goto done;
- break;
+ if(func->qcfunc)
+ {
+ if((func->flags & CF_CLIENT) && CL_VM_ConsoleCommand(text))
+ goto done;
+ else if((func->flags & CF_SERVER) && SV_VM_ConsoleCommand(text))
+ goto done;
+ }
}
}
cmd_state_t *cmd = cmd_iter->cmd;
cmd_function_t *f;
cmd_alias_t *a;
- for (f = cmd->userdefined->csqc_functions; f; f = f->next)
+ for (f = cmd->userdefined->qc_functions; f; f = f->next)
f->initstate = true;
for (f = cmd->engine_functions; f; f = f->next)
f->initstate = true;
cmd_state_t *cmd = cmd_iter->cmd;
cmd_function_t *f, **fp;
cmd_alias_t *a, **ap;
- for (fp = &cmd->userdefined->csqc_functions; (f = *fp);)
+ for (fp = &cmd->userdefined->qc_functions; (f = *fp);)
{
if (f->initstate)
fp = &f->next;
SV_FlushBroadcastMessages();
}
+qbool SV_VM_ConsoleCommand (const char *text)
+{
+ prvm_prog_t *prog = SVVM_prog;
+ int restorevm_tempstringsbuf_cursize;
+ int save_self;
+ qbool r = false;
+
+ if(!sv.active || !prog || !prog->loaded)
+ return false;
+
+ if (PRVM_serverfunction(ConsoleCmd))
+ {
+ save_self = PRVM_serverglobaledict(self);
+ PRVM_serverglobalfloat(time) = sv.time;
+ restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize;
+ PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(sv.world.prog->edicts);
+ PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, text);
+ prog->ExecuteProgram(prog, PRVM_serverfunction(ConsoleCmd), "QC function ConsoleCmd is missing");
+ prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
+ PRVM_serverglobaledict(self) = save_self;
+ r = (int) PRVM_G_FLOAT(OFS_RETURN) != 0;
+ }
+ return r;
+}
+
+// #352 void(string cmdname) registercommand (EXT_CSQC)
+static void VM_SV_registercommand (prvm_prog_t *prog)
+{
+ VM_SAFEPARMCOUNT(1, VM_SV_registercmd);
+ if(!Cmd_Exists(&cmd_server, PRVM_G_STRING(OFS_PARM0)))
+ Cmd_AddCommand(CF_SERVER, PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC");
+}
+
//PF_setpause, // void(float pause) setpause = #531;
static void VM_SV_setpause(prvm_prog_t *prog) {
int pauseValue;
NULL, // #349 float() isdemo (EXT_CSQC)
VM_isserver, // #350 float() isserver (EXT_CSQC)
NULL, // #351 void(vector origin, vector forward, vector right, vector up) SetListener (EXT_CSQC)
-NULL, // #352 void(string cmdname) registercommand (EXT_CSQC)
+VM_SV_registercommand, // #352 void(string cmdname) registercommand (EXT_CSQC)
VM_wasfreed, // #353 float(entity ent) wasfreed (EXT_CSQC) (should be availabe on server too)
VM_SV_serverkey, // #354 string(string key) serverkey (EXT_CSQC)
NULL, // #355