]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - console.c
- be less paranoid about clearing rcon_password (only needed when connecting to anoth...
[xonotic/darkplaces.git] / console.c
index be3c12c8a816a51817b72751be8a19e9318d9a6b..6087f169124397d64fff298abc8f2d525d7d43a9 100644 (file)
--- a/console.c
+++ b/console.c
@@ -124,7 +124,7 @@ cvar_t log_file = {0, "log_file","", "filename to log messages to"};
 cvar_t log_dest_udp = {0, "log_dest_udp","", "UDP address to log messages to (in QW rcon compatible format); multiple destinations can be separated by spaces; DO NOT SPECIFY DNS NAMES HERE"};
 char log_dest_buffer[1400]; // UDP packet
 size_t log_dest_buffer_pos;
-qboolean log_dest_buffer_appending;
+unsigned int log_dest_buffer_appending;
 char crt_log_file [MAX_OSPATH] = "";
 qfile_t* logfile = NULL;
 
@@ -844,7 +844,7 @@ Con_Rcon_AddChar
 Adds a character to the rcon buffer
 ================
 */
-void Con_Rcon_AddChar(char c)
+void Con_Rcon_AddChar(int c)
 {
        if(log_dest_buffer_appending)
                return;
@@ -917,7 +917,7 @@ static char Sys_Con_NearestColor(const unsigned char _r, const unsigned char _g,
                h = (int)(60.0 * (g-b)/(max-min))%360;
        else if(max == g)
                h = (int)(60.0 * (b-r)/(max-min) + 120);
-       else if(max == b)
+       else // if(max == b) redundant check
                h = (int)(60.0 * (r-g)/(max-min) + 240);
 
        if(h < 36) // *red* to orange
@@ -1030,13 +1030,13 @@ void Con_Print(const char *msg)
                                        int lastcolor = 0;
                                        const char *in;
                                        char *out;
-                                       char color;
+                                       int color;
                                        for(in = line, out = printline; *in; ++in)
                                        {
                                                switch(*in)
                                                {
                                                        case STRING_COLOR_TAG:
-                                                               if( in[1] == STRING_COLOR_RGB_DEFAULT && isxdigit(in[2]) && isxdigit(in[3]) && isxdigit(in[4]) )
+                                                               if( in[1] == STRING_COLOR_RGB_TAG_CHAR && isxdigit(in[2]) && isxdigit(in[3]) && isxdigit(in[4]) )
                                                                {
                                                                        char r = tolower(in[2]);
                                                                        char g = tolower(in[3]);
@@ -1057,12 +1057,6 @@ void Con_Print(const char *msg)
                                                                
                                                                switch(color)
                                                                {
-                                                                       /*case 'a':
-                                                                               if ( isxdigit(in[2]) || in[2] == '+' || in[2] == '-' )
-                                                                               {
-                                                                                       in+=2;
-                                                                                       break;
-                                                                               }*/
                                                                        case STRING_COLOR_TAG:
                                                                                ++in;
                                                                                *out++ = STRING_COLOR_TAG;
@@ -1161,18 +1155,16 @@ void Con_Print(const char *msg)
                                                        case STRING_COLOR_TAG:
                                                                switch(in[1])
                                                                {
-                                                                       case STRING_COLOR_RGB_DEFAULT:
+                                                                       case STRING_COLOR_RGB_TAG_CHAR:
                                                                                if ( isxdigit(in[2]) && isxdigit(in[3]) && isxdigit(in[4]) )
                                                                                {
                                                                                        in+=4;
                                                                                        break;
                                                                                }
-                                                                       /*case 'a':
-                                                                               if ( isxdigit(in[2]) || in[2] == '+' || in[2] == '-' )
-                                                                               {
-                                                                                       in+=2;
-                                                                                       break;
-                                                                               }*/
+                                                                               *out++ = STRING_COLOR_TAG;
+                                                                               *out++ = STRING_COLOR_RGB_TAG_CHAR;
+                                                                               ++in;
+                                                                               break;
                                                                        case STRING_COLOR_TAG:
                                                                                ++in;
                                                                                *out++ = STRING_COLOR_TAG;
@@ -1380,9 +1372,9 @@ int Con_DisplayLineFunc(void *passthrough, const char *line, size_t length, floa
                (void) 0;
        else
        {
-               int x = ti->x + (ti->width - width) * ti->alignment;
+               int x = (int) (ti->x + (ti->width - width) * ti->alignment);
                if(isContinuation && *ti->continuationString)
-                       x += DrawQ_String_Font(x, ti->y, ti->continuationString, strlen(ti->continuationString), ti->fontsize, ti->fontsize, 1.0, 1.0, 1.0, 1.0, 0, NULL, false, ti->font);
+                       x += (int) DrawQ_String_Font(x, ti->y, ti->continuationString, strlen(ti->continuationString), ti->fontsize, ti->fontsize, 1.0, 1.0, 1.0, 1.0, 0, NULL, false, ti->font);
                if(length > 0)
                        DrawQ_String_Font(x, ti->y, line, length, ti->fontsize, ti->fontsize, 1.0, 1.0, 1.0, 1.0, 0, &(ti->colorindex), false, ti->font);
        }
@@ -1415,7 +1407,7 @@ int Con_DrawNotifyRect(int mask_must, int mask_mustnot, float maxage, float x, f
        l = 0;
        Con_WordWidthFunc(&ti, NULL, &l, -1);
        l = strlen(continuationString);
-       continuationWidth = Con_WordWidthFunc(&ti, continuationString, &l, -1);
+       continuationWidth = (int) Con_WordWidthFunc(&ti, continuationString, &l, -1);
 
        // first find the first line to draw by backwards iterating and word wrapping to find their length...
        startidx = con_lines_count;
@@ -1812,8 +1804,8 @@ qboolean GetMapList (const char *s, char *completedname, int completednamebuffer
                                        if (com_token[0] == '}')
                                                break;
                                        // skip leading whitespace
-                                       for (k = 0;com_token[k] && com_token[k] <= ' ';k++);
-                                       for (l = 0;l < (int)sizeof(keyname) - 1 && com_token[k+l] && com_token[k+l] > ' ';l++)
+                                       for (k = 0;com_token[k] && ISWHITESPACE(com_token[k]);k++);
+                                       for (l = 0;l < (int)sizeof(keyname) - 1 && com_token[k+l] && !ISWHITESPACE(com_token[k+l]);l++)
                                                keyname[l] = com_token[k+l];
                                        keyname[l] = 0;
                                        if (!COM_ParseToken_Simple(&data, false, false))
@@ -1932,7 +1924,7 @@ void SanitizeString(char *in, char *out)
                                } else if (*in == STRING_COLOR_TAG) // ^[0-9]^ found, don't print ^[0-9]
                                        continue;
                        }
-                       else if (*in == STRING_COLOR_RGB_DEFAULT) // ^x found
+                       else if (*in == STRING_COLOR_RGB_TAG_CHAR) // ^x found
                        {
                                if ( isxdigit(in[1]) && isxdigit(in[2]) && isxdigit(in[3]) )
                                {
@@ -1946,20 +1938,6 @@ void SanitizeString(char *in, char *out)
                                }
                                else in--;
                        }
-                       /*else if (*in == 'a') // ^a found
-                       {
-                               if ( isxdigit(in[1]) || isxdigit(in[1]) == '+' || isxdigit(in[1]) == '-')
-                               {
-                                       in+=2;
-                                       if (!*in)
-                                       {
-                                               *out = 0;
-                                               return;
-                                       } else if (*in == STRING_COLOR_TAG) // ^ax^ found, don't print ^ax
-                                               continue;
-                               }
-                               else in = in--;
-                       }*/
                        else if (*in != STRING_COLOR_TAG)
                                --in;
                }
@@ -2318,7 +2296,7 @@ int Nicks_AddLastColor(char *buffer, int pos)
 {
        qboolean quote_added = false;
        int match;
-       char color = STRING_COLOR_DEFAULT + '0';
+       int color = STRING_COLOR_DEFAULT + '0';
        char r = 0, g = 0, b = 0;
 
        if(con_nickcompletion_flags.integer & NICKS_ADD_QUOTE && buffer[Nicks_matchpos-1] == '\"')
@@ -2341,14 +2319,16 @@ int Nicks_AddLastColor(char *buffer, int pos)
                                        color = buffer[match+1];
                                        break;
                                }
-                               else if(buffer[match+1] == STRING_COLOR_RGB_DEFAULT)
+                               else if(buffer[match+1] == STRING_COLOR_RGB_TAG_CHAR)
                                {
                                        if ( isxdigit(buffer[match+2]) && isxdigit(buffer[match+3]) && isxdigit(buffer[match+4]) )
+                                       {
                                                r = buffer[match+2];
                                                g = buffer[match+3];
                                                b = buffer[match+4];
                                                color = -1;
                                                break;
+                                       }
                                }
                        }
                }
@@ -2358,7 +2338,7 @@ int Nicks_AddLastColor(char *buffer, int pos)
                        {
                                pos -= 2;
                        }
-                       else if( pos >= 5 && buffer[pos-5] == STRING_COLOR_TAG && buffer[pos-4] == STRING_COLOR_RGB_DEFAULT)
+                       else if( pos >= 5 && buffer[pos-5] == STRING_COLOR_TAG && buffer[pos-4] == STRING_COLOR_RGB_TAG_CHAR)
                        {
                                if ( isxdigit(buffer[pos-3]) && isxdigit(buffer[pos-2]) && isxdigit(buffer[pos-1]) )
                                {
@@ -2370,17 +2350,11 @@ int Nicks_AddLastColor(char *buffer, int pos)
                if (color == -1)
                {
                        buffer[pos++] = STRING_COLOR_TAG;
-                       buffer[pos++] = STRING_COLOR_RGB_DEFAULT;
+                       buffer[pos++] = STRING_COLOR_RGB_TAG_CHAR;
                        buffer[pos++] = r;
                        buffer[pos++] = g;
                        buffer[pos++] = b;
                }
-               /*else if (color == -2)
-               {
-                       buffer[pos++] = STRING_COLOR_TAG;
-                       buffer[pos++] = 'a';
-                       buffer[pos++] = a;
-               }*/
                else
                {
                        buffer[pos++] = STRING_COLOR_TAG;