diff --git a/ClientCommand.cpp b/ClientCommand.cpp index 621600cb..7d71c3cc 100644 --- a/ClientCommand.cpp +++ b/ClientCommand.cpp @@ -321,15 +321,11 @@ void CClient::UserCommand(const CString& sLine) { return; } - if (m_pUser->FindServer(sServer)) { - PutStatus("That server already exists"); - return; - } - if (m_pUser->AddServer(sLine.Token(1, true))) { PutStatus("Server added"); } else { PutStatus("Unable to add that server"); + PutStatus("Perhaps the server is already added or openssl is disabled?"); } } else if (sCommand.Equals("REMSERVER") || sCommand.Equals("DELSERVER")) { CString sServer = sLine.Token(1); diff --git a/User.cpp b/User.cpp index 7e0420d9..737f55c8 100644 --- a/User.cpp +++ b/User.cpp @@ -768,6 +768,29 @@ bool CUser::AddServer(const CString& sName, unsigned short uPort, const CString& uPort = 6667; } + // Check if server is already added + for (unsigned int a = 0; a < m_vServers.size(); a++) { + CServer* pServer = m_vServers[a]; + + if (!sName.Equals(pServer->GetName())) + continue; + + if (uPort != pServer->GetPort()) + continue; + + if (sPass != pServer->GetPass()) + continue; + + if (bSSL != pServer->IsSSL()) + continue; + + if (bIPV6 != pServer->IsIPV6()) + continue; + + // Server is already added + return false; + } + CServer* pServer = new CServer(sName, uPort, sPass, bSSL); m_vServers.push_back(pServer);