Index: src/ui/ui_shared.c =================================================================== --- src/ui/ui_shared.c (revision 1090) +++ src/ui/ui_shared.c (working copy) @@ -4544,7 +4544,7 @@ { static char out[ 8192 ]; char *paint = out; - char c[ 3 ]; + char startcolour[ 3 ], endcolour[ 3 ]; const char *p = text; const char *eol; const char *q = NULL, *qMinus1 = NULL; @@ -4560,7 +4560,8 @@ while( *p ) { - Com_Memset( c, 0, sizeof( c ) ); + Com_Memset( startcolour, 0, sizeof( startcolour ) ); + Com_Memset( endcolour, 0, sizeof( endcolour ) ); // Skip leading whitespace @@ -4568,8 +4569,8 @@ { if( Q_IsColorString( p ) ) { - c[ 0 ] = p[ 0 ]; - c[ 1 ] = p[ 1 ]; + startcolour[ 0 ] = p[ 0 ]; + startcolour[ 1 ] = p[ 1 ]; p += 2; } else if( *p != '\n' && isspace( *p ) ) @@ -4589,8 +4590,9 @@ while( Q_IsColorString( q ) ) { - c[ 0 ] = q[ 0 ]; - c[ 1 ] = q[ 1 ]; + Com_Error( ERR_DROP, "benmachine is crazy\n" ); + startcolour[ 0 ] = q[ 0 ]; + startcolour[ 1 ] = q[ 1 ]; q += 2; } @@ -4598,8 +4600,8 @@ while( Q_IsColorString( q ) ) { - c[ 0 ] = q[ 0 ]; - c[ 1 ] = q[ 1 ]; + startcolour[ 0 ] = q[ 0 ]; + startcolour[ 1 ] = q[ 1 ]; q += 2; } @@ -4619,8 +4621,8 @@ // Skip color escapes while( Q_IsColorString( q ) ) { - c[ 0 ] = q[ 0 ]; - c[ 1 ] = q[ 1 ]; + endcolour[ 0 ] = q[ 0 ]; + endcolour[ 1 ] = q[ 1 ]; q += 2; } while( UI_Text_Emoticon( q, &emoticonEscaped, &emoticonLen, NULL, NULL ) ) @@ -4639,8 +4641,8 @@ // Some color escapes might still be present while( Q_IsColorString( q ) ) { - c[ 0 ] = q[ 0 ]; - c[ 1 ] = q[ 1 ]; + endcolour[ 0 ] = q[ 0 ]; + endcolour[ 1 ] = q[ 1 ]; q += 2; } while( UI_Text_Emoticon( q, &emoticonEscaped, &emoticonLen, NULL, NULL ) ) @@ -4668,6 +4670,9 @@ if( eol == p ) eol = q; + // Add colour code (might be empty) + Q_strcat( out, sizeof( out ), startcolour ); + paint = out + strlen( out ); // Copy text @@ -4679,7 +4684,7 @@ if( out[ strlen( out ) - 1 ] != '\n' ) { Q_strcat( out, sizeof( out ), "\n " ); - Q_strcat( out, sizeof( out ), c ); + Q_strcat( out, sizeof( out ), endcolour ); } paint = out + strlen( out );