diff options
| author | oy <Tom_Adams@web.de> | 2011-06-09 23:28:20 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-06-09 23:28:20 +0200 |
| commit | e1ef01f656fbc9e6d45450bbc8519688c51cc661 (patch) | |
| tree | 79f45de77bd38c3cdd7cdcad0f74f57b0a448133 /src/game/client | |
| parent | 69cb197f592be2cc00dfe79603d076fe2779ea55 (diff) | |
| download | zcatch-e1ef01f656fbc9e6d45450bbc8519688c51cc661.tar.gz zcatch-e1ef01f656fbc9e6d45450bbc8519688c51cc661.zip | |
made tab completion for names in chat start with the ones that match on the beginning
Diffstat (limited to 'src/game/client')
| -rw-r--r-- | src/game/client/components/chat.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index f5787483..8a456009 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -132,17 +132,28 @@ bool CChat::OnInput(IInput::CEvent Event) // find next possible name const char *pCompletionString = 0; - m_CompletionChosen = (m_CompletionChosen+1)%MAX_CLIENTS; - for(int i = 0; i < MAX_CLIENTS; ++i) + m_CompletionChosen = (m_CompletionChosen+1)%(2*MAX_CLIENTS); + for(int i = 0; i < 2*MAX_CLIENTS; ++i) { + int SearchType = ((m_CompletionChosen+i)%(2*MAX_CLIENTS))/MAX_CLIENTS; int Index = (m_CompletionChosen+i)%MAX_CLIENTS; if(!m_pClient->m_Snap.m_paPlayerInfos[Index]) continue; - if(str_find_nocase(m_pClient->m_aClients[Index].m_aName, m_aCompletionBuffer)) + bool Found = false; + if(SearchType == 1) + { + if(str_comp_nocase_num(m_pClient->m_aClients[Index].m_aName, m_aCompletionBuffer, str_length(m_aCompletionBuffer)) && + str_find_nocase(m_pClient->m_aClients[Index].m_aName, m_aCompletionBuffer)) + Found = true; + } + else if(!str_comp_nocase_num(m_pClient->m_aClients[Index].m_aName, m_aCompletionBuffer, str_length(m_aCompletionBuffer))) + Found = true; + + if(Found) { pCompletionString = m_pClient->m_aClients[Index].m_aName; - m_CompletionChosen = Index; + m_CompletionChosen = Index+SearchType*MAX_CLIENTS; break; } } |