summaryrefslogtreecommitdiff
path: root/src/modes/cmode_k.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-03-07 05:47:09 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-03-07 05:47:09 +0000
commit269f12c2723d3a4486f14196b14aab8ce7aff36d (patch)
treeccb47c8d0118c8b2f6cab391b6f23a84c3d6930e /src/modes/cmode_k.cpp
parent2d004034febfecf9ba0662406df7ecec67efbacf (diff)
Fix +k for real
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11185 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modes/cmode_k.cpp')
-rw-r--r--src/modes/cmode_k.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp
index a09131354..de420cae2 100644
--- a/src/modes/cmode_k.cpp
+++ b/src/modes/cmode_k.cpp
@@ -40,15 +40,18 @@ void ModeChannelKey::RemoveMode(Channel* channel, irc::modestacker* stack)
* so we have a special-case RemoveMode here for it
*/
- if (channel->IsModeSet(this->GetModeChar()))
+ if (channel->IsModeSet('k'))
{
if (stack)
{
- stack->Push(this->GetModeChar(), channel->GetModeParameter('k'));
+ stack->Push('k', channel->GetModeParameter('k'));
}
else
{
- std::vector<std::string> parameters; parameters.push_back(channel->name); parameters.push_back("-k"); parameters.push_back(channel->GetModeParameter('k'));
+ std::vector<std::string> parameters;
+ parameters.push_back(channel->name);
+ parameters.push_back("-k");
+ parameters.push_back(channel->GetModeParameter('k'));
ServerInstance->SendMode(parameters, ServerInstance->FakeClient);
}
}
@@ -91,11 +94,20 @@ ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, s
if (parameter.rfind(' ') != std::string::npos)
return MODEACTION_DENY;
- std::string ckey;
- ckey.assign(parameter, 0, 32);
- parameter = ckey;
- if (adding && exists)
+ /* must first unset if we are changing the key, otherwise it will be ignored */
+ if (exists && adding)
channel->SetMode('k', false);
- channel->SetModeParam('k', parameter.c_str(), adding);
+
+ /* must run setmode always, to process the change */
+ channel->SetMode('k', adding);
+
+ if (adding)
+ {
+ std::string ckey;
+ ckey.assign(parameter, 0, 32);
+ parameter = ckey;
+ /* running this does not run setmode, despite the third parameter */
+ channel->SetModeParam('k', parameter.c_str(), true);
+ }
return MODEACTION_ALLOW;
}