l = (int)strlen(text);
Cbuf_Lock(cmd);
- if (cmd->text.cursize + l >= (size_t)cmd->text.maxsize)
+ if (cmd->text.maxsize - cmd->text.cursize <= l)
Con_Print("Cbuf_AddText: overflow\n");
else
SZ_Write(&cmd->text, (const unsigned char *)text, l);
//
// client-only commands
Cmd_AddCommand(&cmd_client, "cmd", Cmd_ForwardToServer_f, "send a console commandline to the server (used by some mods)");
+ Cmd_AddCommand(&cmd_clientfromserver, "cmd", Cmd_ForwardToServer_f, "send a console commandline to the server (used by some mods)");
Cmd_AddCommand(&cmd_client, "wait", Cmd_Wait_f, "make script execution wait for next rendered frame");
Cmd_AddCommand(&cmd_client, "cprint", Cmd_Centerprint_f, "print something at the screen center");
return buf;
}
-void Cmd_ClearCsqcFuncs (cmd_state_t *cmd)
+// TODO: Make this more generic?
+void Cmd_ClearCSQCCommands (cmd_state_t *cmd)
{
cmd_function_t *func;
- for (func = cmd->userdefined->csqc_functions; func; func = func->next)
- func->csqcfunc = false;
+ cmd_function_t **next = &cmd->userdefined->csqc_functions;
+
+ while(*next)
+ {
+ func = *next;
+ *next = func->next;
+ Z_Free(func);
+ }
}
/*
// if it's a client command and no command was found, say so.
if (cmd->source == src_client)
{
- Con_Printf("player \"%s\" tried to %s\n", host_client->name, text);
+ Con_Printf("Client \"%s\" tried to execute \"%s\"\n", host_client->name, text);
goto done;
}
}
// check cvars
- if (!Cvar_Command(cmd) && host_framecount > 0)
- Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(cmd, 0));
-
+ if (!Cvar_Command(cmd) && host_framecount > 0) {
+ if (cmd == &cmd_clientfromserver) {
+ Con_Printf("Server tried to execute \"%s\"\n", Cmd_Argv(cmd, 0));
+ } else {
+ Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(cmd, 0));
+ }
+ }
done:
cmd->tokenizebufferpos = oldpos;
if (lockmutex)