summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp3
-rw-r--r--src/commands/cmd_lusers.cpp26
-rw-r--r--src/commands/cmd_wallops.cpp13
-rw-r--r--src/commands/cmd_who.cpp8
-rw-r--r--src/modules/m_alias.cpp8
-rw-r--r--src/modules/m_operprefix.cpp9
-rw-r--r--src/modules/m_regonlycreate.cpp9
-rw-r--r--src/usermanager.cpp13
-rw-r--r--src/users.cpp7
9 files changed, 60 insertions, 36 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 505ef479a..e9e2a3020 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -36,6 +36,7 @@ namespace
ChanModeReference limitmode(NULL, "limit");
ChanModeReference secretmode(NULL, "secret");
ChanModeReference privatemode(NULL, "private");
+ UserModeReference invisiblemode(NULL, "invisible");
}
Channel::Channel(const std::string &cname, time_t ts)
@@ -683,7 +684,7 @@ void Channel::UserList(User *user)
{
if (i->first->quitting)
continue;
- if ((!has_user) && (i->first->IsModeSet('i')))
+ if ((!has_user) && (i->first->IsModeSet(invisiblemode)))
{
/*
* user is +i, and source not on the channel, does not show
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;
}
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp
index 507a93533..73e3bfd46 100644
--- a/src/modules/m_alias.cpp
+++ b/src/modules/m_alias.cpp
@@ -67,6 +67,7 @@ class ModuleAlias : public Module
/* whether or not +B users are allowed to use fantasy commands */
bool AllowBots;
+ UserModeReference botmode;
void ReadAliases()
{
@@ -96,6 +97,11 @@ class ModuleAlias : public Module
}
public:
+ ModuleAlias()
+ : botmode(this, "bot")
+ {
+ }
+
void init() CXX11_OVERRIDE
{
ReadAliases();
@@ -187,7 +193,7 @@ class ModuleAlias : public Module
}
/* Stop here if the user is +B and allowbot is set to no. */
- if (!AllowBots && user->IsModeSet('B'))
+ if (!AllowBots && user->IsModeSet(botmode))
{
return;
}
diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp
index 1f820c745..643f09db9 100644
--- a/src/modules/m_operprefix.cpp
+++ b/src/modules/m_operprefix.cpp
@@ -68,10 +68,12 @@ class ModuleOperPrefixMode : public Module
{
OperPrefixMode opm;
HideOperWatcher hideoperwatcher;
+ UserModeReference hideopermode;
public:
ModuleOperPrefixMode()
: opm(this), hideoperwatcher(this)
+ , hideopermode(this, "hideoper")
{
}
@@ -92,7 +94,7 @@ class ModuleOperPrefixMode : public Module
ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE
{
- if ((user->IsOper()) && (user->IsModeSet('H')))
+ if ((user->IsOper()) && (!user->IsModeSet(hideopermode)))
privs.push_back('y');
return MOD_RES_PASSTHRU;
}
@@ -101,7 +103,8 @@ class ModuleOperPrefixMode : public Module
{
std::vector<std::string> modechange;
modechange.push_back("");
- modechange.push_back(add ? "+y" : "-y");
+ modechange.push_back(add ? "+" : "-");
+ modechange[1].push_back(opm.GetModeChar());
modechange.push_back(user->nick);
for (UCListIter v = user->chans.begin(); v != user->chans.end(); v++)
{
@@ -112,7 +115,7 @@ class ModuleOperPrefixMode : public Module
void OnPostOper(User* user, const std::string& opername, const std::string& opertype) CXX11_OVERRIDE
{
- if (IS_LOCAL(user) && (!user->IsModeSet('H')))
+ if (IS_LOCAL(user) && (!user->IsModeSet(hideopermode)))
SetOperPrefix(user, true);
}
diff --git a/src/modules/m_regonlycreate.cpp b/src/modules/m_regonlycreate.cpp
index 84058fbfa..6b6e059df 100644
--- a/src/modules/m_regonlycreate.cpp
+++ b/src/modules/m_regonlycreate.cpp
@@ -25,7 +25,14 @@
class ModuleRegOnlyCreate : public Module
{
+ UserModeReference regusermode;
+
public:
+ ModuleRegOnlyCreate()
+ : regusermode(this, "u_registered")
+ {
+ }
+
void init() CXX11_OVERRIDE
{
Implementation eventlist[] = { I_OnUserPreJoin };
@@ -40,7 +47,7 @@ class ModuleRegOnlyCreate : public Module
if (user->IsOper())
return MOD_RES_PASSTHRU;
- if (user->IsModeSet('r'))
+ if (user->IsModeSet(regusermode))
return MOD_RES_PASSTHRU;
const AccountExtItem* ext = GetAccountExtItem();
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index e7d1fd05c..15e59c800 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -316,19 +316,6 @@ void UserManager::ServerNoticeAll(const char* text, ...)
}
}
-/* return how many users have a given mode e.g. 'a' */
-int UserManager::ModeCount(const char mode)
-{
- int c = 0;
- for(user_hash::iterator i = clientlist->begin(); i != clientlist->end(); ++i)
- {
- User* u = i->second;
- if (u->modes[mode-65])
- c++;
- }
- return c;
-}
-
void UserManager::GarbageCollect()
{
// Reset the already_sent IDs so we don't wrap it around and drop a message
diff --git a/src/users.cpp b/src/users.cpp
index 2f90a7970..f4055d464 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -45,13 +45,6 @@ bool User::IsModeSet(unsigned char m)
return (modes[m-65]);
}
-void User::SetMode(unsigned char m, bool value)
-{
- if (!isalpha(m))
- return;
- modes[m-65] = value;
-}
-
const char* User::FormatModes(bool showparameters)
{
static std::string data;