mirror of
https://github.com/znc/znc.git
synced 2026-05-09 06:44:40 +02:00
Bug fix for CUser::DelServer()
DelServer() didn't always update m_uServerIdx correctly which means GetCurServer() started to return the wrong server. This should now be fixed. This log shows the bug. ZNC starts to think it's connected to irc.efnet.nl: <znc_psy> listservers <*status> +-------------------+------+-----+------+ <*status> | Host | Port | SSL | Pass | <*status> +-------------------+------+-----+------+ <*status> | irc.efnet.pl | 6667 | | | <*status> | irc.spotchat.org* | 6667 | | | <*status> | irc.efnet.nl | 6667 | | | <*status> | irc.freenode.org | 6667 | | | <*status> +-------------------+------+-----+------+ <znc_psy> delserver irc.efnet.pl <*status> Server removed <znc_psy> listservers <*status> +------------------+------+-----+------+ <*status> | Host | Port | SSL | Pass | <*status> +------------------+------+-----+------+ <*status> | irc.spotchat.org | 6667 | | | <*status> | irc.efnet.nl* | 6667 | | | <*status> | irc.freenode.org | 6667 | | | <*status> +------------------+------+-----+------+ Thanks to tomaw for reporting this bug. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1659 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -768,10 +768,15 @@ bool CUser::DelServer(const CString& sName, unsigned short uPort, const CString&
|
||||
}
|
||||
|
||||
unsigned int a = 0;
|
||||
bool bSawCurrentServer = false;
|
||||
CServer* pCurServer = GetCurrentServer();
|
||||
|
||||
for (vector<CServer*>::iterator it = m_vServers.begin(); it != m_vServers.end(); it++, a++) {
|
||||
CServer* pServer = *it;
|
||||
|
||||
if (pServer == pCurServer)
|
||||
bSawCurrentServer = true;
|
||||
|
||||
if (!pServer->GetName().Equals(sName))
|
||||
continue;
|
||||
|
||||
@@ -781,12 +786,12 @@ bool CUser::DelServer(const CString& sName, unsigned short uPort, const CString&
|
||||
if (!sPass.empty() && pServer->GetPass() != sPass)
|
||||
continue;
|
||||
|
||||
CServer* pCurServer = GetCurrentServer();
|
||||
m_vServers.erase(it);
|
||||
|
||||
if (pServer == pCurServer) {
|
||||
CIRCSock* pIRCSock = GetIRCSock();
|
||||
|
||||
// Make sure we don't skip the next server in the list!
|
||||
if (m_uServerIdx) {
|
||||
m_uServerIdx--;
|
||||
}
|
||||
@@ -795,8 +800,11 @@ bool CUser::DelServer(const CString& sName, unsigned short uPort, const CString&
|
||||
pIRCSock->Quit();
|
||||
PutStatus("Your current server was removed, jumping...");
|
||||
}
|
||||
} else if (m_uServerIdx >= m_vServers.size()) {
|
||||
m_uServerIdx = 0;
|
||||
} else if (!bSawCurrentServer) {
|
||||
// Our current server comes after the server which we
|
||||
// are removing. This means that it now got a different
|
||||
// index in m_vServers!
|
||||
m_uServerIdx--;
|
||||
}
|
||||
|
||||
delete pServer;
|
||||
|
||||
Reference in New Issue
Block a user