[Bug 3313] New: recursive color escape codes

bugzilla-daemon at icculus.org bugzilla-daemon at icculus.org
Wed Aug 15 00:46:20 EDT 2007


http://bugzilla.icculus.org/show_bug.cgi?id=3313

           Summary: recursive color escape codes
           Product: Quake 3
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P3
         Component: Misc
        AssignedTo: zakk at icculus.org
        ReportedBy: devhc97 at gmail.com
         QAContact: quake3-bugzilla at icculus.org


It is possible to input such strings, that when stripped from color code escape
squences in one pass, would result in a color coded string (expected to have no
color codes).

For example ^^14noob is the player's name. The ^1 squence will activate a red
color istead of writing ^1. (So the name will look like a default (white) "^"
followed by a red "4noob".) When we need to display the name without colors (or
one specific color), we ignore ^N sequences. This results in a printing of
^4noob, in which ^4 is recongnized as a blue color escape code! (Resulting in a
blue "noob" output.)

I recommend a function that processes the string until there is nothing to
strip. At the end of execution, the function guarantees no remaining color
codes.

void Q_StripColorEscapes( char *str ) {
        qboolean wasColored;
        char *src, *dst;

        do {
                wasColored = qfalse;
                dst = src = str;

                while( *src ) {
                        if( *src == Q_COLOR_ESCAPE && *( src + 1 )
                         && *( src + 1 ) != Q_COLOR_ESCAPE ) {
                                wasColored = qtrue;
                                src += 2;

                                while( *src ) {
                                        if( *src == Q_COLOR_ESCAPE && *( src +
1 )
                                         && *( src + 1 ) != Q_COLOR_ESCAPE ) {
                                                src += 2;
                                                continue;
                                        }
                                        *dst++ = *src++;
                                }

                                *dst = '\0';
                                break;
                        }

                        dst++;
                        src++;
                }
        } while( wasColored );
}

TODO:
- Implement this. This function should be used for all user-inputted strings
that need color escape code stripping (not just names).
- To optimize, for every player name there should be a pre-stored stripped
string.


-- 
Configure bugmail: http://bugzilla.icculus.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.



More information about the quake3-bugzilla mailing list