From b8b2401bc3323790bad8a6b8d2c17d68402065a9 Mon Sep 17 00:00:00 2001 From: divverent Date: Tue, 30 Dec 2008 08:30:17 +0000 Subject: [PATCH] fix two bugs in handling of invalid ^xRGB codes git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8615 d7cf8633-e32d-0410-b094-e92efae38249 --- common.c | 7 ++++++- console.c | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/common.c b/common.c index aac01fba..18affb8d 100644 --- a/common.c +++ b/common.c @@ -1835,7 +1835,7 @@ for example). If the output buffer size did not suffice for converting, the function returns FALSE. Generally, if escape_carets is false, the output buffer needs -strlen(str)+1 bytes, and if escape_carets is true, it can need strlen(str)+2 +strlen(str)+1 bytes, and if escape_carets is true, it can need strlen(str)*1.5+2 bytes. In any case, the function makes sure that the resulting string is zero terminated. @@ -1869,6 +1869,11 @@ COM_StringDecolorize(const char *in, size_t size_in, char *out, size_t size_out, in+=3; break; } + APPEND(STRING_COLOR_TAG); + if(escape_carets) + APPEND(STRING_COLOR_TAG); + APPEND(STRING_COLOR_RGB_DEFAULT); + break; /*case 'a': if ( in+1 != end && ( isxdigit(in[1]) || (in[1] == '+' || in[1] == '-') ) ) { diff --git a/console.c b/console.c index 421e0379..4d9b71b8 100644 --- a/console.c +++ b/console.c @@ -1167,6 +1167,10 @@ void Con_Print(const char *msg) in+=4; break; } + *out++ = STRING_COLOR_TAG; + *out++ = STRING_COLOR_RGB_DEFAULT; + ++in; + break; /*case 'a': if ( isxdigit(in[2]) || in[2] == '+' || in[2] == '-' ) { @@ -2344,11 +2348,13 @@ int Nicks_AddLastColor(char *buffer, int pos) else if(buffer[match+1] == STRING_COLOR_RGB_DEFAULT) { if ( isxdigit(buffer[match+2]) && isxdigit(buffer[match+3]) && isxdigit(buffer[match+4]) ) + { r = buffer[match+2]; g = buffer[match+3]; b = buffer[match+4]; color = -1; break; + } } } } -- 2.39.2