Index: trunk/code/game/g_client.c =================================================================== --- trunk/code/game/g_client.c (revision 1288) +++ trunk/code/game/g_client.c (working copy) @@ -613,7 +613,7 @@ char *p; int spaces; - //save room for trailing null byte + // save room for trailing null byte outSize--; len = 0; @@ -634,26 +634,22 @@ } // check colors - if( ch == Q_COLOR_ESCAPE ) { - // solo trailing carat is not a color prefix - if( !*in ) { + if( ch == Q_COLOR_ESCAPE && *in && *in != Q_COLOR_ESCAPE ) { + // make sure there is room for both chars + if( (len += 2) > outSize ) { break; } + *out++ = ch; // don't allow black in a name, period if( ColorIndex(*in) == 0 ) { + *out++ = COLOR_WHITE; in++; - continue; } - - // make sure room in dest for both chars - if( len > outSize - 2 ) { - break; + else { + *out++ = *in++; } - *out++ = ch; - *out++ = *in++; - len += 2; continue; } @@ -664,26 +660,28 @@ if( spaces > 3 ) { continue; } + + if( ++len > outSize ) { + break; + } + *out++ = ch; - len++; - continue; } else { spaces = 0; } - if( len > outSize - 1 ) { + if( ++len > outSize ) { break; } *out++ = ch; colorlessLen++; - len++; } *out = 0; // don't allow empty names - if( *p == 0 || colorlessLen == 0 ) { + if( colorlessLen == 0 ) { Q_strncpyz( p, "UnnamedPlayer", outSize ); } }