]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix little bug that made \001 destroy the first output character in log_dest_udp
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 8 Jul 2007 23:00:26 +0000 (23:00 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 8 Jul 2007 23:00:26 +0000 (23:00 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7472 d7cf8633-e32d-0410-b094-e92efae38249

console.c

index b6f49ee42b8f49fff081b5bd1dfcf2d0c8154179..eeed6627f255acf64a0a101d665579977774ad39 100644 (file)
--- a/console.c
+++ b/console.c
@@ -670,6 +670,31 @@ static char qfont_table[256] = {
        'x',  'y',  'z',  '{',  '|',  '}',  '~',  '<'
 };
 
+/*
+================
+Con_Rcon_AddChar
+
+Adds a character to the rcon buffer
+================
+*/
+inline void Con_Rcon_AddChar(char c)
+{
+       // if this print is in response to an rcon command, add the character
+       // to the rcon redirect buffer
+       if (rcon_redirect && rcon_redirect_bufferpos < (int)sizeof(rcon_redirect_buffer) - 1)
+               rcon_redirect_buffer[rcon_redirect_bufferpos++] = c;
+       else if(*log_dest_udp.string) // don't duplicate rcon command responses here, these are sent another way
+       {
+               if(log_dest_buffer_pos == 0)
+                       Log_DestBuffer_Init();
+               log_dest_buffer[log_dest_buffer_pos++] = c;
+               if(log_dest_buffer_pos >= sizeof(log_dest_buffer) - 1) // minus one, to allow for terminating zero
+                       Log_DestBuffer_Flush();
+       }
+       else
+               log_dest_buffer_pos = 0;
+}
+
 /*
 ================
 Con_Print
@@ -682,27 +707,13 @@ extern cvar_t timeformat;
 extern qboolean sys_nostdout;
 void Con_Print(const char *msg)
 {
-       int mask = 0;
+       static int mask = 0;
        static int index = 0;
        static char line[MAX_INPUTLINE];
 
        for (;*msg;msg++)
        {
-               // if this print is in response to an rcon command, add the character
-               // to the rcon redirect buffer
-               if (rcon_redirect && rcon_redirect_bufferpos < (int)sizeof(rcon_redirect_buffer) - 1)
-                       rcon_redirect_buffer[rcon_redirect_bufferpos++] = *msg;
-               else if(*log_dest_udp.string) // don't duplicate rcon command responses here, these are sent another way
-               {
-                       if(log_dest_buffer_pos == 0)
-                               Log_DestBuffer_Init();
-                       log_dest_buffer[log_dest_buffer_pos++] = *msg;
-                       if(log_dest_buffer_pos >= sizeof(log_dest_buffer) - 1) // minus one, to allow for terminating zero
-                               Log_DestBuffer_Flush();
-               }
-               else
-                       log_dest_buffer_pos = 0;
-
+               Con_Rcon_AddChar(*msg);
                // if this is the beginning of a new line, print timestamp
                if (index == 0)
                {
@@ -727,6 +738,7 @@ void Con_Print(const char *msg)
                                line[index++] = STRING_COLOR_TAG;
                                line[index++] = '3';
                                msg++;
+                               Con_Rcon_AddChar(*msg);
                        }
                        // store timestamp
                        for (;*timestamp;index++, timestamp++)