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

View File

@@ -754,6 +754,7 @@ void CUser::JoinChans() {
// still be able to join the rest of your channels.
unsigned int start = rand() % m_vChans.size();
unsigned int uJoins = m_uMaxJoins;
set<CChan*> sChans;
for (unsigned int a = 0; a < m_vChans.size(); a++) {
unsigned int idx = (start + a) % m_vChans.size();
CChan* pChan = m_vChans[idx];
@@ -761,11 +762,18 @@ void CUser::JoinChans() {
if (!JoinChan(pChan))
continue;
sChans.insert(pChan);
// Limit the number of joins
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) {
@@ -775,8 +783,6 @@ bool CUser::JoinChan(CChan* pChan) {
} else {
pChan->IncJoinTries();
MODULECALL(OnTimerAutoJoin(*pChan), this, NULL, return false);
PutIRC("JOIN " + pChan->GetName() + " " + pChan->GetKey());
return true;
}
return false;

3
User.h
View File

@@ -53,7 +53,6 @@ public:
bool AddChan(const CString& sName, bool bInConfig);
bool DelChan(const CString& sName);
void JoinChans();
bool JoinChan(CChan* pChan);
CServer* FindServer(const CString& sName) const;
bool DelServer(const CString& sName, unsigned short uPort, const CString& sPass);
bool AddServer(const CString& sName);
@@ -224,6 +223,8 @@ public:
CString GetSkinName() const;
// !Getters
private:
bool JoinChan(CChan* pChan);
protected:
CString m_sUserName;
CString m_sCleanUserName;