]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Remove spanningtree override of /LUSERS
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 10 Jan 2010 03:30:43 +0000 (03:30 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 10 Jan 2010 03:30:43 +0000 (03:30 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12247 e03df62e-2008-0410-955e-edbf42e46eb7

src/commands/cmd_lusers.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/main.h
src/modules/m_spanningtree/precommand.cpp

index a79466ae4ce9dc3a2bc956ab149e55d27a080f4a..a8453fb66fd902f37ca0e73e7bda1c2f6cb98f21 100644 (file)
  */
 class CommandLusers : public Command
 {
+       unsigned int max_local, max_global;
  public:
        /** Constructor for lusers.
         */
-       CommandLusers ( Module* parent) : Command(parent,"LUSERS",0,0) { }
+       CommandLusers ( Module* parent) : Command(parent,"LUSERS",0,0),
+               max_local(0), max_global(0)
+       { }
        /** Handle command.
         * @param parameters The parameters to the comamnd
         * @param pcnt The number of parameters passed to teh command
@@ -48,17 +51,40 @@ class CommandLusers : public Command
  */
 CmdResult CommandLusers::Handle (const std::vector<std::string>&, User *user)
 {
-       // this lusers command shows one server at all times because
-       // a protocol module must override it to show those stats.
-       user->WriteNumeric(251, "%s :There are %d users and %d invisible on 1 server",user->nick.c_str(),ServerInstance->Users->UserCount()-ServerInstance->Users->ModeCount('i'),ServerInstance->Users->ModeCount('i'));
+       unsigned int n_users = ServerInstance->Users->UserCount();
+       unsigned int n_invis = ServerInstance->Users->ModeCount('i');
+       ProtoServerList serverlist;
+       ServerInstance->PI->GetServerList(serverlist);
+       int n_serv = 1;
+       int n_local_servs = 0;
+       for(ProtoServerList::iterator i = serverlist.begin(); i != serverlist.end(); ++i)
+       {
+               n_serv++;
+               if (i->parentname == ServerInstance->Config->ServerName)
+                       n_local_servs++;
+       }
+
+       // these are updated on every connect (or /lusers invocation), which is good enough
+       if (ServerInstance->Users->LocalUserCount() > max_local)
+               max_local = ServerInstance->Users->LocalUserCount();
+       if (n_users > max_global)
+               max_global = n_users;
+
+       user->WriteNumeric(251, "%s :There are %d users and %d invisible on %d servers",user->nick.c_str(),
+                       n_users, n_users-n_invis, n_serv);
+
        if (ServerInstance->Users->OperCount())
                user->WriteNumeric(252, "%s %d :operator(s) online",user->nick.c_str(),ServerInstance->Users->OperCount());
+
        if (ServerInstance->Users->UnregisteredUserCount())
                user->WriteNumeric(253, "%s %d :unknown connections",user->nick.c_str(),ServerInstance->Users->UnregisteredUserCount());
+
        if (ServerInstance->ChannelCount())
                user->WriteNumeric(254, "%s %ld :channels formed",user->nick.c_str(),ServerInstance->ChannelCount());
-       if (ServerInstance->Users->LocalUserCount())
-               user->WriteNumeric(255, "%s :I have %d clients and 0 servers",user->nick.c_str(),ServerInstance->Users->LocalUserCount());
+
+       user->WriteNumeric(255, "%s :I have %d clients and %d servers",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),n_local_servs);
+       user->WriteNumeric(265, "%s :Current Local Users: %d  Max: %d",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),max_local);
+       user->WriteNumeric(266, "%s :Current Global Users: %d  Max: %d",user->nick.c_str(),n_users,max_global);
 
        return CMD_SUCCESS;
 }
index 4c982356aedc2be967f559ceecbfab38ea085b2e..fc4e319062a727e46966803bf1ffa9f307104382 100644 (file)
@@ -28,7 +28,6 @@
 #include "protocolinterface.h"
 
 ModuleSpanningTree::ModuleSpanningTree()
-       : max_local(0), max_global(0)
 {
        Utils = new SpanningTreeUtilities(this);
        command_rconnect = new CommandRConnect(this, Utils);
@@ -97,11 +96,6 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
                        Current->GetDesc().c_str());
 }
 
