summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree.cpp
diff options
context:
space:
mode:
authorfrostycoolslug <frostycoolslug@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-08 06:32:25 +0000
committerfrostycoolslug <frostycoolslug@e03df62e-2008-0410-955e-edbf42e46eb7>2006-01-08 06:32:25 +0000
commit965ee51d748e1cbf25edfc85b45358a8935ef99f (patch)
tree95dcb6bd01cf2a92a1ebb045c53b105cac6d5a76 /src/modules/m_spanningtree.cpp
parentadf31d907ef02d689fd4cf134b3428ade358f7b9 (diff)
Added User Counts to /map
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2736 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree.cpp')
-rw-r--r--src/modules/m_spanningtree.cpp53
1 files changed, 52 insertions, 1 deletions
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index e25da642d..ea5d0664a 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -334,6 +334,16 @@ class TreeServer
return UserCount;
}
+ void AddUserCount()
+ {
+ UserCount++;
+ }
+
+ void DelUserCount()
+ {
+ UserCount--;
+ }
+
int GetOperCount()
{
return OperCount;
@@ -1054,6 +1064,13 @@ class TreeSocket : public InspSocket
}
params[7] = ":" + params[7];
DoOneToAllButSender(source,"NICK",params,source);
+
+ // Increment the Source Servers User Count..
+ TreeServer* SourceServer = FindServer(source);
+ if (SourceServer) {
+ SourceServer->AddUserCount();
+ }
+
return true;
}
@@ -2443,7 +2460,28 @@ class ModuleSpanningTree : public Module
{
matrix[line][t] = ' ';
}
- strlcpy(&matrix[line][depth],Current->GetName().c_str(),80);
+
+ // For Aligning, we need to work out exactly how deep this thing is, and produce
+ // a 'Spacer' String to compensate.
+ char spacer[40];
+
+ memset(spacer,' ',40);
+ if ((40 - Current->GetName().length() - depth) > 1) {
+ spacer[40 - Current->GetName().length() - depth] = '\0';
+ } else {
+ spacer[5] = '\0';
+ }
+
+ float percent;
+ char text[80];
+ if (clientlist.size() == 0) {
+ // If there are no users, WHO THE HELL DID THE /MAP?!?!?!
+ percent = 0;
+ } else {
+ percent = ((float)Current->GetUserCount() / (float)clientlist.size()) * 100;
+ }
+ snprintf(text, 80, "%s %s%d [%.2f%%]", Current->GetName().c_str(), spacer, Current->GetUserCount(), percent);
+ strlcpy(&matrix[line][depth],text,80);
line++;
for (unsigned int q = 0; q < Current->ChildCount(); q++)
{
@@ -2930,6 +2968,13 @@ class ModuleSpanningTree : public Module
params.push_back(user->ip);
params.push_back(":"+std::string(user->fullname));
DoOneToMany(Srv->GetServerName(),"NICK",params);
+
+ // User is Local, change needs to be reflected!
+ TreeServer* SourceServer = FindServer(user->server);
+ if (SourceServer) {
+ SourceServer->AddUserCount();
+ }
+
}
}
@@ -2941,6 +2986,12 @@ class ModuleSpanningTree : public Module
params.push_back(":"+reason);
DoOneToMany(user->nick,"QUIT",params);
}
+ // Regardless, We need to modify the user Counts..
+ TreeServer* SourceServer = FindServer(user->server);
+ if (SourceServer) {
+ SourceServer->DelUserCount();
+ }
+
}
virtual void OnUserPostNick(userrec* user, std::string oldnick)