summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-10 03:30:43 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-10 03:30:43 +0000
commitde69e28a4a1aea89e410b693bbbb67890ecb0bd3 (patch)
treeb9da19d1807977da003b710d97283bfd63766a9c
parent3cd1a24a51b9560a6dd6590b4a384f6b6942370d (diff)
Remove spanningtree override of /LUSERS
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12247 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/commands/cmd_lusers.cpp38
-rw-r--r--src/modules/m_spanningtree/main.cpp54
-rw-r--r--src/modules/m_spanningtree/main.h10
-rw-r--r--src/modules/m_spanningtree/precommand.cpp5
4 files changed, 32 insertions, 75 deletions
diff --git a/src/commands/cmd_lusers.cpp b/src/commands/cmd_lusers.cpp
index a79466ae4..a8453fb66 100644
--- a/src/commands/cmd_lusers.cpp
+++ b/src/commands/cmd_lusers.cpp
@@ -28,10 +28,13 @@
*/
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;
}
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 4c982356a..fc4e31906 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -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;
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index b152757b9..69bd7253c 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -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);
diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp
index c43e4e927..b005510d8 100644
--- a/src/modules/m_spanningtree/precommand.cpp
+++ b/src/modules/m_spanningtree/precommand.cpp
@@ -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);