From 0f004824c2b380d3477aaaf36d0049d488816866 Mon Sep 17 00:00:00 2001 From: Ben Millwood Date: Sat, 3 Oct 2009 11:48:57 +0000 Subject: * Experimental fix for the colour wrapping fail --- src/game/g_local.h | 1 + src/ui/ui_shared.c | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/game/g_local.h b/src/game/g_local.h index ab6d82f0..49a5ceac 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -655,6 +655,7 @@ char *G_NewString( const char *string ); // g_cmds.c // void G_StopFollowing( gentity_t *ent ); +void G_StopFromFollowing( gentity_t *ent ); void G_FollowLockView( gentity_t *ent ); qboolean G_FollowNewClient( gentity_t *ent, int dir ); void G_ToggleFollow( gentity_t *ent ); diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c index 027ca75a..e708c9bb 100644 --- a/src/ui/ui_shared.c +++ b/src/ui/ui_shared.c @@ -4541,7 +4541,7 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width ) { 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; @@ -4557,7 +4557,8 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width ) while( *p ) { - Com_Memset( c, 0, sizeof( c ) ); + Com_Memset( startcolour, 0, sizeof( startcolour ) ); + Com_Memset( endcolour, 0, sizeof( endcolour ) ); // Skip leading whitespace @@ -4565,8 +4566,8 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width ) { 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 ) ) @@ -4586,8 +4587,8 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width ) while( Q_IsColorString( q ) ) { - c[ 0 ] = q[ 0 ]; - c[ 1 ] = q[ 1 ]; + startcolour[ 0 ] = q[ 0 ]; + startcolour[ 1 ] = q[ 1 ]; q += 2; } @@ -4595,8 +4596,8 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width ) while( Q_IsColorString( q ) ) { - c[ 0 ] = q[ 0 ]; - c[ 1 ] = q[ 1 ]; + startcolour[ 0 ] = q[ 0 ]; + startcolour[ 1 ] = q[ 1 ]; q += 2; } @@ -4616,8 +4617,8 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width ) // 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 ) ) @@ -4636,8 +4637,8 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width ) // 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 ) ) @@ -4665,6 +4666,9 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width ) if( eol == p ) eol = q; + // Add colour code (might be empty) + Q_strcat( out, sizeof( out ), startcolour ); + paint = out + strlen( out ); // Copy text @@ -4676,7 +4680,7 @@ static const char *Item_Text_Wrap( const char *text, float scale, float width ) 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 ); -- cgit