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 | |
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')
-rw-r--r-- | src/commands/cmd_lusers.cpp | 26 | ||||
-rw-r--r-- | src/commands/cmd_wallops.cpp | 13 | ||||
-rw-r--r-- | src/commands/cmd_who.cpp | 8 |
3 files changed, 37 insertions, 10 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--; } diff --git a/src/commands/cmd_wallops.cpp b/src/commands/cmd_wallops.cpp index 3cd8abc42..e0e832ff7 100644 --- a/src/commands/cmd_wallops.cpp +++ b/src/commands/cmd_wallops.cpp @@ -27,10 +27,19 @@ */ class CommandWallops : public Command { + UserModeReference wallopsmode; + public: /** Constructor for wallops. */ - CommandWallops ( Module* parent) : Command(parent,"WALLOPS",1,1) { flags_needed = 'o'; syntax = "<any-text>"; } + CommandWallops(Module* parent) + : Command(parent, "WALLOPS", 1, 1) + , wallopsmode(parent, "wallops") + { + flags_needed = 'o'; + syntax = "<any-text>"; + } + /** Handle command. * @param parameters The parameters to the comamnd * @param pcnt The number of parameters passed to teh command @@ -53,7 +62,7 @@ CmdResult CommandWallops::Handle (const std::vector<std::string>& parameters, Us for (LocalUserList::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++) { User* t = *i; - if (t->IsModeSet('w')) + if (t->IsModeSet(wallopsmode)) user->WriteTo(t,wallop); } diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index a78f03793..302393927 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -41,6 +41,7 @@ class CommandWho : public Command bool opt_time; ChanModeReference secretmode; ChanModeReference privatemode; + UserModeReference invisiblemode; Channel* get_first_visible_channel(User *u) { @@ -61,6 +62,7 @@ class CommandWho : public Command : Command(parent, "WHO", 1) , secretmode(parent, "secret") , privatemode(parent, "private") + , invisiblemode(parent, "invisible") { syntax = "<server>|<nickname>|<channel>|<realname>|<host>|0 [ohurmMiaplf]"; } @@ -336,7 +338,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User * continue; /* If we're not inside the channel, hide +i users */ - if (i->first->IsModeSet('i') && !inside && !user->HasPrivPermission("users/auspex")) + if (i->first->IsModeSet(invisiblemode) && !inside && !user->HasPrivPermission("users/auspex")) continue; } @@ -358,7 +360,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User * { if (!user->SharesChannelWith(oper)) { - if (usingwildcards && (!oper->IsModeSet('i')) && (!user->HasPrivPermission("users/auspex"))) + if (usingwildcards && (!oper->IsModeSet(invisiblemode)) && (!user->HasPrivPermission("users/auspex"))) continue; } @@ -374,7 +376,7 @@ CmdResult CommandWho::Handle (const std::vector<std::string>& parameters, User * { if (!user->SharesChannelWith(i->second)) { - if (usingwildcards && (i->second->IsModeSet('i')) && (!user->HasPrivPermission("users/auspex"))) + if (usingwildcards && (i->second->IsModeSet(invisiblemode)) && (!user->HasPrivPermission("users/auspex"))) continue; } |