From 6782ba987e355b01f59eb62f4e5c18c20c454e35 Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 17 Aug 2009 18:49:39 +0000 Subject: [PATCH] Split up CUser::JoinChans() This adds CUser::JoinChan() as a helper function git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1601 726aef4b-f618-498e-8847-2d620e286838 --- User.cpp | 31 +++++++++++++++++++------------ User.h | 1 + 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/User.cpp b/User.cpp index cecf2554..24f4cf4e 100644 --- a/User.cpp +++ b/User.cpp @@ -708,23 +708,30 @@ void CUser::JoinChans() { for (unsigned int a = 0; a < m_vChans.size(); a++) { CChan* pChan = m_vChans[a]; if (!pChan->IsOn() && !pChan->IsDisabled()) { - if (JoinTries() != 0 && pChan->GetJoinTries() >= JoinTries()) { - PutStatus("The channel " + pChan->GetName() + " could not be joined, disabling it."); - pChan->Disable(); - } else { - pChan->IncJoinTries(); - MODULECALL(OnTimerAutoJoin(*pChan), this, NULL, continue); + if (!JoinChan(pChan)) + continue; - PutIRC("JOIN " + pChan->GetName() + " " + pChan->GetKey()); - - // Limit the number of joins - if (uJoins != 0 && --uJoins == 0) - return; - } + // Limit the number of joins + if (uJoins != 0 && --uJoins == 0) + return; } } } +bool CUser::JoinChan(CChan* pChan) { + if (JoinTries() != 0 && pChan->GetJoinTries() >= JoinTries()) { + PutStatus("The channel " + pChan->GetName() + " could not be joined, disabling it."); + pChan->Disable(); + } else { + pChan->IncJoinTries(); + MODULECALL(OnTimerAutoJoin(*pChan), this, NULL, return false); + + PutIRC("JOIN " + pChan->GetName() + " " + pChan->GetKey()); + return true; + } + return false; +} + CServer* CUser::FindServer(const CString& sName) const { for (unsigned int a = 0; a < m_vServers.size(); a++) { CServer* pServer = m_vServers[a]; diff --git a/User.h b/User.h index 3ad6cc29..862021a1 100644 --- a/User.h +++ b/User.h @@ -42,6 +42,7 @@ 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); bool AddServer(const CString& sName);