From 5cc9614e73a783dec7a8e0887a0435cf577eaad4 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Fri, 19 Jul 2013 13:10:18 +0200 Subject: m_spanningtree Change TreeServer::GetSocket() to always return the socket that can be used to talk to the server The only exception is the tree root (us) which has no associated socket (NULL) Add TreeServer::IsRoot() and IsLocal() helpers --- src/modules/m_spanningtree/rsquit.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/modules/m_spanningtree/rsquit.cpp') diff --git a/src/modules/m_spanningtree/rsquit.cpp b/src/modules/m_spanningtree/rsquit.cpp index 9437c174a..3b7468491 100644 --- a/src/modules/m_spanningtree/rsquit.cpp +++ b/src/modules/m_spanningtree/rsquit.cpp @@ -34,7 +34,6 @@ CommandRSQuit::CommandRSQuit(Module* Creator) CmdResult CommandRSQuit::Handle (const std::vector& parameters, User *user) { TreeServer *server_target; // Server to squit - TreeServer *server_linked; // Server target is linked to server_target = Utils->FindServerMask(parameters[0]); if (!server_target) @@ -43,25 +42,20 @@ CmdResult CommandRSQuit::Handle (const std::vector& parameters, Use return CMD_FAILURE; } - if (server_target == Utils->TreeRoot) + if (server_target->IsRoot()) { ((ModuleSpanningTree*)(Module*)creator)->RemoteMessage(user, "*** RSQUIT: Foolish mortal, you cannot make a server SQUIT itself! (%s matches local server name)", parameters[0].c_str()); return CMD_FAILURE; } - server_linked = server_target->GetParent(); - - if (server_linked == Utils->TreeRoot) + if (server_target->IsLocal()) { // We have been asked to remove server_target. TreeSocket* sock = server_target->GetSocket(); - if (sock) - { - const char *reason = parameters.size() == 2 ? parameters[1].c_str() : "No reason"; - ServerInstance->SNO->WriteToSnoMask('l',"RSQUIT: Server \002%s\002 removed from network by %s (%s)", parameters[0].c_str(), user->nick.c_str(), reason); - sock->Squit(server_target, "Server quit by " + user->GetFullRealHost() + " (" + reason + ")"); - sock->Close(); - } + const char* reason = parameters.size() == 2 ? parameters[1].c_str() : "No reason"; + ServerInstance->SNO->WriteToSnoMask('l',"RSQUIT: Server \002%s\002 removed from network by %s (%s)", parameters[0].c_str(), user->nick.c_str(), reason); + sock->Squit(server_target, "Server quit by " + user->GetFullRealHost() + " (" + reason + ")"); + sock->Close(); } return CMD_SUCCESS; -- cgit v1.2.3