Change the way CUser::JoinChans() works

Hopefully you'll soon see why I did this.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2181 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-11-15 20:34:36 +00:00
parent 1baa019705
commit 3327a974fe
2 changed files with 11 additions and 4 deletions
+9 -3
View File
@@ -754,6 +754,7 @@ void CUser::JoinChans() {
// still be able to join the rest of your channels. // still be able to join the rest of your channels.
unsigned int start = rand() % m_vChans.size(); unsigned int start = rand() % m_vChans.size();
unsigned int uJoins = m_uMaxJoins; unsigned int uJoins = m_uMaxJoins;
set<CChan*> sChans;
for (unsigned int a = 0; a < m_vChans.size(); a++) { for (unsigned int a = 0; a < m_vChans.size(); a++) {
unsigned int idx = (start + a) % m_vChans.size(); unsigned int idx = (start + a) % m_vChans.size();
CChan* pChan = m_vChans[idx]; CChan* pChan = m_vChans[idx];
@@ -761,11 +762,18 @@ void CUser::JoinChans() {
if (!JoinChan(pChan)) if (!JoinChan(pChan))
continue; continue;
sChans.insert(pChan);
// Limit the number of joins // Limit the number of joins
if (uJoins != 0 && --uJoins == 0) if (uJoins != 0 && --uJoins == 0)
return; break;
} }
} }
for (set<CChan*>::iterator it = sChans.begin();
it != sChans.end(); ++it) {
PutIRC("JOIN " + (*it)->GetName() + " " + (*it)->GetKey());
}
} }
bool CUser::JoinChan(CChan* pChan) { bool CUser::JoinChan(CChan* pChan) {
@@ -775,8 +783,6 @@ bool CUser::JoinChan(CChan* pChan) {
} else { } else {
pChan->IncJoinTries(); pChan->IncJoinTries();
MODULECALL(OnTimerAutoJoin(*pChan), this, NULL, return false); MODULECALL(OnTimerAutoJoin(*pChan), this, NULL, return false);
PutIRC("JOIN " + pChan->GetName() + " " + pChan->GetKey());
return true; return true;
} }
return false; return false;
+2 -1
View File
@@ -53,7 +53,6 @@ public:
bool AddChan(const CString& sName, bool bInConfig); bool AddChan(const CString& sName, bool bInConfig);
bool DelChan(const CString& sName); bool DelChan(const CString& sName);
void JoinChans(); void JoinChans();
bool JoinChan(CChan* pChan);
CServer* FindServer(const CString& sName) const; CServer* FindServer(const CString& sName) const;
bool DelServer(const CString& sName, unsigned short uPort, const CString& sPass); bool DelServer(const CString& sName, unsigned short uPort, const CString& sPass);
bool AddServer(const CString& sName); bool AddServer(const CString& sName);
@@ -224,6 +223,8 @@ public:
CString GetSkinName() const; CString GetSkinName() const;
// !Getters // !Getters
private: private:
bool JoinChan(CChan* pChan);
protected: protected:
CString m_sUserName; CString m_sUserName;
CString m_sCleanUserName; CString m_sCleanUserName;