mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 01:21:17 +00:00
- 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.
This commit is contained in:
parent
405ece578a
commit
2887bc6afc
1 changed files with 2 additions and 6 deletions
|
@ -76,7 +76,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<uint8_t> ChatQueue;
|
||||
|
||||
CVAR (String, chatmacro1, "I'm ready to kick butt!", CVAR_ARCHIVE)
|
||||
|
@ -116,7 +115,6 @@ CVAR (Bool, chat_substitution, false, CVAR_ARCHIVE)
|
|||
void CT_Init ()
|
||||
{
|
||||
ChatQueue.Clear();
|
||||
CharLen = 0;
|
||||
chatmodeon = 0;
|
||||
}
|
||||
|
||||
|
@ -295,7 +293,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);
|
||||
|
@ -305,7 +303,6 @@ static void CT_AddChar (int c)
|
|||
{
|
||||
ChatQueue.Push(encode[i]);
|
||||
}
|
||||
CharLen++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -319,12 +316,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--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue