diff --git a/engine/client/console.c b/engine/client/console.c index deb062aa..0a37e588 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -843,11 +843,14 @@ If no console is visible, the notify window will pop up. */ void Con_Print( const char *txt ) { - static int cr_pending = 0; - static char buf[MAX_PRINT_MSG]; - qboolean norefresh = false; - static int lastlength = 0; - static int bufpos = 0; + static qboolean cr_pending = false; + static qboolean colorstring = false; + static char buf[MAX_PRINT_MSG]; + static int lastlength = 0; + static int bufpos = 0; + static int charpos = 0; + + qboolean norefresh = false; int c, mask = 0; // client not running @@ -873,7 +876,7 @@ void Con_Print( const char *txt ) if( cr_pending ) { Con_DeleteLastLine(); - cr_pending = 0; + cr_pending = false; } c = *txt; @@ -886,23 +889,42 @@ void Con_Print( const char *txt ) { Con_AddLine( buf, bufpos, true ); lastlength = CON_LINES_LAST().length; - cr_pending = 1; + cr_pending = true; bufpos = 0; + charpos = 0; } break; case '\n': Con_AddLine( buf, bufpos, true ); lastlength = CON_LINES_LAST().length; bufpos = 0; + charpos = 0; break; default: - buf[bufpos++] = c | mask; - if(( bufpos >= sizeof( buf ) - 1 ) || bufpos >= ( con.linewidth - 1 )) + + if( IsColorString( txt )) + { + // first color string character + colorstring = true; + } + else if( colorstring ) + { + // second color string character + colorstring = false; + } + else + { + // not a color string, move char counter + charpos++; + } + + if(( bufpos >= sizeof( buf ) - 1 ) || charpos >= ( con.linewidth - 1 )) { Con_AddLine( buf, bufpos, true ); lastlength = CON_LINES_LAST().length; bufpos = 0; + charpos = 0; } break; } @@ -918,6 +940,7 @@ void Con_Print( const char *txt ) Con_AddLine( buf, bufpos, lastlength != 0 ); lastlength = 0; bufpos = 0; + charpos = 0; } // pump messages to avoid window hanging