From 3bd94b9adab8cea7fe3705beb0f9f734d3d5297b Mon Sep 17 00:00:00 2001 From: Learath2 Date: Sun, 12 Mar 2017 22:32:05 +0100 Subject: [PATCH] Forgot m_Friend isn't initialized, also align the messages --- src/game/client/components/chat.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index efa47e3f2..797363cd6 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -545,6 +545,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) m_aLines[m_CurrentLine].m_Friend = m_pClient->m_aClients[ClientID].m_Friend; } + m_aLines[m_CurrentLine].m_Friend = ClientID >= 0 ? m_pClient->m_aClients[ClientID].m_Friend : false; char aBuf[1024]; str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText); @@ -744,11 +745,19 @@ void CChat::OnRender() TextRender()->SetCursor(&Cursor, Begin, y, FontSize, TEXTFLAG_RENDER); Cursor.m_LineWidth = LineWidth; - if(g_Config.m_ClMessageFriend && m_aLines[r].m_Friend) + if(g_Config.m_ClMessageFriend) { - vec3 rgb = HslToRgb(vec3(g_Config.m_ClMessageFriendHue / 255.0f, g_Config.m_ClMessageFriendSat / 255.0f, g_Config.m_ClMessageFriendLht / 255.0f)); - TextRender()->TextColor(rgb.r, rgb.g, rgb.b, Blend); - TextRender()->TextEx(&Cursor, "♥ ", -1); + if(m_aLines[r].m_Friend) + { + vec3 rgb = HslToRgb(vec3(g_Config.m_ClMessageFriendHue / 255.0f, g_Config.m_ClMessageFriendSat / 255.0f, g_Config.m_ClMessageFriendLht / 255.0f)); + TextRender()->TextColor(rgb.r, rgb.g, rgb.b, Blend); + TextRender()->TextEx(&Cursor, "♥ ", -1); + } + else // Ugly hack to align messages + { + float tw = TextRender()->TextWidth(0, FontSize, "♥ ", -1); + Cursor.m_X += tw; + } } // render name