]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_spanningtree Minor cleanup of functions
authorattilamolnar <attilamolnar@hush.com>
Sat, 17 Aug 2013 13:43:24 +0000 (15:43 +0200)
committerattilamolnar <attilamolnar@hush.com>
Mon, 19 Aug 2013 17:54:54 +0000 (19:54 +0200)
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/main.h
src/modules/m_spanningtree/override_map.cpp
src/modules/m_spanningtree/treeserver.cpp
src/modules/m_spanningtree/treeserver.h
src/modules/m_spanningtree/treesocket2.cpp
src/modules/m_spanningtree/utils.cpp
src/modules/m_spanningtree/utils.h

index 8f17129a33cea93eff5eca9be8711012cbd2d3f6..060dc01df9398bfe78a48f13f7ccc6854f2988db 100644 (file)
@@ -104,16 +104,10 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
                        Current->GetDesc().c_str());
 }
 
-int ModuleSpanningTree::CountServs()
-{
-       return Utils->serverlist.size();
-}
-
 void ModuleSpanningTree::HandleLinks(const std::vector<std::string>& parameters, User* user)
 {
        ShowLinks(Utils->TreeRoot,user,0);
        user->WriteNumeric(365, "%s * :End of /LINKS list.",user->nick.c_str());
-       return;
 }
 
 std::string ModuleSpanningTree::TimeToStr(time_t secs)
@@ -432,12 +426,12 @@ void ModuleSpanningTree::OnPostTopicChange(User* user, Channel* chan, const std:
        Utils->DoOneToMany(user->uuid,"TOPIC",params);
 }
 
