JoinChans(): Join channels in a semi random number

Now ZNC doesn't try to join the first, then the second etc channel, but instead
it will start at a random channel and go on from there.

This fixes a bug if you got e.g. MaxJoins = 5 and your first five channels are
invite-only. Without this, ZNC would never try to join any of the other
channels. With this patch applied, it will sooner or later try to join the other
channels, too. (I'd guess more sooner than later)


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1602 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-08-17 20:00:09 +00:00
parent 6782ba987e
commit 88897381da
+6 -1
View File
@@ -704,9 +704,14 @@ CChan* CUser::FindChan(const CString& sName) const {
}
void CUser::JoinChans() {
// We start at a random offset into the channel list so that if your
// first 3 channels are invite-only and you got MaxJoins == 3, ZNC will
// still be able to join the rest of your channels.
unsigned int start = rand() % m_vChans.size();
unsigned int uJoins = m_uMaxJoins;
for (unsigned int a = 0; a < m_vChans.size(); a++) {
CChan* pChan = m_vChans[a];
unsigned int idx = (start + a) % m_vChans.size();
CChan* pChan = m_vChans[idx];
if (!pChan->IsOn() && !pChan->IsDisabled()) {
if (!JoinChan(pChan))
continue;