From: havoc Date: Wed, 20 Oct 2004 12:58:15 +0000 (+0000) Subject: messagemode/messagemode2 now send the say/say_team command directly instead of passin... X-Git-Tag: xonotic-v0.1.0preview~5445 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=7e5798f42d1ce9ca82f71343b98fceafa3956adb messagemode/messagemode2 now send the say/say_team command directly instead of passing through the client console, so that typing something like ";quit" as a message does not quit the game git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4679 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cmd.c b/cmd.c index 2e1323a4..fe455296 100644 --- 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) { - Con_Printf("Can't \"%s\", not connected\n", Cmd_Argv(0)); + Con_Printf("Can't \"%s\", not connected\n", s); 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. - 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); +} + /* ================ diff --git a/cmd.h b/cmd.h index 04e44e27..35ce36f2 100644 --- 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. +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, diff --git a/keys.c b/keys.c index f1fa5c52..47ec8ab0 100644 --- a/keys.c +++ b/keys.c @@ -505,13 +505,9 @@ static void 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;