From 269f12c2723d3a4486f14196b14aab8ce7aff36d Mon Sep 17 00:00:00 2001 From: danieldg Date: Sat, 7 Mar 2009 05:47:09 +0000 Subject: Fix +k for real git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11185 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modes/cmode_k.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src') 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 parameters; parameters.push_back(channel->name); parameters.push_back("-k"); parameters.push_back(channel->GetModeParameter('k')); + std::vector 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; } -- cgit v1.2.3