From a384870e4b6ad3719f658851d1b3abdc0929e02d Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 28 Feb 2002 04:12:20 +0000 Subject: [PATCH] cl_chatmode works again --- libs/console/client.c | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/libs/console/client.c b/libs/console/client.c index 66046fa40..96e387cff 100644 --- a/libs/console/client.c +++ b/libs/console/client.c @@ -260,14 +260,46 @@ Condump_f (void) Qclose (file); } +qboolean +CheckForCommand (const char *line) +{ + char command[128]; + const char *cmd; + int i; + + for (i = 0; i < 127; i++) + + if (line[i] <= ' ') + break; + else + command[i] = line[i]; + command[i] = 0; + + cmd = Cmd_CompleteCommand (command); + if (!cmd || strcmp (cmd, command)) + cmd = Cvar_CompleteVariable (command); + if (!cmd || strcmp (cmd, command)) + return false; // just a chat message + return true; +} + static void C_ExecLine (const char *line) { - Con_Printf ("%s\n", line); - if (line[0] == '/') - line++; - Cbuf_AddText (line); + if (line[0] == '/' && line [1] == '/') + goto no_lf; + else if (line[0] == '\\' || line[0] == '/') + Cbuf_AddText (line + 1); + else if (cl_chatmode->int_val != 1 && CheckForCommand (line)) + Cbuf_AddText (line); + else if (cl_chatmode->int_val) { + Cbuf_AddText ("say "); + Cbuf_AddText (line); + } else + Cbuf_AddText (line); Cbuf_AddText ("\n"); + no_lf: + Con_Printf ("%s\n", line); } static void