restore non styled chat size check

This commit is contained in:
DrPerkyLegit 2026-04-10 18:36:14 -04:00
parent 7eef3b6069
commit 15989a9ef6

View file

@ -17,29 +17,6 @@ bool ChatScreen::isAllowedChatChar(wchar_t c)
return c >= 0x20 && (c == L'\u00A7' || allowedChars.empty() || allowedChars.find(c) != wstring::npos);
}
int VisibleCharLength(wstring message) {
static std::unordered_set<wchar_t> validStyleCharacters = {
L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7', L'8', L'9',
L'a', L'b', L'c', L'd', L'e', L'f',
};
int results = 0;
for (int i = 0; i < message.size(); i++) {
wchar_t _char = message[i];
if (_char == L'§' && (i + 1) < message.size()) {
wchar_t colorChar = message[i + 1];
if (validStyleCharacters.find(colorChar) != validStyleCharacters.end()) {
i++; //do this so it increments 2 instead of 1
continue;
}
}
results++;
}
return results;
}
ChatScreen::ChatScreen()
{
frame = 0;
@ -154,7 +131,7 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey)
cursorIndex--;
return;
}
if (isAllowedChatChar(ch) && VisibleCharLength(message) < SharedConstants::maxVisibleLength)
if (isAllowedChatChar(ch) && static_cast<int>(message.length()) < SharedConstants::maxVisibleLength)
{
message.insert(cursorIndex, 1, ch);
cursorIndex++;