summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2016-08-30 16:05:01 +0200
committerAttila Molnar <attilamolnar@hush.com>2016-08-30 16:05:01 +0200
commitf0debf907a36846e3b48767e9797880135a4583b (patch)
treec2130bb47a303e4f253b8adb6dd15fa43f8e943d /src
parentf899ea2786e2ccf1b5765efd68c99273c9c056a9 (diff)
Pass the ModeHandler to User::HasModePermission()
Mark the method as const
Diffstat (limited to 'src')
-rw-r--r--src/mode.cpp2
-rw-r--r--src/modules/m_check.cpp4
-rw-r--r--src/users.cpp7
3 files changed, 7 insertions, 6 deletions
diff --git a/src/mode.cpp b/src/mode.cpp
index beea6d3a0..b7a7b7d41 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -294,7 +294,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode
}
}
- if (adding && IS_LOCAL(user) && mh->NeedsOper() && !user->HasModePermission(modechar, type))
+ if ((adding) && (IS_LOCAL(user)) && (mh->NeedsOper()) && (!user->HasModePermission(mh)))
{
/* It's an oper only mode, and they don't have access to it. */
if (user->IsOper())
diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp
index 17eb9d9c5..ddac033c1 100644
--- a/src/modules/m_check.cpp
+++ b/src/modules/m_check.cpp
@@ -184,10 +184,10 @@ class CommandCheck : public Command
for(char c='A'; c <= 'z'; c++)
{
ModeHandler* mh = ServerInstance->Modes->FindMode(c, MODETYPE_USER);
- if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_USER))
+ if (mh && mh->NeedsOper() && loctarg->HasModePermission(mh))
umodes.push_back(c);
mh = ServerInstance->Modes->FindMode(c, MODETYPE_CHANNEL);
- if (mh && mh->NeedsOper() && loctarg->HasModePermission(c, MODETYPE_CHANNEL))
+ if (mh && mh->NeedsOper() && loctarg->HasModePermission(mh))
cmodes.push_back(c);
}
context.Write("modeperms", "user=" + umodes + " channel=" + cmodes);
diff --git a/src/users.cpp b/src/users.cpp
index c57b6fc14..5d1c12b13 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -153,19 +153,20 @@ const std::string& User::GetFullRealHost()
return this->cached_fullrealhost;
}
-bool User::HasModePermission(unsigned char, ModeType)
+bool User::HasModePermission(const ModeHandler* mh) const
{
return true;
}
-bool LocalUser::HasModePermission(unsigned char mode, ModeType type)
+bool LocalUser::HasModePermission(const ModeHandler* mh) const
{
if (!this->IsOper())
return false;
+ const unsigned char mode = mh->GetModeChar();
if (mode < 'A' || mode > ('A' + 64)) return false;
- return ((type == MODETYPE_USER ? oper->AllowedUserModes : oper->AllowedChanModes))[(mode - 'A')];
+ return ((mh->GetModeType() == MODETYPE_USER ? oper->AllowedUserModes : oper->AllowedChanModes))[(mode - 'A')];
}
/*