From 083717851817e2e2e3aa5171c00075c0980e782a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Apr 2019 08:27:31 +0200 Subject: [PATCH] - do proper checks for chat string length. The counter variable was not only used incorrectly, it was completely redundant. This still has a byte limit due to how the network code works so for non-Latin languages may result in shorter strings. --- src/ct_chat.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/ct_chat.cpp b/src/ct_chat.cpp index e73c64c77..d3aa44810 100644 --- a/src/ct_chat.cpp +++ b/src/ct_chat.cpp @@ -73,7 +73,6 @@ static void CT_BackSpace (); static void ShoveChatStr (const char *str, uint8_t who); static bool DoSubstitution (FString &out, const char *in); -static int CharLen; static TArray ChatQueue; CVAR (String, chatmacro1, "I'm ready to kick butt!", CVAR_ARCHIVE) @@ -113,7 +112,6 @@ CVAR (Bool, chat_substitution, false, CVAR_ARCHIVE) void CT_Init () { ChatQueue.Clear(); - CharLen = 0; chatmodeon = 0; } @@ -290,7 +288,7 @@ void CT_Drawer (void) static void CT_AddChar (int c) { - if (CharLen < QUEUESIZE-2) + if (ChatQueue.Size() < QUEUESIZE-2) { int size; auto encode = MakeUTF8(c, &size); @@ -300,7 +298,6 @@ static void CT_AddChar (int c) { ChatQueue.Push(encode[i]); } - CharLen++; } } } @@ -314,12 +311,11 @@ static void CT_AddChar (int c) static void CT_BackSpace () { - if (CharLen) + if (ChatQueue.Size()) { int endpos = ChatQueue.Size() - 1; while (endpos > 0 && ChatQueue[endpos] >= 0x80 && ChatQueue[endpos] < 0xc0) endpos--; ChatQueue.Clamp(endpos); - CharLen--; } }