Merge pull request #237 from XLabsProject/fix-chat-crash
Fix chat crash (Client side only)
This commit is contained in:
commit
404392a9fa
@ -55,16 +55,16 @@ namespace Components
|
|||||||
push eax
|
push eax
|
||||||
pushad
|
pushad
|
||||||
|
|
||||||
push[esp + 100h + 28h]
|
push [esp + 100h + 28h]
|
||||||
push eax
|
push eax
|
||||||
call Chat::EvaluateSay
|
call Chat::EvaluateSay
|
||||||
add esp, 8h
|
add esp, 8h
|
||||||
|
|
||||||
mov[esp + 20h], eax
|
mov [esp + 20h], eax
|
||||||
popad
|
popad
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
mov[esp + 100h + 10h], eax
|
mov [esp + 100h + 10h], eax
|
||||||
|
|
||||||
jmp PlayerName::CleanStrStub
|
jmp PlayerName::CleanStrStub
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ namespace Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Chat::CheckChatLineEnd(const char*& inputBuffer, char*& lineBuffer, float& len, const int chatHeight, const float chatWidth, char*& lastSpacePos, char*& lastFontIconPos, const int lastColor)
|
void Chat::CheckChatLineEnd(const char*& inputBuffer, char*& lineBuffer, float& len, const int chatHeight, const float chatWidth, char*& lastSpacePos, char*& lastFontIconPos, const int lastColor)
|
||||||
{
|
{
|
||||||
if (len > chatWidth)
|
if (len > chatWidth)
|
||||||
{
|
{
|
||||||
if (lastSpacePos && lastSpacePos > lastFontIconPos)
|
if (lastSpacePos && lastSpacePos > lastFontIconPos)
|
||||||
@ -110,6 +110,7 @@ namespace Components
|
|||||||
inputBuffer += lastFontIconPos - lineBuffer;
|
inputBuffer += lastFontIconPos - lineBuffer;
|
||||||
lineBuffer = lastFontIconPos;
|
lineBuffer = lastFontIconPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
*lineBuffer = 0;
|
*lineBuffer = 0;
|
||||||
len = 0.0f;
|
len = 0.0f;
|
||||||
Game::cgsArray[0].teamChatMsgTimes[Game::cgsArray[0].teamChatPos % chatHeight] = Game::cgArray[0].time;
|
Game::cgsArray[0].teamChatMsgTimes[Game::cgsArray[0].teamChatPos % chatHeight] = Game::cgArray[0].time;
|
||||||
@ -122,7 +123,7 @@ namespace Components
|
|||||||
lastSpacePos = nullptr;
|
lastSpacePos = nullptr;
|
||||||
lastFontIconPos = nullptr;
|
lastFontIconPos = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chat::CG_AddToTeamChat(const char* text)
|
void Chat::CG_AddToTeamChat(const char* text)
|
||||||
{
|
{
|
||||||
@ -132,7 +133,7 @@ namespace Components
|
|||||||
const auto chatHeight = (*cg_chatHeight)->current.integer;
|
const auto chatHeight = (*cg_chatHeight)->current.integer;
|
||||||
const auto chatWidth = static_cast<float>(cg_chatWidth.get<int>());
|
const auto chatWidth = static_cast<float>(cg_chatWidth.get<int>());
|
||||||
const auto chatTime = (*cg_chatTime)->current.integer;
|
const auto chatTime = (*cg_chatTime)->current.integer;
|
||||||
if (chatHeight < 0 || static_cast<unsigned>(chatHeight) > std::extent_v<decltype(Game::cgs_t::teamChatMsgs)> || chatWidth <= 0 || chatTime <= 0)
|
if (chatHeight <= 0 || static_cast<unsigned>(chatHeight) > std::extent_v<decltype(Game::cgs_t::teamChatMsgs)> || chatWidth <= 0 || chatTime <= 0)
|
||||||
{
|
{
|
||||||
Game::cgsArray[0].teamLastChatPos = 0;
|
Game::cgsArray[0].teamLastChatPos = 0;
|
||||||
Game::cgsArray[0].teamChatPos = 0;
|
Game::cgsArray[0].teamChatPos = 0;
|
||||||
@ -152,7 +153,7 @@ namespace Components
|
|||||||
CheckChatLineEnd(text, p, len, chatHeight, chatWidth, lastSpace, lastFontIcon, lastColor);
|
CheckChatLineEnd(text, p, len, chatHeight, chatWidth, lastSpace, lastFontIcon, lastColor);
|
||||||
|
|
||||||
const char* fontIconEndPos = &text[1];
|
const char* fontIconEndPos = &text[1];
|
||||||
if(text[0] == TextRenderer::FONT_ICON_SEPARATOR_CHARACTER && TextRenderer::IsFontIcon(fontIconEndPos, fontIconInfo))
|
if (text[0] == TextRenderer::FONT_ICON_SEPARATOR_CHARACTER && TextRenderer::IsFontIcon(fontIconEndPos, fontIconInfo))
|
||||||
{
|
{
|
||||||
// The game calculates width on a per character base. Since the width of a font icon is calculated based on the height of the font
|
// The game calculates width on a per character base. Since the width of a font icon is calculated based on the height of the font
|
||||||
// which is roughly double as much as the average width of a character without an additional multiplier the calculated len of the font icon
|
// which is roughly double as much as the average width of a character without an additional multiplier the calculated len of the font icon
|
||||||
|
Loading…
x
Reference in New Issue
Block a user