-int ModuleSpanningTree::CountLocalServs()
-{
-       return Utils->TreeRoot->ChildCount();
-}
-
 int ModuleSpanningTree::CountServs()
 {
        return Utils->serverlist.size();
@@ -114,54 +108,6 @@ void ModuleSpanningTree::HandleLinks(const std::vector<std::string>& parameters,
        return;
 }
 
-void ModuleSpanningTree::HandleLusers(const std::vector<std::string>& parameters, User* user)
-{
-       unsigned int n_users = ServerInstance->Users->UserCount();
-
-       /* Only update these when someone wants to see them, more efficient */
-       if ((unsigned int)ServerInstance->Users->LocalUserCount() > max_local)
-               max_local = ServerInstance->Users->LocalUserCount();
-       if (n_users > max_global)
-               max_global = n_users;
-
-       unsigned int ulined_count = 0;
-       unsigned int ulined_local_count = 0;
-
-       /* If ulined are hidden and we're not an oper, count the number of ulined servers hidden,
-        * locally and globally (locally means directly connected to us)
-        */
-       if ((Utils->HideULines) && (!IS_OPER(user)))
-       {
-               for (server_hash::iterator q = Utils->serverlist.begin(); q != Utils->serverlist.end(); q++)
-               {
-                       if (ServerInstance->ULine(q->second->GetName().c_str()))
-                       {
-                               ulined_count++;
-                               if (q->second->GetParent() == Utils->TreeRoot)
-                                       ulined_local_count++;
-                       }
-               }
-       }
-       user->WriteNumeric(251, "%s :There are %d users and %d invisible on %d servers",user->nick.c_str(),
-                       n_users-ServerInstance->Users->ModeCount('i'),
-                       ServerInstance->Users->ModeCount('i'),
-                       ulined_count ? this->CountServs() - ulined_count : this->CountServs());
-
-       if (ServerInstance->Users->OperCount())
-               user->WriteNumeric(252, "%s %d :operator(s) online",user->nick.c_str(),ServerInstance->Users->OperCount());
-
-       if (ServerInstance->Users->UnregisteredUserCount())
-               user->WriteNumeric(253, "%s %d :unknown connections",user->nick.c_str(),ServerInstance->Users->UnregisteredUserCount());
-
-       if (ServerInstance->ChannelCount())
-               user->WriteNumeric(254, "%s %ld :channels formed",user->nick.c_str(),ServerInstance->ChannelCount());
-
-       user->WriteNumeric(255, "%s :I have %d clients and %d servers",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),ulined_local_count ? this->CountLocalServs() - ulined_local_count : this->CountLocalServs());
-       user->WriteNumeric(265, "%s :Current Local Users: %d  Max: %d",user->nick.c_str(),ServerInstance->Users->LocalUserCount(),max_local);
-       user->WriteNumeric(266, "%s :Current Global Users: %d  Max: %d",user->nick.c_str(),n_users,max_global);
-       return;
-}
-
 std::string ModuleSpanningTree::TimeToStr(time_t secs)
 {
        time_t mins_up = secs / 60;
index b152757b9bc1ae5dde4ca7046e3a1a305988ba6b..69bd7253cdef24f12a19dedbe81ba40020fa584b 100644 (file)
@@ -46,8 +46,6 @@ class Autoconnect;
  */
 class ModuleSpanningTree : public Module
 {
-       unsigned int max_local;
-       unsigned int max_global;
        CommandRConnect* command_rconnect;
        CommandRSQuit* command_rsquit;
        CommandSVSJoin* command_svsjoin;
@@ -72,10 +70,6 @@ class ModuleSpanningTree : public Module
         */
        void ShowLinks(TreeServer* Current, User* user, int hops);
 
-       /** Counts local servers
-        */
-       int CountLocalServs();
-
        /** Counts local and remote servers
         */
        int CountServs();
@@ -84,10 +78,6 @@ class ModuleSpanningTree : public Module
         */
        void HandleLinks(const std::vector<std::string>& parameters, User* user);
 
-       /** Handle LUSERS command
-        */
-       void HandleLusers(const std::vector<std::string>& parameters, User* user);
-
        /** Show MAP output to a user (recursive)
         */
        void ShowMap(TreeServer* Current, User* user, int depth, int &line, char* names, int &maxnamew, char* stats);
index c43e4e927c12566bb173dfc517a21838791887eb..b005510d88bed7a9020339b4a30a3e733df3f32f 100644 (file)
@@ -58,11 +58,6 @@ ModResult ModuleSpanningTree::OnPreCommand(std::string &command, std::vector<std
        {
                return this->HandleTime(parameters,user);
        }
-       else if (command == "LUSERS")
-       {
-               this->HandleLusers(parameters,user);
-               return MOD_RES_DENY;
-       }
        else if (command == "LINKS")
        {
                this->HandleLinks(parameters,user);