summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/regchannel.h3
-rw-r--r--modules/commands/cs_mode.cpp4
-rw-r--r--modules/commands/cs_set_persist.cpp2
-rw-r--r--src/regchannel.cpp15
4 files changed, 17 insertions, 7 deletions
diff --git a/include/regchannel.h b/include/regchannel.h
index 851d98f19..93a242a28 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -363,10 +363,11 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
/** Remove a mlock
* @param mode The mode
+ * @param status True for mlock on, false for mlock off
* @param param The param of the mode, required if it is a list or status mode
* @return true on success, false on failure
*/
- bool RemoveMLock(ChannelMode *mode, const Anope::string &param = "");
+ bool RemoveMLock(ChannelMode *mode, bool status, const Anope::string &param = "");
/** Clear all mlocks on the channel
*/
diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp
index e0dda5524..c2b9c7de4 100644
--- a/modules/commands/cs_mode.cpp
+++ b/modules/commands/cs_mode.cpp
@@ -136,7 +136,7 @@ class CommandCSMode : public Command
source.Reply(_("Missing parameter for mode %c."), cm->ModeChar);
else
{
- if (ci->RemoveMLock(cm, mode_param))
+ if (ci->RemoveMLock(cm, adding, mode_param))
{
if (!mode_param.empty())
mode_param = " " + mode_param;
@@ -144,7 +144,7 @@ class CommandCSMode : public Command
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->ModeChar << mode_param;
}
else
- source.Reply(_("%c is not locked on %s."), cm->ModeChar, ci->name.c_str());
+ source.Reply(_("%c%c is not locked on %s."), adding == 1 ? '+' : '-', cm->ModeChar, ci->name.c_str());
}
}
}
diff --git a/modules/commands/cs_set_persist.cpp b/modules/commands/cs_set_persist.cpp
index 4136a2fa2..4a1d676dd 100644
--- a/modules/commands/cs_set_persist.cpp
+++ b/modules/commands/cs_set_persist.cpp
@@ -99,7 +99,7 @@ class CommandCSSetPersist : public Command
if (ci->c && ci->c->HasMode(CMODE_PERM))
ci->c->RemoveMode(NULL, cm);
/* Remove from mlock */
- ci->RemoveMLock(cm);
+ ci->RemoveMLock(cm, true);
}
/* No channel mode, no BotServ, but using ChanServ as the botserv bot
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index bf85f5809..34a578917 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -806,10 +806,11 @@ bool ChannelInfo::SetMLock(ChannelMode *mode, bool status, const Anope::string &
/** Remove a mlock
* @param mode The mode
+ * @param status True for mlock on, false for mlock off
* @param param The param of the mode, required if it is a list or status mode
* @return true on success, false on failure
*/
-bool ChannelInfo::RemoveMLock(ChannelMode *mode, const Anope::string &param)
+bool ChannelInfo::RemoveMLock(ChannelMode *mode, bool status, const Anope::string &param)
{
if (mode->Type == MODE_REGULAR || mode->Type == MODE_PARAM)
{
@@ -817,13 +818,21 @@ bool ChannelInfo::RemoveMLock(ChannelMode *mode, const Anope::string &param)
if (it != this->mode_locks.end())
for (; it != it_end; it = it_next)
{
+ const ModeLock &ml = it->second;
++it_next;
+
+ if (status != ml.set)
+ continue;
+
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnUnMLock, OnUnMLock(this, &it->second));
if (MOD_RESULT != EVENT_STOP)
+ {
this->mode_locks.erase(it);
+ return true;
+ }
}
- return true;
+ return false;
}
else
{
@@ -835,7 +844,7 @@ bool ChannelInfo::RemoveMLock(ChannelMode *mode, const Anope::string &param)
for (; it != it_end; ++it)
{
const ModeLock &ml = it->second;
- if (ml.param == param)
+ if (ml.set == status && ml.param == param)
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnUnMLock, OnUnMLock(this, &it->second));