From dce6d4f0ea99567c46d54ede312091da3a46d4fc Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 12 Sep 2015 19:24:29 +0200 Subject: [PATCH] Make CClient::PutClient() handle multi-prefix --- src/Client.cpp | 15 ++++++++++++++- src/IRCSock.cpp | 25 ------------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/Client.cpp b/src/Client.cpp index 69273789..2e0220bc 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -764,7 +764,20 @@ bool CClient::PutClient(const CMessage& Message) if (Msg.GetType() == CMessage::Type::Numeric) { unsigned int uCode = static_cast(Msg).GetCode(); - if (uCode == 353) { // RPL_NAMES + if (uCode == 352) { // RPL_WHOREPLY + if (!m_bNamesx && pIRCSock->HasNamesx()) { + // The server has NAMESX, but the client doesn't, so we need to remove extra prefixes + CString sNick = Msg.GetParam(6); + if (sNick.size() > 1 && pIRCSock->IsPermChar(sNick[1])) { + CString sNewNick = sNick; + size_t pos = sNick.find_first_not_of(pIRCSock->GetPerms()); + if (pos >= 2 && pos != CString::npos) { + sNewNick = sNick[0] + sNick.substr(pos); + } + Msg.SetParam(6, sNewNick); + } + } + } else if (uCode == 353) { // RPL_NAMES if ((!m_bNamesx && pIRCSock->HasNamesx()) || (!m_bUHNames && pIRCSock->HasUHNames())) { // The server has either UHNAMES or NAMESX, but the client is missing either or both CString sNicks = Msg.GetParam(3); diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 10c2e431..18935b8e 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -811,31 +811,6 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) { pChan->OnWho(sNick, sIdent, sHost); } - if (m_bNamesx && (sNick.size() > 1) && IsPermChar(sNick[1])) { - // sLine uses multi-prefix - - const vector& vClients = m_pNetwork->GetClients(); - for (CClient* pClient : vClients) { - if (pClient->HasNamesx()) { - m_pNetwork->PutUser(Message, pClient); - } else { - // The client doesn't support multi-prefix so we need to remove - // the other prefixes. - - CString sNewNick = sNick; - size_t pos = sNick.find_first_not_of(GetPerms()); - if (pos >= 2 && pos != CString::npos) { - sNewNick = sNick[0] + sNick.substr(pos); - } - CMessage WhoMsg(Message); - WhoMsg.SetParam(5, sNewNick); - m_pNetwork->PutUser(WhoMsg, pClient); - } - } - - return true; - } - CChan* pChan = m_pNetwork->FindChan(sChan); if (pChan && pChan->IsDetached()) { return true;