diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-06-06 03:15:50 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-06-06 03:15:50 +0200 |
commit | f2febe8ff61766f1b57305fae873071de4526d58 (patch) | |
tree | 7de052ec47e3989f518287d2973c19992278559a /src/usermanager.cpp | |
parent | eeabdde6fbd99bc0ba5739c65421a9c20b503f72 (diff) |
Move code between usermanager.(cpp|h), clarify comments
Initialize clientlist and uuidlist in UserManager constructor
Diffstat (limited to 'src/usermanager.cpp')
-rw-r--r-- | src/usermanager.cpp | 52 |
1 files changed, 14 insertions, 38 deletions
diff --git a/src/usermanager.cpp b/src/usermanager.cpp index df1d5f9f1..c7d9a61a1 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -25,10 +25,23 @@ #include "bancache.h" UserManager::UserManager() - : unregistered_count(0), local_count(0) + : clientlist(new user_hash) + , uuidlist(new user_hash) + , unregistered_count(0), local_count(0) { } +UserManager::~UserManager() +{ + for (user_hash::iterator i = clientlist->begin(); i != clientlist->end(); ++i) + { + delete i->second; + } + + delete clientlist; + delete uuidlist; +} + /* add a client connection to the sockets list */ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) { @@ -235,7 +248,6 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char ServerInstance->Users->uuidlist->erase(user->uuid); } - void UserManager::AddLocalClone(User *user) { local_clones[user->GetCIDRMask()]++; @@ -290,42 +302,6 @@ unsigned long UserManager::LocalCloneCount(User *user) 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 this->clientlist->size(); -} - -/* this counts only registered users, so that the percentages in /MAP don't mess up */ -unsigned int UserManager::RegisteredUserCount() -{ - return this->clientlist->size() - this->UnregisteredUserCount(); -} - -/* return how many users are opered */ -unsigned int UserManager::OperCount() -{ - return this->all_opers.size(); -} - -/* return how many users are unregistered */ -unsigned int UserManager::UnregisteredUserCount() -{ - return this->unregistered_count; -} - -/* return how many local registered users there are */ -unsigned int UserManager::LocalUserCount() -{ - /* Doesnt count unregistered clients */ - return (this->local_count - this->UnregisteredUserCount()); -} - void UserManager::ServerNoticeAll(const char* text, ...) { std::string message; |