diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-08-17 15:43:24 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-08-19 19:54:54 +0200 |
commit | 5dcd385b772f2ce822cf0700912ced93bd06c914 (patch) | |
tree | 39339313e2dab18d8c16d34e263577fa8d389a83 | |
parent | b14ebbccf08ec34a73e1ba271e67da80d9fe805c (diff) |
m_spanningtree Minor cleanup of functions
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 17 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 7 | ||||
-rw-r--r-- | src/modules/m_spanningtree/override_map.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.h | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.h | 4 |
8 files changed, 13 insertions, 31 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 8f17129a3..060dc01df 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -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); diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 8b1f8e72f..e9be44167 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -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 *** diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index d57fdeea6..ae30ae706 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -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]; diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index fe7dbe170..0fad3132d 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -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(); diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 7792f2191..faaa47aa1 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -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 */ diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 66826ff3b..986e71cfe 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -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()); } } diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 5330d2eb3..ddfd26b6d 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -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 ¶ms) +void SpanningTreeUtilities::DoOneToMany(const std::string &prefix, const std::string &command, const parameterlist ¶ms) { 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) diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index f65b07c43..58821bd2b 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -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 ¶ms); + void DoOneToMany(const std::string &prefix, const std::string &command, const parameterlist ¶ms); /** Read the spanningtree module's tags from the config file */ |