]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
messagemode/messagemode2 now send the say/say_team command directly instead of passin...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 20 Oct 2004 12:58:15 +0000 (12:58 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 20 Oct 2004 12:58:15 +0000 (12:58 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4679 d7cf8633-e32d-0410-b094-e92efae38249

cmd.c
cmd.h
keys.c

diff --git a/cmd.c b/cmd.c
index 2e1323a41f9ed62c741931ad0ca5ceb5ca8f6813..fe455296ef4fc3278ac270e7308ebcd0c1ae95f7 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -820,17 +820,16 @@ void Cmd_ExecuteString (const char *text, cmd_source_t src)
 
 /*
 ===================
 
 /*
 ===================
-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)
        {
        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;
        }
 
                return;
        }
 
@@ -840,14 +839,27 @@ void Cmd_ForwardToServer (void)
        // 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.
        // 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);
 }
 
        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);
+}
+
 
 /*
 ================
 
 /*
 ================
diff --git a/cmd.h b/cmd.h
index 04e44e27e7494b5ef4cca593a727e5e83dc6a73a..35ce36f26b8582b8f350e00f330febec5f1b1add 100644 (file)
--- a/cmd.h
+++ b/cmd.h
@@ -126,6 +126,10 @@ void Cmd_ExecuteString (const char *text, cmd_source_t src);
 // 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.
 
 // 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,
 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,
diff --git a/keys.c b/keys.c
index f1fa5c525f9174365d25e3fe3581eb8cbe639a5c..47ec8ab0ef3a12b5f3d2141a260fe1ac123dd345 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -505,13 +505,9 @@ static void
 Key_Message (int key, char ascii)
 {
 
 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;
 
                key_dest = key_game;
                chat_bufferlen = 0;