some color tag cleanups by terencehill
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 20 Feb 2009 18:13:06 +0000 (18:13 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 20 Feb 2009 18:13:06 +0000 (18:13 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8751 d7cf8633-e32d-0410-b094-e92efae38249

common.c
console.c
draw.h
gl_draw.c
host_cmd.c

index c370552..e29a00a 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1777,7 +1777,7 @@ COM_StringLengthNoColors(const char *s, size_t size_s, qboolean *valid)
                                ++s;
                                switch((s == end) ? 0 : *s)
                                {
-                                       case STRING_COLOR_RGB_DEFAULT:
+                                       case STRING_COLOR_RGB_TAG_CHAR:
                                                if (s+1 != end && isxdigit(s[1]) &&
                                                        s+2 != end && isxdigit(s[2]) &&
                                                        s+3 != end && isxdigit(s[3]) )
@@ -1786,17 +1786,8 @@ COM_StringLengthNoColors(const char *s, size_t size_s, qboolean *valid)
                                                        break;
                                                }
                                                ++len; // STRING_COLOR_TAG
-                                               ++len; // STRING_COLOR_RGB_DEFAULT
+                                               ++len; // STRING_COLOR_RGB_TAG_CHAR
                                                break;
-                                       /*case 'a':
-                                               if ( s+1 != end && ( isxdigit(s[1]) || (s[1] == '+' || s[1] == '-') ) )
-                                               {
-                                                       s++;
-                                                       break;
-                                               }
-                                               ++len; // STRING_COLOR_TAG
-                                               ++len; // STRING_COLOR_RGB_DEFAULT
-                                               break;*/
                                        case 0: // ends with unfinished color code!
                                                ++len;
                                                if(valid)
@@ -1861,7 +1852,7 @@ COM_StringDecolorize(const char *in, size_t size_in, char *out, size_t size_out,
                                ++in;
                                switch((in == end) ? 0 : *in)
                                {
-                                       case STRING_COLOR_RGB_DEFAULT:
+                                       case STRING_COLOR_RGB_TAG_CHAR:
                                                if (in+1 != end && isxdigit(in[1]) &&
                                                        in+2 != end && isxdigit(in[2]) &&
                                                        in+3 != end && isxdigit(in[3]) )
@@ -1872,14 +1863,8 @@ COM_StringDecolorize(const char *in, size_t size_in, char *out, size_t size_out,
                                                APPEND(STRING_COLOR_TAG);
                                                if(escape_carets)
                                                        APPEND(STRING_COLOR_TAG);
-                                               APPEND(STRING_COLOR_RGB_DEFAULT);
+                                               APPEND(STRING_COLOR_RGB_TAG_CHAR);
                                                break;
-                                       /*case 'a':
-                                               if ( in+1 != end && ( isxdigit(in[1]) || (in[1] == '+' || in[1] == '-') ) )
-                                               {
-                                                       in++;
-                                                       break;
-                                               }*/
                                        case 0: // ends with unfinished color code!
                                                APPEND(STRING_COLOR_TAG);
                                                // finish the code by appending another caret when escaping
index 91a99be..6087f16 100644 (file)
--- a/console.c
+++ b/console.c
@@ -1036,7 +1036,7 @@ void Con_Print(const char *msg)
                                                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,22 +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;
                                                                                }
                                                                                *out++ = STRING_COLOR_TAG;
-                                                                               *out++ = STRING_COLOR_RGB_DEFAULT;
+                                                                               *out++ = STRING_COLOR_RGB_TAG_CHAR;
                                                                                ++in;
                                                                                break;
-                                                                       /*case 'a':
-                                                                               if ( isxdigit(in[2]) || in[2] == '+' || in[2] == '-' )
-                                                                               {
-                                                                                       in+=2;
-                                                                                       break;
-                                                                               }*/
                                                                        case STRING_COLOR_TAG:
                                                                                ++in;
                                                                                *out++ = STRING_COLOR_TAG;
@@ -1936,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]) )
                                {
@@ -1950,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;
                }
@@ -2345,7 +2319,7 @@ 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]) )
                                        {
@@ -2364,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]) )
                                {
@@ -2376,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;
diff --git a/draw.h b/draw.h
index 259ed9b..f2c9f7a 100644 (file)
--- a/draw.h
+++ b/draw.h
@@ -110,10 +110,8 @@ extern dp_font_t dp_fonts[MAX_FONTS];
 #define STRING_COLOR_TAG                       '^'
 #define STRING_COLOR_DEFAULT           7
 #define STRING_COLOR_DEFAULT_STR       "^7"
-#define STRING_COLOR_RGB_DEFAULT 'x'
-#define STRING_COLOR_RGB_DEFAULT_STR "^xfff"
-//#define STRING_COLOR_ALPHA_DEFAULT 'a'
-//#define STRING_COLOR_ALPHA_DEFAULT_STR "^af"
+#define STRING_COLOR_RGB_TAG_CHAR      'x'
+#define STRING_COLOR_RGB_TAG           "^x"
 
 // all of these functions will set r_defdef.draw2dstage if not in 2D rendering mode (and of course prepare for 2D rendering in that case)
 
index 18a4d2a..91d866d 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -945,7 +945,7 @@ float DrawQ_TextWidth_Font_UntilWidth_TrackColors(const char *text, size_t *maxl
        size_t i;
        float x = 0;
        char ch;
-       int current_alpha, tempcolorindex;
+       int tempcolorindex;
 
        if (*maxlen < 1)
                *maxlen = 1<<30;
@@ -957,8 +957,6 @@ float DrawQ_TextWidth_Font_UntilWidth_TrackColors(const char *text, size_t *maxl
 
        maxwidth /= fnt->scale;
 
-       current_alpha = 0xf;
-
        for (i = 0;i < *maxlen && text[i];i++)
        {
                if (text[i] == ' ')
@@ -976,7 +974,7 @@ float DrawQ_TextWidth_Font_UntilWidth_TrackColors(const char *text, size_t *maxl
                                colorindex = ch - '0';
                 continue;
                        }
-                       else if (ch == STRING_COLOR_RGB_DEFAULT && i + 3 < *maxlen ) // ^x found
+                       else if (ch == STRING_COLOR_RGB_TAG_CHAR && i + 3 < *maxlen ) // ^x found
                        {
                                // building colorindex...
                                ch = tolower(text[i+1]);
@@ -998,7 +996,7 @@ float DrawQ_TextWidth_Font_UntilWidth_TrackColors(const char *text, size_t *maxl
                                                else tempcolorindex = 0;
                                                if (tempcolorindex)
                                                {
-                                                       colorindex = tempcolorindex | current_alpha;
+                                                       colorindex = tempcolorindex | 0xf;
                                                        // ...done! now colorindex has rgba codes (1,rrrr,gggg,bbbb,aaaa)
                                                        i+=3;
                                                        continue;
@@ -1006,30 +1004,6 @@ float DrawQ_TextWidth_Font_UntilWidth_TrackColors(const char *text, size_t *maxl
                                        }
                                }
                        }
-                       /*else if (ch == 'a' && i + 1 < *maxlen) // ^a found
-                       {
-                               if (colorindex > 9)
-                               {
-                                       ch = tolower(text[i+1]);
-                                       if (ch <= '9' && ch >= '0') current_alpha = (ch - '0');
-                                       else if (ch >= 'a' && ch <= 'f') current_alpha = (ch - 87);
-                                       else if (ch == '+' && colorindex > 9)
-                                       {
-                                               current_alpha = colorindex & 0xf;
-                                               if (current_alpha < 0xf)
-                                                       current_alpha++;
-                                       }
-                                       else if (ch == '-' && colorindex > 9)
-                                       {
-                                               current_alpha = colorindex & 0xf;
-                                               if (current_alpha > 0)
-                                                       current_alpha--;
-                                       }
-                                       colorindex = ((colorindex >> 4 ) << 4) + current_alpha;
-                               }
-                               i++;
-                               continue;
-                       }*/
                        else if (ch == STRING_COLOR_TAG) // ^^ found, ignore the first ^ and go to print the second
                                i++;
                        i--;
@@ -1060,7 +1034,7 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
        float texcoord2f[QUADELEMENTS_MAXQUADS*4*2];
        float color4f[QUADELEMENTS_MAXQUADS*4*4];
        int ch;
-       int current_alpha, tempcolorindex;
+       int tempcolorindex;
 
        int tw, th;
        tw = R_TextureWidth(fnt->tex);
@@ -1103,7 +1077,6 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
                        x += r_textshadow.value;
                        y += r_textshadow.value;
                }
-               current_alpha = 0xf;
                for (i = 0;i < maxlen && text[i];i++)
                {
                        if (text[i] == ' ')
@@ -1120,7 +1093,7 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
                                        DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow);
                                        continue;
                                }
-                               else if (ch == STRING_COLOR_RGB_DEFAULT && i+3 < maxlen ) // ^x found
+                               else if (ch == STRING_COLOR_RGB_TAG_CHAR && i+3 < maxlen ) // ^x found
                                {
                                        // building colorindex...
                                        ch = tolower(text[i+1]);
@@ -1142,7 +1115,7 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
                                                        else tempcolorindex = 0;
                                                        if (tempcolorindex)
                                                        {
-                                                               colorindex = tempcolorindex | current_alpha;
+                                                               colorindex = tempcolorindex | 0xf;
                                                                // ...done! now colorindex has rgba codes (1,rrrr,gggg,bbbb,aaaa)
                                                                //Con_Printf("^1colorindex:^7 %x\n", colorindex);
                                                                DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow);
@@ -1152,32 +1125,6 @@ float DrawQ_String_Font(float startx, float starty, const char *text, size_t max
                                                }
                                        }
                                }
-                               /*else if (ch == 'a' && i+1 < maxlen ) // ^a found
-                               {
-                                       if (colorindex > 9) // colorindex is a RGB color
-                                       {
-                                               ch = tolower(text[i+1]);
-                                               if (ch <= '9' && ch >= '0') current_alpha = (ch - '0');
-                                               else if (ch >= 'a' && ch <= 'f') current_alpha = (ch - 87);
-                                               else if (ch == '+' && colorindex > 9)
-                                               {
-                                                       current_alpha = colorindex & 0xf;
-                                                       if (current_alpha < 0xf)
-                                                               current_alpha++;
-                                               }
-                                               else if (ch == '-' && colorindex > 9)
-                                               {
-                                                       current_alpha = colorindex & 0xf;
-                                                       if (current_alpha > 0)
-                                                               current_alpha--;
-                                               }
-                                               colorindex = ((colorindex >> 4 ) << 4) + current_alpha;
-                                               //Con_Printf("^1colorindex:^7 %x\n", colorindex);
-                                               DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow);
-                                       }
-                                       i++;
-                                       continue;
-                               }*/
                                else if (ch == STRING_COLOR_TAG)
                                        i++;
                                i--;
index 0de8ba3..0437bbd 100644 (file)
@@ -1048,7 +1048,7 @@ void Host_Name_f (void)
                                i++;
                                continue;
                        }
-                       if (host_client->name[i+1] == STRING_COLOR_RGB_DEFAULT && isxdigit(host_client->name[i+2]) && isxdigit(host_client->name[i+3]) && isxdigit(host_client->name[i+4]))
+                       if (host_client->name[i+1] == STRING_COLOR_RGB_TAG_CHAR && isxdigit(host_client->name[i+2]) && isxdigit(host_client->name[i+3]) && isxdigit(host_client->name[i+4]))
                        {
                                j = i;
                                i += 4;