diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 4812144e1..b27726076 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -40,6 +40,7 @@ void CChat::OnReset() m_InputUpdate = false; m_ChatStringOffset = 0; m_CompletionChosen = -1; + m_CompletionFav = -1; m_aCompletionBuffer[0] = 0; m_PlaceholderOffset = 0; m_PlaceholderLength = 0; @@ -156,10 +157,15 @@ bool CChat::OnInput(IInput::CEvent Event) // find next possible name const char *pCompletionString = 0; - if(m_ReverseCompletion) - m_CompletionChosen = (m_CompletionChosen-1 + 2*MAX_CLIENTS)%(2*MAX_CLIENTS); + if(m_CompletionChosen < 0 && m_CompletionFav >= 0) + m_CompletionChosen = m_CompletionFav; else - m_CompletionChosen = (m_CompletionChosen+1)%(2*MAX_CLIENTS); + { + if (m_ReverseCompletion) + m_CompletionChosen = (m_CompletionChosen - 1 + 2 * MAX_CLIENTS) % (2 * MAX_CLIENTS); + else + m_CompletionChosen = (m_CompletionChosen + 1) % (2 * MAX_CLIENTS); + } for(int i = 0; i < 2*MAX_CLIENTS; ++i) { @@ -194,6 +200,7 @@ bool CChat::OnInput(IInput::CEvent Event) { pCompletionString = m_pClient->m_aClients[Index].m_aName; m_CompletionChosen = Index+SearchType*MAX_CLIENTS; + m_CompletionFav = m_CompletionChosen; break; } } @@ -367,6 +374,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) 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] == ' '))) Highlighted = true; + m_CompletionFav = ClientID; } m_aLines[m_CurrentLine].m_Highlighted = Highlighted; diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index 8be2b2219..c23647af9 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -49,6 +49,7 @@ class CChat : public CComponent int m_ChatStringOffset; int m_OldChatStringLength; int m_CompletionChosen; + int m_CompletionFav; char m_aCompletionBuffer[256]; int m_PlaceholderOffset; int m_PlaceholderLength;