summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-01-17 12:17:09 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-01-17 12:17:09 +0000
commit1e5728d84c1b4b0d86bf745ce253aa458575df20 (patch)
treeb05d280fa7dec2fe9c56cba0c8e0143984d947cd /src
parentbf77b312c8e15da249991cff43432c21b44807d7 (diff)
Move a number of methods from class InspIRCd to class UserManager
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8726 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/commands/cmd_lusers.cpp14
-rw-r--r--src/helperfuncs.cpp31
-rw-r--r--src/modules/m_spanningtree/main.cpp18
-rw-r--r--src/usermanager.cpp38
4 files changed, 54 insertions, 47 deletions
diff --git a/src/commands/cmd_lusers.cpp b/src/commands/cmd_lusers.cpp
index bb9670227..f91266a15 100644
--- a/src/commands/cmd_lusers.cpp
+++ b/src/commands/cmd_lusers.cpp
@@ -25,15 +25,15 @@ CmdResult CommandLusers::Handle (const char**, int, User *user)
{
// this lusers command shows one server at all times because
// a protocol module must override it to show those stats.
- user->WriteServ("251 %s :There are %d users and %d invisible on 1 server",user->nick,ServerInstance->UserCount()-ServerInstance->ModeCount('i'),ServerInstance->ModeCount('i'));
- if (ServerInstance->OperCount())
- user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->OperCount());
- if (ServerInstance->UnregisteredUserCount())
- user->WriteServ("253 %s %d :unknown connections",user->nick,ServerInstance->UnregisteredUserCount());
+ user->WriteServ("251 %s :There are %d users and %d invisible on 1 server",user->nick,ServerInstance->Users->UserCount()-ServerInstance->ModeCount('i'),ServerInstance->ModeCount('i'));
+ if (ServerInstance->Users->OperCount())
+ user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->Users->OperCount());
+ if (ServerInstance->Users->UnregisteredUserCount())
+ user->WriteServ("253 %s %d :unknown connections",user->nick,ServerInstance->Users->UnregisteredUserCount());
if (ServerInstance->ChannelCount())
user->WriteServ("254 %s %d :channels formed",user->nick,ServerInstance->ChannelCount());
- if (ServerInstance->LocalUserCount())
- user->WriteServ("255 %s :I have %d clients and 0 servers",user->nick,ServerInstance->LocalUserCount());
+ if (ServerInstance->Users->LocalUserCount())
+ user->WriteServ("255 %s :I have %d clients and 0 servers",user->nick,ServerInstance->Users->LocalUserCount());
return CMD_SUCCESS;
}
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 40b2d7d90..048de75ca 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -339,18 +339,6 @@ void InspIRCd::SendError(const std::string &s)
}
}
-/* this function counts all users connected, wether they are registered or NOT. */
-int InspIRCd::UserCount()
-{
- return clientlist->size();
-}
-
-/* this counts only registered users, so that the percentages in /MAP don't mess up when users are sitting in an unregistered state */
-int InspIRCd::RegisteredUserCount()
-{
- return clientlist->size() - this->UnregisteredUserCount();
-}
-
/* return how many users have a given mode e.g. 'a' */
int InspIRCd::ModeCount(const char mode)
{
@@ -362,31 +350,12 @@ int InspIRCd::ModeCount(const char mode)
return 0;
}
-/* return how many users are opered */
-int InspIRCd::OperCount()
-{
- return this->all_opers.size();
-}
-
-/* return how many users are unregistered */
-int InspIRCd::UnregisteredUserCount()
-{
- return this->unregistered_count;
-}
-
/* return channel count */
long InspIRCd::ChannelCount()
{
return chanlist->size();
}
-/* return how many local registered users there are */
-long InspIRCd::LocalUserCount()
-{
- /* Doesnt count unregistered clients */
- return (local_users.size() - this->UnregisteredUserCount());
-}
-
bool InspIRCd::IsValidMask(const std::string &mask)
{
char* dest = (char*)mask.c_str();
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 4312dd4b3..dabc20fdf 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -123,11 +123,11 @@ void ModuleSpanningTree::HandleLinks(const char** parameters, int pcnt, User* us
void ModuleSpanningTree::HandleLusers(const char** parameters, int pcnt, User* user)
{
- unsigned int n_users = ServerInstance->UserCount();
+ unsigned int n_users = ServerInstance->Users->UserCount();
/* Only update these when someone wants to see them, more efficient */
- if ((unsigned int)ServerInstance->LocalUserCount() > max_local)
- max_local = ServerInstance->LocalUserCount();
+ if ((unsigned int)ServerInstance->Users->LocalUserCount() > max_local)
+ max_local = ServerInstance->Users->LocalUserCount();
if (n_users > max_global)
max_global = n_users;
@@ -154,17 +154,17 @@ void ModuleSpanningTree::HandleLusers(const char** parameters, int pcnt, User* u
ServerInstance->ModeCount('i'),
ulined_count ? this->CountServs() - ulined_count : this->CountServs());
- if (ServerInstance->OperCount())
- user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->OperCount());
+ if (ServerInstance->Users->OperCount())
+ user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->Users->OperCount());
- if (ServerInstance->UnregisteredUserCount())
- user->WriteServ("253 %s %d :unknown connections",user->nick,ServerInstance->UnregisteredUserCount());
+ if (ServerInstance->Users->UnregisteredUserCount())
+ user->WriteServ("253 %s %d :unknown connections",user->nick,ServerInstance->Users->UnregisteredUserCount());
if (ServerInstance->ChannelCount())
user->WriteServ("254 %s %d :channels formed",user->nick,ServerInstance->ChannelCount());
- user->WriteServ("255 %s :I have %d clients and %d servers",user->nick,ServerInstance->LocalUserCount(),ulined_local_count ? this->CountLocalServs() - ulined_local_count : this->CountLocalServs());
- user->WriteServ("265 %s :Current Local Users: %d Max: %d",user->nick,ServerInstance->LocalUserCount(),max_local);
+ user->WriteServ("255 %s :I have %d clients and %d servers",user->nick,ServerInstance->Users->LocalUserCount(),ulined_local_count ? this->CountLocalServs() - ulined_local_count : this->CountLocalServs());
+ user->WriteServ("265 %s :Current Local Users: %d Max: %d",user->nick,ServerInstance->Users->LocalUserCount(),max_local);
user->WriteServ("266 %s :Current Global Users: %d Max: %d",user->nick,n_users,max_global);
return;
}
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index c980e0eb3..bc5eb01a9 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -237,3 +237,41 @@ unsigned long UserManager::LocalCloneCount(User *user)
else
return 0;
}
+
+/* this function counts all users connected, wether they are registered or NOT. */
+unsigned int UserManager::UserCount()
+{
+ /*
+ * XXX: Todo:
+ * As part of this restructuring, move clientlist/etc fields into usermanager.
+ * -- w00t
+ */
+ return ServerInstance->clientlist->size();
+}
+
+/* this counts only registered users, so that the percentages in /MAP don't mess up */
+unsigned int UserManager::RegisteredUserCount()
+{
+ return ServerInstance->clientlist->size() - this->UnregisteredUserCount();
+}
+
+/* return how many users are opered */
+unsigned int UserManager::OperCount()
+{
+ return ServerInstance->all_opers.size();
+}
+
+/* return how many users are unregistered */
+unsigned int UserManager::UnregisteredUserCount()
+{
+ return ServerInstance->unregistered_count;
+}
+
+/* return how many local registered users there are */
+unsigned int UserManager::LocalUserCount()
+{
+ /* Doesnt count unregistered clients */
+ return (ServerInstance->local_users.size() - this->UnregisteredUserCount());
+}
+
+