summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-10-18 03:40:31 +0100
committerPeter Powell <petpow@saberuk.com>2017-11-06 10:55:56 +0000
commit257bf752fc6b87fa35bfa8cf95fc37730c3d55c6 (patch)
tree1e12e5a40587abc20ce5cc718f189fd753f4a9a7 /src
parent2bce37fc7dc10ad719cddd5094845e57c93ff095 (diff)
Add support for setting the unset rank in ModeHandler.
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_channel/cmd_kick.cpp4
-rw-r--r--src/mode.cpp15
-rw-r--r--src/modules/m_auditorium.cpp2
-rw-r--r--src/modules/m_autoop.cpp4
-rw-r--r--src/modules/m_customprefix.cpp3
-rw-r--r--src/modules/m_delayjoin.cpp2
-rw-r--r--src/modules/m_delaymsg.cpp2
-rw-r--r--src/modules/m_ojoin.cpp2
-rw-r--r--src/modules/m_operprefix.cpp2
-rw-r--r--src/modules/m_override.cpp2
-rw-r--r--src/modules/m_rmode.cpp2
11 files changed, 24 insertions, 16 deletions
diff --git a/src/coremods/core_channel/cmd_kick.cpp b/src/coremods/core_channel/cmd_kick.cpp
index 7f8a8a329..420ed2b83 100644
--- a/src/coremods/core_channel/cmd_kick.cpp
+++ b/src/coremods/core_channel/cmd_kick.cpp
@@ -104,8 +104,8 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
for (std::string::size_type i = 0; i < memb->modes.length(); i++)
{
ModeHandler* mh = ServerInstance->Modes->FindMode(memb->modes[i], MODETYPE_CHANNEL);
- if (mh && mh->GetLevelRequired() > req)
- req = mh->GetLevelRequired();
+ if (mh && mh->GetLevelRequired(true) > req)
+ req = mh->GetLevelRequired(true);
}
if (them < req)
diff --git a/src/mode.cpp b/src/mode.cpp
index fd5e30707..cff625c46 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -27,9 +27,16 @@
#include "builtinmodes.h"
ModeHandler::ModeHandler(Module* Creator, const std::string& Name, char modeletter, ParamSpec Params, ModeType type, Class mclass)
- : ServiceProvider(Creator, Name, SERVICE_MODE), modeid(ModeParser::MODEID_MAX),
- parameters_taken(Params), mode(modeletter), oper(false),
- list(false), m_type(type), type_id(mclass), levelrequired(HALFOP_VALUE)
+ : ServiceProvider(Creator, Name, SERVICE_MODE)
+ , modeid(ModeParser::MODEID_MAX)
+ , parameters_taken(Params)
+ , mode(modeletter)
+ , oper(false)
+ , list(false)
+ , m_type(type)
+ , type_id(mclass)
+ , ranktoset(HALFOP_VALUE)
+ , ranktounset(HALFOP_VALUE)
{
}
@@ -237,7 +244,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode
return MODEACTION_DENY;
if (MOD_RESULT == MOD_RES_PASSTHRU)
{
- unsigned int neededrank = mh->GetLevelRequired();
+ unsigned int neededrank = mh->GetLevelRequired(adding);
/* Compare our rank on the channel against the rank of the required prefix,
* allow if >= ours. Because mIRC and xchat throw a tizz if the modes shown
* in NAMES(X) are not in rank order, we know the most powerful mode is listed
diff --git a/src/modules/m_auditorium.cpp b/src/modules/m_auditorium.cpp
index 692b3eba4..7acbd2fff 100644
--- a/src/modules/m_auditorium.cpp
+++ b/src/modules/m_auditorium.cpp
@@ -28,7 +28,7 @@ class AuditoriumMode : public SimpleChannelModeHandler
public:
AuditoriumMode(Module* Creator) : SimpleChannelModeHandler(Creator, "auditorium", 'u')
{
- levelrequired = OP_VALUE;
+ ranktoset = ranktounset = OP_VALUE;
}
};
diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp
index 8c7f300da..257c3647c 100644
--- a/src/modules/m_autoop.cpp
+++ b/src/modules/m_autoop.cpp
@@ -28,7 +28,7 @@ class AutoOpList : public ListModeBase
public:
AutoOpList(Module* Creator) : ListModeBase(Creator, "autoop", 'w', "End of Channel Access List", 910, 911, true)
{
- levelrequired = OP_VALUE;
+ ranktoset = ranktounset = OP_VALUE;
tidy = false;
}
@@ -61,7 +61,7 @@ class AutoOpList : public ListModeBase
std::string dummy;
if (mh->AccessCheck(source, channel, dummy, true) == MOD_RES_DENY)
return MOD_RES_DENY;
- if (mh->GetLevelRequired() > mylevel)
+ if (mh->GetLevelRequired(true) > mylevel)
{
source->WriteNumeric(ERR_CHANOPRIVSNEEDED, channel->name, InspIRCd::Format("You must be able to set mode '%s' to include it in an autoop", mid.c_str()));
return MOD_RES_DENY;
diff --git a/src/modules/m_customprefix.cpp b/src/modules/m_customprefix.cpp
index f6f9a84f6..1be9676b5 100644
--- a/src/modules/m_customprefix.cpp
+++ b/src/modules/m_customprefix.cpp
@@ -33,7 +33,8 @@ class CustomPrefixMode : public PrefixMode
prefix = v.c_str()[0];
v = tag->getString("letter");
mode = v.c_str()[0];
- levelrequired = tag->getInt("ranktoset", prefixrank);
+ ranktoset = tag->getInt("ranktoset", prefixrank, prefixrank, UINT_MAX);
+ ranktounset = tag->getInt("ranktounset", ranktoset, ranktoset, UINT_MAX);
depriv = tag->getBool("depriv", true);
}
diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp
index e864a8289..6d1251345 100644
--- a/src/modules/m_delayjoin.cpp
+++ b/src/modules/m_delayjoin.cpp
@@ -28,7 +28,7 @@ class DelayJoinMode : public ModeHandler
public:
DelayJoinMode(Module* Parent) : ModeHandler(Parent, "delayjoin", 'D', PARAM_NONE, MODETYPE_CHANNEL)
{
- levelrequired = OP_VALUE;
+ ranktoset = ranktounset = OP_VALUE;
}
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding);
diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp
index 1ad41cc57..3471c7fd2 100644
--- a/src/modules/m_delaymsg.cpp
+++ b/src/modules/m_delaymsg.cpp
@@ -27,7 +27,7 @@ class DelayMsgMode : public ParamMode<DelayMsgMode, LocalIntExt>
: ParamMode<DelayMsgMode, LocalIntExt>(Parent, "delaymsg", 'd')
, jointime("delaymsg", ExtensionItem::EXT_MEMBERSHIP, Parent)
{
- levelrequired = OP_VALUE;
+ ranktoset = ranktounset = OP_VALUE;
}
bool ResolveModeConflict(std::string &their_param, const std::string &our_param, Channel*)
diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp
index 76e66bdc2..a96e47bc6 100644
--- a/src/modules/m_ojoin.cpp
+++ b/src/modules/m_ojoin.cpp
@@ -89,7 +89,7 @@ class NetworkPrefix : public PrefixMode
NetworkPrefix(Module* parent, char NPrefix)
: PrefixMode(parent, "official-join", 'Y', NETWORK_VALUE, NPrefix)
{
- levelrequired = INT_MAX;
+ ranktoset = ranktounset = UINT_MAX;
}
ModResult AccessCheck(User* source, Channel* channel, std::string &parameter, bool adding)
diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp
index 73155b394..8b68dbe60 100644
--- a/src/modules/m_operprefix.cpp
+++ b/src/modules/m_operprefix.cpp
@@ -33,7 +33,7 @@ class OperPrefixMode : public PrefixMode
: PrefixMode(Creator, "operprefix", 'y', OPERPREFIX_VALUE)
{
prefix = ServerInstance->Config->ConfValue("operprefix")->getString("prefix", "!", 1, 1)[0];
- levelrequired = INT_MAX;
+ ranktoset = ranktounset = UINT_MAX;
}
};
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index fd09dd6ec..2094d3c96 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -42,7 +42,7 @@ class ModuleOverride : public Module
for (Modes::ChangeList::List::const_iterator i = list.begin(); i != list.end(); ++i)
{
ModeHandler* mh = i->mh;
- if (mh->GetLevelRequired() > userlevel)
+ if (mh->GetLevelRequired(i->adding) > userlevel)
return true;
}
return false;
diff --git a/src/modules/m_rmode.cpp b/src/modules/m_rmode.cpp
index 37c6e62ff..7c15247be 100644
--- a/src/modules/m_rmode.cpp
+++ b/src/modules/m_rmode.cpp
@@ -50,7 +50,7 @@ class CommandRMode : public Command
return CMD_FAILURE;
}
- if (chan->GetPrefixValue(user) < mh->GetLevelRequired())
+ if (chan->GetPrefixValue(user) < mh->GetLevelRequired(false))
{
user->WriteNotice("You do not have access to unset " + ConvToStr(modeletter) + " on " + chan->name + ".");
return CMD_FAILURE;