From 2192a9f58aae466a42d60279fb34ee3c5d2950a1 Mon Sep 17 00:00:00 2001 From: w00t Date: Sun, 13 Jan 2008 03:37:25 +0000 Subject: First UserManager overhaul: Move clone counts out of InspIRCd & User. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8705 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/usermanager.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'src/usermanager.cpp') diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 3bf17cda2..2bb4ee685 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -15,3 +15,61 @@ #include "inspircd.h" +void UserManager::AddLocalClone(User *user) +{ + clonemap::iterator x = local_clones.find(user->GetIPString()); + if (x != local_clones.end()) + x->second++; + else + local_clones[user->GetIPString()] = 1; +} + +void UserManager::AddGlobalClone(User *user) +{ + clonemap::iterator y = global_clones.find(user->GetIPString()); + if (y != global_clones.end()) + y->second++; + else + global_clones[user->GetIPString()] = 1; +} + +void UserManager::RemoveCloneCounts(User *user) +{ + clonemap::iterator x = local_clones.find(user->GetIPString()); + if (x != local_clones.end()) + { + x->second--; + if (!x->second) + { + local_clones.erase(x); + } + } + + clonemap::iterator y = global_clones.find(user->GetIPString()); + if (y != global_clones.end()) + { + y->second--; + if (!y->second) + { + global_clones.erase(y); + } + } +} + +unsigned long UserManager::GlobalCloneCount(User *user) +{ + clonemap::iterator x = global_clones.find(user->GetIPString()); + if (x != global_clones.end()) + return x->second; + else + return 0; +} + +unsigned long UserManager::LocalCloneCount(User *user) +{ + clonemap::iterator x = local_clones.find(user->GetIPString()); + if (x != local_clones.end()) + return x->second; + else + return 0; +} -- cgit v1.3.1-10-gc9f91