mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 13:11:33 +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
ac9133eda0
commit
0837178518
1 changed files with 2 additions and 6 deletions
|
@ -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<uint8_t> 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--;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue