diff --git a/Chan.cpp b/Chan.cpp index 6974efbe..050ab200 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -86,30 +86,42 @@ void CChan::JoinUser(bool bForce, const CString& sKey, CClient* pClient) { CString sLine = sPre; CString sPerm, sNick; - for (map::iterator a = m_msNicks.begin(); a != m_msNicks.end(); a++) { - if(pClient->HasNamesx()) { - sPerm = a->second->GetPermStr(); - } else { - char c = a->second->GetPermChar(); - sPerm = ""; - if (c != '\0') { - sPerm += c; + vector& vpClients = m_pUser->GetClients(); + for (vector::iterator it = vpClients.begin(); it != vpClients.end(); it++) { + CClient* pThisClient; + if (!pClient) + pThisClient = *it; + else + pThisClient = pClient; + + for (map::iterator a = m_msNicks.begin(); a != m_msNicks.end(); a++) { + if(pThisClient->HasNamesx()) { + sPerm = a->second->GetPermStr(); + } else { + char c = a->second->GetPermChar(); + sPerm = ""; + if (c != '\0') { + sPerm += c; + } + } + if(pThisClient->HasUHNames() && !a->second->GetIdent().empty() && a->second->GetHost().empty()) { + sNick = a->first + "!" + a->second->GetIdent() + "@" + a->second->GetHost(); + } else { + sNick = a->first; + } + + sLine += sPerm + sNick; + + if (sLine.size() >= 490 || a == (--m_msNicks.end())) { + m_pUser->PutUser(sLine, pThisClient); + sLine = sPre; + } else { + sLine += " "; } } - if(pClient->HasUHNames() && !a->second->GetIdent().empty() && a->second->GetHost().empty()) { - sNick = a->first + "!" + a->second->GetIdent() + "@" + a->second->GetHost(); - } else { - sNick = a->first; - } - sLine += sPerm + sNick; - - if (sLine.size() >= 490 || a == (--m_msNicks.end())) { - m_pUser->PutUser(sLine, pClient); - sLine = sPre; - } else { - sLine += " "; - } + if (pClient) // We only want to do this for one client + break; } m_pUser->PutUser(":" + m_pUser->GetIRCServer() + " 366 " + m_pUser->GetIRCNick().GetNick() + " " + GetName() + " :End of /NAMES list.", pClient); diff --git a/Client.cpp b/Client.cpp index c1c70c93..3d77eaab 100644 --- a/Client.cpp +++ b/Client.cpp @@ -574,7 +574,8 @@ void CClient::UserCommand(const CString& sLine) { } const map& msNicks = pChan->GetNicks(); - const CString& sPerms = m_pUser->GetIRCSock()->GetPerms(); + CIRCSock* pIRCSock = (!m_pUser) ? NULL : m_pUser->GetIRCSock(); + const CString& sPerms = (pIRCSock) ? pIRCSock->GetPerms() : ""; if (!msNicks.size()) { PutStatus("No nicks on [" + sChan + "]"); @@ -763,7 +764,8 @@ void CClient::UserCommand(const CString& sLine) { } else if (sCommand.CaseCmp("LISTCHANS") == 0) { if (m_pUser) { const vector& vChans = m_pUser->GetChans(); - const CString& sPerms = m_pUser->GetIRCSock()->GetPerms(); + CIRCSock* pIRCSock = (!m_pUser) ? NULL : m_pUser->GetIRCSock(); + const CString& sPerms = (pIRCSock) ? pIRCSock->GetPerms() : ""; if (!vChans.size()) { PutStatus("You have no channels defined"); diff --git a/Nick.cpp b/Nick.cpp index 42ff1984..89669b3a 100644 --- a/Nick.cpp +++ b/Nick.cpp @@ -102,7 +102,8 @@ bool CNick::RemPerm(unsigned char uPerm) { } void CNick::UpdatePermChar() { - const CString& sChanPerms = (!m_pUser) ? "@+" : m_pUser->GetIRCSock()->GetPerms(); + CIRCSock* pIRCSock = (!m_pUser) ? NULL : m_pUser->GetIRCSock(); + const CString& sChanPerms = (!pIRCSock) ? "@+" : pIRCSock->GetPerms(); m_cPerm = 0; for (unsigned int a = 0; a < sChanPerms.size(); a++) {