From d12c51650837f55eb14062c7a38f85dbf944e6e4 Mon Sep 17 00:00:00 2001 From: east Date: Wed, 22 Jul 2015 15:37:00 +0200 Subject: [PATCH 1/2] fixed highlighting in demo playback --- src/game/client/components/chat.cpp | 43 +++++++++++++++++++---------- src/game/client/components/chat.h | 2 ++ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 9cb76408b..3193edf7e 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -310,6 +310,22 @@ void CChat::OnMessage(int MsgType, void *pRawMsg) } } +bool CChat::LineShouldHighlight(const char *pLine, const char *pName) +{ + const char *pHL = str_find_nocase(pLine, pName); + + if (pHL) + { + int Length = str_length(m_pClient->m_aClients[m_pClient->Client()->m_LocalIDs[0]].m_aName); + + if((pLine == pHL || pHL[-1] == ' ') && (pHL[Length] == 0 || pHL[Length] == ' ' || pHL[Length] == '.' || pHL[Length] == '!' || pHL[Length] == ',' || pHL[Length] == '?' || pHL[Length] == ':')) + return true; + + } + + return false; +} + void CChat::AddLine(int ClientID, int Team, const char *pLine) { if(*pLine == 0 || (ClientID != -1 && (m_pClient->m_aClients[ClientID].m_aName[0] == '\0' || // unknown client @@ -368,24 +384,23 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) m_aLines[m_CurrentLine].m_NameColor = -2; // check for highlighted name - const char *pHL = str_find_nocase(pLine, m_pClient->m_aClients[m_pClient->Client()->m_LocalIDs[0]].m_aName); - if(pHL) + if (Client()->State() != IClient::STATE_DEMOPLAYBACK) { - int Length = str_length(m_pClient->m_aClients[m_pClient->Client()->m_LocalIDs[0]].m_aName); - if((pLine == pHL || pHL[-1] == ' ') && (pHL[Length] == 0 || pHL[Length] == ' ' || pHL[Length] == '.' || pHL[Length] == '!' || pHL[Length] == ',' || pHL[Length] == '?' || pHL[Length] == ':')) + // main character + if (LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->Client()->m_LocalIDs[0]].m_aName)) + Highlighted = true; + // dummy + if(m_pClient->Client()->DummyConnected() && LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->Client()->m_LocalIDs[1]].m_aName)) + Highlighted = true; + } + else + { + // on demo playback use local id from snap directly, + // since m_LocalIDs isn't valid there + if (LineShouldHighlight(pLine, m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_aName)) Highlighted = true; } - if(m_pClient->Client()->DummyConnected()) - { - pHL = str_find_nocase(pLine, m_pClient->m_aClients[m_pClient->Client()->m_LocalIDs[1]].m_aName); - if(pHL) - { - int Length = str_length(m_pClient->m_aClients[m_pClient->Client()->m_LocalIDs[1]].m_aName); - if((pLine == pHL || pHL[-1] == ' ') && (pHL[Length] == 0 || pHL[Length] == ' ' || pHL[Length] == '.' || pHL[Length] == '!' || pHL[Length] == ',' || pHL[Length] == '?' || pHL[Length] == ':')) - Highlighted = true; - } - } m_aLines[m_CurrentLine].m_Highlighted = Highlighted; diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index e7ed432e1..4ce37f22e 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -71,6 +71,8 @@ class CChat : public CComponent static void ConChat(IConsole::IResult *pResult, void *pUserData); static void ConShowChat(IConsole::IResult *pResult, void *pUserData); + bool LineShouldHighlight(const char *pLine, const char *pName); + public: CChat(); From 63cfc090178df31e3672919087e0dfa42fcd6e82 Mon Sep 17 00:00:00 2001 From: east Date: Wed, 22 Jul 2015 15:37:59 +0200 Subject: [PATCH 2/2] make add_demomarker working in all recorders --- src/engine/client/client.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 0f651bf10..b1740f5ad 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -3129,6 +3129,8 @@ void CClient::Con_AddDemoMarker(IConsole::IResult *pResult, void *pUserData) { CClient *pSelf = (CClient *)pUserData; pSelf->DemoRecorder_AddDemoMarker(RECORDER_MANUAL); + pSelf->DemoRecorder_AddDemoMarker(RECORDER_RACE); + pSelf->DemoRecorder_AddDemoMarker(RECORDER_AUTO); } void CClient::ServerBrowserUpdate()