From ec0d52e675e7aecd1185149847643c6ed3c15acd Mon Sep 17 00:00:00 2001 From: psychon Date: Sun, 7 Mar 2010 13:16:17 +0000 Subject: [PATCH] Split up CIRCSock::ForwardRaw353() into two function, one which is per-client git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1810 726aef4b-f618-498e-8847-2d620e286838 --- IRCSock.cpp | 70 +++++++++++++++++++++++++++++------------------------ IRCSock.h | 2 ++ 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/IRCSock.cpp b/IRCSock.cpp index 34ca5b67..8d19d1bf 100644 --- a/IRCSock.cpp +++ b/IRCSock.cpp @@ -988,48 +988,54 @@ void CIRCSock::ParseISupport(const CString& sLine) { void CIRCSock::ForwardRaw353(const CString& sLine) const { vector& vClients = m_pUser->GetClients(); + vector::iterator it; + + for (it = vClients.begin(); it != vClients.end(); ++it) { + ForwardRaw353(sLine, *it); + } +} + +void CIRCSock::ForwardRaw353(const CString& sLine, CClient* pClient) const { CString sNicks = sLine.Token(5, true); if (sNicks.Left(1) == ":") sNicks.LeftChomp(); - for (unsigned int a = 0; a < vClients.size(); a++) { - if ((!m_bNamesx || vClients[a]->HasNamesx()) && (!m_bUHNames || vClients[a]->HasUHNames())) { - // Client and server have both the same UHNames and Namesx stuff enabled - m_pUser->PutUser(sLine, vClients[a]); - } else { - // Get everything except the actual user list - CString sTmp = sLine.Token(0, false, " :") + " :"; + if ((!m_bNamesx || pClient->HasNamesx()) && (!m_bUHNames || pClient->HasUHNames())) { + // Client and server have both the same UHNames and Namesx stuff enabled + m_pUser->PutUser(sLine, pClient); + } else { + // Get everything except the actual user list + CString sTmp = sLine.Token(0, false, " :") + " :"; - VCString vsNicks; - VCString::const_iterator it; + VCString vsNicks; + VCString::const_iterator it; - // This loop runs once for every nick on the channel - sNicks.Split(" ", vsNicks, false); - for (it = vsNicks.begin(); it != vsNicks.end(); ++it) { - CString sNick = *it; - if (sNick.empty()) - break; + // This loop runs once for every nick on the channel + sNicks.Split(" ", vsNicks, false); + for (it = vsNicks.begin(); it != vsNicks.end(); ++it) { + CString sNick = *it; + if (sNick.empty()) + break; - if (m_bNamesx && !vClients[a]->HasNamesx() && IsPermChar(sNick[0])) { - // Server has, client doesn't have NAMESX, so we just use the first perm char - size_t pos = sNick.find_first_not_of(GetPerms()); - if (pos >= 2 && pos != CString::npos) { - sNick = sNick[0] + sNick.substr(pos); - } + if (m_bNamesx && !pClient->HasNamesx() && IsPermChar(sNick[0])) { + // Server has, client doesn't have NAMESX, so we just use the first perm char + size_t pos = sNick.find_first_not_of(GetPerms()); + if (pos >= 2 && pos != CString::npos) { + sNick = sNick[0] + sNick.substr(pos); } - - if (m_bUHNames && !vClients[a]->HasUHNames()) { - // Server has, client hasnt UHNAMES, - // so we strip away ident and host. - sNick = sNick.Token(0, false, "!"); - } - - sTmp += sNick + " "; } - // Strip away the spaces we inserted at the end - sTmp.TrimRight(" "); - m_pUser->PutUser(sTmp, vClients[a]); + + if (m_bUHNames && !pClient->HasUHNames()) { + // Server has, client hasnt UHNAMES, + // so we strip away ident and host. + sNick = sNick.Token(0, false, "!"); + } + + sTmp += sNick + " "; } + // Strip away the spaces we inserted at the end + sTmp.TrimRight(" "); + m_pUser->PutUser(sTmp, pClient); } } diff --git a/IRCSock.h b/IRCSock.h index eaa97c69..e86caab0 100644 --- a/IRCSock.h +++ b/IRCSock.h @@ -15,6 +15,7 @@ // Forward Declarations class CChan; class CUser; +class CClient; // !Forward Declarations class CIRCSock : public CZNCSock { @@ -79,6 +80,7 @@ private: void SetNick(const CString& sNick); void ParseISupport(const CString& sLine); void ForwardRaw353(const CString& sLine) const; + void ForwardRaw353(const CString& sLine, CClient* pClient) const; // This is called when we connect and the nick we want is already taken void SendAltNick(const CString& sBadNick); protected: