]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/main.cpp
Convert WriteNumeric() calls to pass the parameters of the numeric as method parameters
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / main.cpp
index 31d8227894205f00edd71f48fcad0ee23b4e623c..ade8359ba4a85463ad714e1e7c40243544f553bc 100644 (file)
@@ -37,8 +37,9 @@
 
 ModuleSpanningTree::ModuleSpanningTree()
        : rconnect(this), rsquit(this), map(this)
-       , commands(NULL)
+       , commands(this)
        , currmembid(0)
+       , eventprov(this, "event/spanningtree")
        , DNS(this, "DNS")
        , loopCall(false)
 {
@@ -88,7 +89,6 @@ void ModuleSpanningTree::init()
 
        Utils = new SpanningTreeUtilities(this);
        Utils->TreeRoot = new TreeServer;
-       commands = new SpanningTreeCommands(this);
 
        ServerInstance->PI = &protocolinterface;
 
@@ -127,16 +127,15 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
        else if ((Current->Hidden) && (!user->IsOper()))
                return;
 
-       user->WriteNumeric(RPL_LINKS, "%s %s :%d %s",   Current->GetName().c_str(),
-                       (Utils->FlatLinks && (!user->IsOper())) ? ServerInstance->Config->ServerName.c_str() : Parent.c_str(),
-                       (Utils->FlatLinks && (!user->IsOper())) ? 0 : hops,
-                       Current->GetDesc().c_str());
+       user->WriteNumeric(RPL_LINKS, Current->GetName(),
+                       (((Utils->FlatLinks) && (!user->IsOper())) ? ServerInstance->Config->ServerName : Parent),
+                       InspIRCd::Format("%d %s", (((Utils->FlatLinks) && (!user->IsOper())) ? 0 : hops), Current->GetDesc().c_str()));
 }
 
 void ModuleSpanningTree::HandleLinks(const std::vector<std::string>& parameters, User* user)
 {
        ShowLinks(Utils->TreeRoot,user,0);
-       user->WriteNumeric(RPL_ENDOFLINKS, "* :End of /LINKS list.");
+       user->WriteNumeric(RPL_ENDOFLINKS, '*', "End of /LINKS list.");
 }
 
 std::string ModuleSpanningTree::TimeToStr(time_t secs)
@@ -217,7 +216,7 @@ void ModuleSpanningTree::ConnectServer(Link* x, Autoconnect* y)
        /* Do we already have an IP? If so, no need to resolve it. */
        if (ipvalid)
        {
-               /* Gave a hook, but it wasnt one we know */
+               // Create a TreeServer object that will start connecting immediately in the background
                TreeSocket* newsocket = new TreeSocket(x, y, x->IPAddr);
                if (newsocket->GetFd() > -1)
                {
@@ -288,7 +287,7 @@ void ModuleSpanningTree::DoConnectTimeout(time_t curtime)
 
 ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& parameters, User* user)
 {
-       // we've already checked if pcnt > 0, so this is safe
+       // We've already confirmed that !parameters.empty(), so this is safe
        TreeServer* found = Utils->FindServerMask(parameters[0]);
        if (found)
        {
@@ -304,11 +303,11 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& para
                // or the server is a 2.0 server and does not send a full version.
                bool showfull = ((user->IsOper()) && (!found->GetFullVersion().empty()));
                const std::string& Version = (showfull ? found->GetFullVersion() : found->GetVersion());
-               user->WriteNumeric(RPL_VERSION, ":%s", Version.c_str());
+               user->WriteNumeric(RPL_VERSION, Version);
        }
        else
        {
-               user->WriteNumeric(ERR_NOSUCHSERVER, "%s :No such server", parameters[0].c_str());
+               user->WriteNumeric(ERR_NOSUCHSERVER, parameters[0], "No such server");
        }
        return MOD_RES_DENY;
 }
@@ -357,7 +356,7 @@ ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& para
        return MOD_RES_DENY;
 }
 
-void ModuleSpanningTree::OnUserInvite(User* source,User* dest,Channel* channel, time_t expiry)
+void ModuleSpanningTree::OnUserInvite(User* source, User* dest, Channel* channel, time_t expiry, unsigned int notifyrank, CUList& notifyexcepts)
 {
        if (IS_LOCAL(source))
        {
@@ -526,7 +525,7 @@ void ModuleSpanningTree::OnUserQuit(User* user, const std::string &reason, const
                }
        }
 
-       // Regardless, We need to modify the user Counts..
+       // Regardless, update the UserCount
        TreeServer::Get(user)->UserCount--;
 }
 
@@ -650,13 +649,13 @@ restart:
        }
 }
 
-// note: the protocol does not allow direct umode +o except
-// via NICK with 8 params. sending OPERTYPE infers +o modechange
-// locally.
 void ModuleSpanningTree::OnOper(User* user, const std::string &opertype)
 {
        if (user->registered != REG_ALL || !IS_LOCAL(user))
                return;
+
+       // Note: The protocol does not allow direct umode +o;
+       // sending OPERTYPE infers +o modechange locally.
        CommandOpertype::Builder(user).Broadcast();
 }
 
@@ -734,10 +733,7 @@ ModuleSpanningTree::~ModuleSpanningTree()
        Server* newsrv = new Server(ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc);
        SetLocalUsersServer(newsrv);
 
-       /* This will also free the listeners */
        delete Utils;
-
-       delete commands;
 }
 
 Version ModuleSpanningTree::GetVersion()
@@ -749,7 +745,7 @@ Version ModuleSpanningTree::GetVersion()
  * so that any activity it sees is FINAL, e.g. we arent going to send out
  * a NICK message before m_cloaking has finished putting the +x on the user,
  * etc etc.
- * Therefore, we return PRIORITY_LAST to make sure we end up at the END of
+ * Therefore, we set our priority to PRIORITY_LAST to make sure we end up at the END of
  * the module call queue.
  */
 void ModuleSpanningTree::Prioritize()