-void ModuleSpanningTree::LocalMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list, const char* message_type)
+void ModuleSpanningTree::OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype)
 {
-       /* Server or remote origin, dest should always be non-null */
-       if ((!user) || (!IS_LOCAL(user)) || (!dest))
+       if (!IS_LOCAL(user))
                return;
 
+       const char* message_type = (msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
        if (target_type == TYPE_USER)
        {
                User* d = (User*) dest;
@@ -463,11 +457,6 @@ void ModuleSpanningTree::LocalMessage(User* user, void* dest, int target_type, c
        }
 }
 
-void ModuleSpanningTree::OnUserMessage(User* user, void* dest, int target_type, const std::string& text, char status, const CUList& exempt_list, MessageType msgtype)
-{
-       LocalMessage(user, dest, target_type, text, status, exempt_list, (msgtype == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE"));
-}
-
 void ModuleSpanningTree::OnBackgroundTimer(time_t curtime)
 {
        AutoConnectServers(curtime);
index 8b1f8e72f67a43efed7796b68e374f8855886016..e9be4416701bb88a24420d51cd41d6b8ceeaeb8c 100644 (file)
@@ -53,7 +53,6 @@ class Autoconnect;
 class ModuleSpanningTree : public Module
 {
        SpanningTreeCommands* commands;
-       void LocalMessage(User* user, void* dest, int target_type, const std::string &text, char status, const CUList &exempt_list, const char* message_type);
 
  public:
        dynamic_reference<DNS::Manager> DNS;
@@ -74,10 +73,6 @@ class ModuleSpanningTree : public Module
         */
        void ShowLinks(TreeServer* Current, User* user, int hops);
 
-       /** Counts local and remote servers
-        */
-       int CountServs();
-
        /** Handle LINKS command
         */
        void HandleLinks(const std::vector<std::string>& parameters, User* user);
@@ -136,7 +131,7 @@ class ModuleSpanningTree : public Module
 
        /** Display a time as a human readable string
         */
-       std::string TimeToStr(time_t secs);
+       static std::string TimeToStr(time_t secs);
 
        /**
         ** *** MODULE EVENTS ***
index d57fdeea6dd696218dde4cd43110912dfa142cad..ae30ae706ce36532a536da48432a67cde6668c63 100644 (file)
@@ -123,7 +123,7 @@ bool ModuleSpanningTree::HandleMap(const std::vector<std::string>& parameters, U
        // "scratch" draw to, as the console device of an irc
        // client does not provide for a proper terminal.
        int totusers = ServerInstance->Users->clientlist->size();
-       int totservers = this->CountServs();
+       int totservers = Utils->serverlist.size();
        int maxnamew = 0;
        int line = 0;
        char* names = new char[totservers * 100];
index fe7dbe170fc7524e732b85936db4239acde4e563..0fad3132d8f629c9f31e5276e06c53b62d146c5e 100644 (file)
@@ -271,13 +271,13 @@ bool TreeServer::DelChild(TreeServer* Child)
  * This is used during netsplits to automatically tidy up the
  * server tree. It is slow, we don't use it for much else.
  */
-bool TreeServer::Tidy()
+void TreeServer::Tidy()
 {
        while (1)
        {
                std::vector<TreeServer*>::iterator a = Children.begin();
                if (a == Children.end())
-                       return true;
+                       return;
                TreeServer* s = *a;
                s->Tidy();
                s->cull();
index 7792f2191f28e687d25c686fe02930cd5b704086..faaa47aa100d882caada2501fac152f2431a8387 100644 (file)
@@ -163,7 +163,7 @@ class TreeServer : public classbase
         * This is used during netsplits to automatically tidy up the
         * server tree. It is slow, we don't use it for much else.
         */
-       bool Tidy();
+       void Tidy();
 
        /** Get server ID
         */
index 66826ff3b9e3fa0392e6b766a64b63a9d3fdf5e7..986e71cfe147027f8b850b3c94bed575e86a810e 100644 (file)
@@ -388,7 +388,7 @@ void TreeSocket::Close()
                time_t server_uptime = ServerInstance->Time() - this->age;
                if (server_uptime)
                {
-                       std::string timestr = Utils->Creator->TimeToStr(server_uptime);
+                       std::string timestr = ModuleSpanningTree::TimeToStr(server_uptime);
                        ServerInstance->SNO->WriteGlobalSno('l', "Connection to '\2%s\2' was established for %s", linkID.c_str(), timestr.c_str());
                }
        }
index 5330d2eb3fe7ca04943ada951957c4d5c5d32e81..ddfd26b6d186a33fffb446297b7e85961577d5d6 100644 (file)
@@ -207,7 +207,7 @@ std::string SpanningTreeUtilities::ConstructLine(const std::string& prefix, cons
        return FullLine;
 }
 
-bool SpanningTreeUtilities::DoOneToAllButSender(const std::string& prefix, const std::string& command, const parameterlist& params, const std::string& omit)
+void SpanningTreeUtilities::DoOneToAllButSender(const std::string& prefix, const std::string& command, const parameterlist& params, const std::string& omit)
 {
        TreeServer* omitroute = this->BestRouteTo(omit);
        std::string FullLine = ConstructLine(prefix, command, params);
@@ -227,10 +227,9 @@ bool SpanningTreeUtilities::DoOneToAllButSender(const std::string& prefix, const
                                Sock->WriteLine(FullLine);
                }
        }
-       return true;
 }
 
-bool SpanningTreeUtilities::DoOneToMany(const std::string &prefix, const std::string &command, const parameterlist &params)
+void SpanningTreeUtilities::DoOneToMany(const std::string &prefix, const std::string &command, const parameterlist &params)
 {
        std::string FullLine = ConstructLine(prefix, command, params);
 
@@ -245,7 +244,6 @@ bool SpanningTreeUtilities::DoOneToMany(const std::string &prefix, const std::st
                                Sock->WriteLine(FullLine);
                }
        }
-       return true;
 }
 
 bool SpanningTreeUtilities::DoOneToOne(const std::string& prefix, const std::string& command, const parameterlist& params, const std::string& target)
index f65b07c436c755d5fd0384a137aff3fb925bb87d..58821bd2b7a65df26cff550608176880efc367a5 100644 (file)
@@ -134,11 +134,11 @@ class SpanningTreeUtilities : public classbase
 
        /** Send a message from this server to all but one other, local or remote
         */
-       bool DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist& params, const std::string& omit);
+       void DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist& params, const std::string& omit);
 
        /** Send a message from this server to all others
         */
-       bool DoOneToMany(const std::string &prefix, const std::string &command, const parameterlist &params);
+       void DoOneToMany(const std::string &prefix, const std::string &command, const parameterlist &params);
 
        /** Read the spanningtree module's tags from the config file
         */