diff --git a/Chan.cpp b/Chan.cpp index 3dd59d50..3063b0b4 100644 --- a/Chan.cpp +++ b/Chan.cpp @@ -72,7 +72,27 @@ bool CChan::WriteConfig(CFile& File) { return true; } -void CChan::Joined() { +void CChan::Clone(CChan& chan) { + // We assume that m_sName and m_pUser are equal + SetBufferCount(chan.GetBufferCount()); + SetKeepBuffer(chan.KeepBuffer()); + SetAutoCycle(chan.AutoCycle()); + SetKey(chan.GetKey()); + SetDefaultModes(chan.GetDefaultModes()); + + if (IsDetached() != chan.IsDetached()) { + // Only send something if it makes sense + // (= Only detach if client is on the channel + // and only attach if we are on the channel) + if (IsOn()) { + if (IsDetached()) { + JoinUser(false, ""); + } else { + DetachUser(); + } + } + SetDetached(chan.IsDetached()); + } } void CChan::Cycle() const { diff --git a/Chan.h b/Chan.h index 2246b9d7..1b509383 100644 --- a/Chan.h +++ b/Chan.h @@ -55,7 +55,7 @@ public: void Reset(); bool WriteConfig(CFile& File); - void Joined(); + void Clone(CChan& chan); void Cycle() const; void JoinUser(bool bForce = false, const CString& sKey = "", CClient* pClient = NULL); void DetachUser(); @@ -104,7 +104,7 @@ public: // Setters void IncPermCount(unsigned char uPerm); void DecPermCount(unsigned char uPerm); - void SetIsOn(bool b) { m_bIsOn = b; if (!b) { Reset(); } else { Joined(); } } + void SetIsOn(bool b) { m_bIsOn = b; if (!b) { Reset(); } } void SetKey(const CString& s) { m_sKey = s; } void SetTopic(const CString& s) { m_sTopic = s; } void SetTopicOwner(const CString& s) { m_sTopicOwner = s; } diff --git a/User.cpp b/User.cpp index af82876c..32be4c48 100644 --- a/User.cpp +++ b/User.cpp @@ -387,9 +387,12 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet) { for (a = 0; a < m_vChans.size(); a++) { CChan* pChan = m_vChans[a]; + CChan* pNewChan = User.FindChan(pChan->GetName()); - if (!User.FindChan(pChan->GetName())) { + if (!pNewChan) { pChan->SetInConfig(false); + } else { + pChan->Clone(*pNewChan); } }