From fd142e054ba489ecd59b0cfa8c1791149ffb5bce Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Fri, 26 Oct 2018 14:17:51 +0200 Subject: [PATCH 1/2] Fixed highlighting not being triggered when message is empty, after a colon --- src/game/client/components/chat.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index bee53754f..884cc0746 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -427,8 +427,11 @@ void CChat::AddLine(int ClientID, int Mode, const char *pLine) if(pHL) { int Length = str_length(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName); - if((pLine == pHL || pHL[-1] == ' ') && (pHL[Length] == 0 || pHL[Length] == ' ' || (pHL[Length] == ':' && pHL[Length+1] == ' '))) + if((pLine == pHL || pHL[-1] == ' ') // space or nothing before + && ((pHL[Length] == 0 || pHL[Length] == ' ') || pHL[Length] == ':' && (pHL[Length+1] == 0) || pHL[Length+1] == ' ')) // space or nothing after, allowing a colon + { Highlighted = true; + } m_CompletionFav = ClientID; } From a637c72a4023ef84cf6316f88cfedc6e97c5fec1 Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Fri, 26 Oct 2018 14:19:12 +0200 Subject: [PATCH 2/2] Do not trigger highlighting for our own messages --- src/game/client/components/chat.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 884cc0746..f133769c4 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -422,17 +422,20 @@ void CChat::AddLine(int ClientID, int Mode, const char *pLine) m_aLines[m_CurrentLine].m_Mode = Mode; m_aLines[m_CurrentLine].m_NameColor = -2; - // check for highlighted name - const char *pHL = str_find_nocase(pLine, m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName); - if(pHL) + if(ClientID != m_pClient->m_LocalClientID) // do not highlight our own messages { - int Length = str_length(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName); - if((pLine == pHL || pHL[-1] == ' ') // space or nothing before - && ((pHL[Length] == 0 || pHL[Length] == ' ') || pHL[Length] == ':' && (pHL[Length+1] == 0) || pHL[Length+1] == ' ')) // space or nothing after, allowing a colon + // check for highlighted name + const char *pHL = str_find_nocase(pLine, m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName); + if(pHL) { - Highlighted = true; + int Length = str_length(m_pClient->m_aClients[m_pClient->m_LocalClientID].m_aName); + if((pLine == pHL || pHL[-1] == ' ') // space or nothing before + && ((pHL[Length] == 0 || pHL[Length] == ' ') || pHL[Length] == ':' && (pHL[Length+1] == 0) || pHL[Length+1] == ' ')) // space or nothing after, allowing a colon + { + Highlighted = true; + } + m_CompletionFav = ClientID; } - m_CompletionFav = ClientID; } m_aLines[m_CurrentLine].m_Highlighted = Highlighted || Mode == CHAT_WHISPER;