From 37d463cd325d8a12e4a0eddc98fb9b20f9694c3e Mon Sep 17 00:00:00 2001 From: psychon Date: Mon, 6 Aug 2007 09:24:20 +0000 Subject: [PATCH] partyline: Rewrite the whole fixed channel list when changing it instead of some CString::Replace() magic. This was inspired by sf.net bug 1762977 comment 2. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@819 726aef4b-f618-498e-8847-2d620e286838 --- modules/partyline.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/partyline.cpp b/modules/partyline.cpp index 5a36180c..84cab689 100644 --- a/modules/partyline.cpp +++ b/modules/partyline.cpp @@ -105,6 +105,23 @@ public: return; } + void SaveFixedChans(CUser* pUser) { + CString sChans; + const CString &sUser = pUser->GetUserName(); + + for(set::iterator it = m_ssChannels.begin(); + it != m_ssChannels.end(); it++) { + if ((*it)->IsFixedChan(sUser)) { + sChans += "," + (*it)->GetName(); + } + } + + if (!sChans.empty()) + SetNV(sUser, sChans.substr(1)); // Strip away the first , + else + DelNV(sUser); + } + virtual EModRet OnDeleteUser(CUser& User) { const CString& sNick = User.GetUserName(); CString sHost = User.GetVHost(); @@ -433,10 +450,7 @@ public: JoinUser(pUser, pChan); pChan->AddFixedNick(sUser); - // Save the fixed channel - // every channel has a , at its start, so its easier - // to remove one. - SetNV(sUser, GetNV(sUser) + "," + sChan); + SaveFixedChans(pUser); PutModule("Fixed " + sUser + " to channel " + sChan); } else if (sCommand.CaseCmp("DELFIXCHAN") == 0) { @@ -461,9 +475,7 @@ public: PartUser(pUser, pChan, true); - CString sFixed = GetNV(sUser); - sFixed.Replace("," + sChan, ""); - SetNV(sUser, sChan); + SaveFixedChans(pUser); PutModule("Removed " + sUser + " from " + sChan); } else if (sCommand.CaseCmp("LISTFIXCHANS") == 0) {