diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-06-18 19:10:07 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-07-19 19:40:04 +0200 |
commit | fd1d19d6345943ecdb5ce4ef947f9b3c5c8bca86 (patch) | |
tree | 20ce1866b482808a85b34c7c09e53c3159617bc0 /src/commands/cmd_lusers.cpp | |
parent | 882084defcc43c876ecb10e30086b63ac074fcad (diff) |
Replace hardcoded mode letters, part 3
This changes most remaining User::IsModeSet() calls to use ModeReferences for modes that were created by other modules or the core
Diffstat (limited to 'src/commands/cmd_lusers.cpp')
-rw-r--r-- | src/commands/cmd_lusers.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/commands/cmd_lusers.cpp b/src/commands/cmd_lusers.cpp index c594a0e24..c1f35592a 100644 --- a/src/commands/cmd_lusers.cpp +++ b/src/commands/cmd_lusers.cpp @@ -26,10 +26,10 @@ struct LusersCounters unsigned int max_global; unsigned int invisible; - LusersCounters() + LusersCounters(unsigned int inv) : max_local(ServerInstance->Users->LocalUserCount()) , max_global(ServerInstance->Users->RegisteredUserCount()) - , invisible(ServerInstance->Users->ModeCount('i')) + , invisible(inv) { } @@ -128,13 +128,29 @@ public: class ModuleLusers : public Module { + UserModeReference invisiblemode; LusersCounters counters; CommandLusers cmd; InvisibleWatcher mw; + unsigned int CountInvisible() + { + unsigned int c = 0; + for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); ++i) + { + User* u = i->second; + if (u->IsModeSet(invisiblemode)) + c++; + } + return c; + } + public: ModuleLusers() - : cmd(this, counters), mw(this, counters.invisible) + : invisiblemode(this, "invisible") + , counters(CountInvisible()) + , cmd(this, counters) + , mw(this, counters.invisible) { } @@ -149,13 +165,13 @@ class ModuleLusers : public Module void OnPostConnect(User* user) { counters.UpdateMaxUsers(); - if (user->IsModeSet('i')) + if (user->IsModeSet(invisiblemode)) counters.invisible++; } void OnUserQuit(User* user, const std::string& message, const std::string& oper_message) { - if (user->IsModeSet('i')) + if (user->IsModeSet(invisiblemode)) counters.invisible--; } |