/*
===================
-Cmd_ForwardToServer
+Cmd_ForwardStringToServer
-Sends the entire command line over to the server
+Sends an entire command string over to the server, unprocessed
===================
*/
-void Cmd_ForwardToServer (void)
+void Cmd_ForwardStringToServer (const char *s)
{
- const char *s;
if (cls.state != ca_connected)
{
- Con_Printf("Can't \"%s\", not connected\n", Cmd_Argv(0));
+ Con_Printf("Can't \"%s\", not connected\n", s);
return;
}
// LordHavoc: thanks to Fuh for bringing the pure evil of SZ_Print to my
// attention, it has been eradicated from here, its only (former) use in
// all of darkplaces.
- if (strcasecmp(Cmd_Argv(0), "cmd") != 0)
- s = va("%s %s", Cmd_Argv(0), Cmd_Argc() > 1 ? Cmd_Args() : "\n");
- else
- s = Cmd_Argc() > 1 ? Cmd_Args() : "\n";
MSG_WriteByte(&cls.message, clc_stringcmd);
SZ_Write(&cls.message, s, strlen(s) + 1);
}
+/*
+===================
+Cmd_ForwardToServer
+
+Sends the entire command line over to the server
+===================
+*/
+void Cmd_ForwardToServer (void)
+{
+ const char *s;
+ if (strcasecmp(Cmd_Argv(0), "cmd"))
+ s = va("%s %s", Cmd_Argv(0), Cmd_Argc() > 1 ? Cmd_Args() : "");
+ else
+ s = Cmd_Argc() > 1 ? Cmd_Args() : "";
+ Cmd_ForwardStringToServer(s);
+}
+
/*
================
// Parses a single line of text into arguments and tries to execute it.
// The text can come from the command buffer, a remote client, or stdin.
+void Cmd_ForwardStringToServer (const char *s);
+// adds the string as a clc_stringcmd to the client message.
+// (used when there is no reason to generate a local command to do it)
+
void Cmd_ForwardToServer (void);
// adds the current command line as a clc_stringcmd to the client message.
// things like godmode, noclip, etc, are commands directed to the server,
Key_Message (int key, char ascii)
{
- if (key == K_ENTER) {
- if (chat_team)
- Cbuf_AddText ("say_team \"");
- else
- Cbuf_AddText ("say \"");
- Cbuf_AddText (chat_buffer);
- Cbuf_AddText ("\"\n");
+ if (key == K_ENTER)
+ {
+ Cmd_ForwardStringToServer(va("%s %s", chat_team ? "say_team" : "say ", chat_buffer));
key_dest = key_game;
chat_bufferlen = 0;