diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-06-13 19:00:01 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-06-13 19:00:01 +0200 |
commit | 95593de52c9b89dd3dae8d79a2c76efc81d9d353 (patch) | |
tree | c99c8b3172b299a7d520faf7b5e69d0e3196aa05 /src | |
parent | c25a59d9036444872d831a126c6326f3d8be5e74 (diff) |
Call Channel::SetModeParam() from the mode parser when needed instead of requiring mode handlers to do it
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 5 | ||||
-rw-r--r-- | src/mode.cpp | 7 | ||||
-rw-r--r-- | src/modes/cmode_k.cpp | 19 | ||||
-rw-r--r-- | src/modules/m_chanhistory.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_delaymsg.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_joinflood.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_kicknorejoin.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_messageflood.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_nickflood.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_redirect.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_repeat.cpp | 2 |
11 files changed, 6 insertions, 40 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 0d43bc802..b8629bf2c 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -56,12 +56,9 @@ void Channel::SetMode(ModeHandler* mh, bool on) void Channel::SetModeParam(char mode, const std::string& parameter) { - CustomModeList::iterator n = custom_mode_params.find(mode); - // always erase, even if changing, so that the map gets the new value - if (n != custom_mode_params.end()) - custom_mode_params.erase(n); if (parameter.empty()) { + custom_mode_params.erase(mode); modes[mode-65] = false; } else diff --git a/src/mode.cpp b/src/mode.cpp index 9c38afaad..1e1c7a25c 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -134,10 +134,6 @@ ModeAction ParamChannelModeHandler::OnModeChange(User* source, User* dest, Chann std::string now = channel->GetModeParameter(this); if (parameter == now) return MODEACTION_DENY; - if (adding) - channel->SetModeParam(this, parameter); - else - channel->SetModeParam(this, ""); return MODEACTION_ALLOW; } @@ -320,6 +316,9 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool if (ma != MODEACTION_ALLOW) return ma; + if ((!mh->IsListMode()) && (mh->GetNumParams(true)) && (chan)) + chan->SetModeParam(mh, (adding ? parameter : "")); + itpair = modewatchermap.equal_range(mh->name); for (ModeWatchIter i = itpair.first; i != itpair.second; ++i) { diff --git a/src/modes/cmode_k.cpp b/src/modes/cmode_k.cpp index cb9ec5b0e..f07d47172 100644 --- a/src/modes/cmode_k.cpp +++ b/src/modes/cmode_k.cpp @@ -50,23 +50,8 @@ ModeAction ModeChannelKey::OnModeChange(User* source, User*, Channel* channel, s } } - /* invalid keys */ - if (!parameter.length()) - return MODEACTION_DENY; - - if (parameter.rfind(' ') != std::string::npos) - return MODEACTION_DENY; - if (adding) - { - std::string ckey; - ckey.assign(parameter, 0, 32); - parameter = ckey; - channel->SetModeParam('k', parameter); - } - else - { - channel->SetModeParam('k', ""); - } + parameter = parameter.substr(0, 32); + return MODEACTION_ALLOW; } diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index c114891bb..9c4f644d7 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -94,14 +94,12 @@ class HistoryMode : public ModeHandler { ext.set(channel, new HistoryList(len, time)); } - channel->SetModeParam('H', parameter); } else { if (!channel->IsModeSet('H')) return MODEACTION_DENY; ext.unset(channel); - channel->SetModeParam('H', ""); } return MODEACTION_ALLOW; } diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp index 8391dc45e..aeb4e4932 100644 --- a/src/modules/m_delaymsg.cpp +++ b/src/modules/m_delaymsg.cpp @@ -87,7 +87,6 @@ ModeAction DelayMsgMode::OnModeChange(User* source, User* dest, Channel* channel for (UserMembCIter n = names->begin(); n != names->end(); ++n) jointime.set(n->second, 0); } - channel->SetModeParam('d', adding ? parameter : ""); return MODEACTION_ALLOW; } diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index fde974559..53277150a 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -119,7 +119,6 @@ class JoinFlood : public ModeHandler ext.set(channel, jfs); parameter = ConvToStr(njoins) + ":" + ConvToStr(nsecs); - channel->SetModeParam(this, parameter); return MODEACTION_ALLOW; } else @@ -131,7 +130,6 @@ class JoinFlood : public ModeHandler if (f) { ext.unset(channel); - channel->SetModeParam(this, ""); return MODEACTION_ALLOW; } } diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 3406f4f99..01d3aee71 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -56,7 +56,6 @@ class KickRejoin : public ModeHandler v = max; parameter = ConvToStr(v); - channel->SetModeParam(this, parameter); } else { @@ -64,7 +63,6 @@ class KickRejoin : public ModeHandler return MODEACTION_DENY; ext.unset(channel); - channel->SetModeParam(this, ""); } return MODEACTION_ALLOW; } diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 86296094b..2e91cdf06 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -102,7 +102,6 @@ class MsgFlood : public ModeHandler ext.set(channel, new floodsettings(ban, nsecs, nlines)); parameter = std::string(ban ? "*" : "") + ConvToStr(nlines) + ":" + ConvToStr(nsecs); - channel->SetModeParam('f', parameter); return MODEACTION_ALLOW; } else @@ -111,7 +110,6 @@ class MsgFlood : public ModeHandler return MODEACTION_DENY; ext.unset(channel); - channel->SetModeParam('f', ""); return MODEACTION_ALLOW; } } diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index de9b64f99..61347ded0 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -115,7 +115,6 @@ class NickFlood : public ModeHandler ext.set(channel, new nickfloodsettings(nsecs, nnicks)); parameter = ConvToStr(nnicks) + ":" + ConvToStr(nsecs); - channel->SetModeParam('F', parameter); return MODEACTION_ALLOW; } else @@ -124,7 +123,6 @@ class NickFlood : public ModeHandler return MODEACTION_DENY; ext.unset(channel); - channel->SetModeParam('F', ""); return MODEACTION_ALLOW; } } diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 000d53a2e..e40339fa6 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -70,14 +70,12 @@ class Redirect : public ModeHandler * We used to do some checking for circular +L here, but there is no real need for this any more especially as we * now catch +L looping in PreJoin. Remove it, since O(n) logic makes me sad, and we catch it anyway. :) -- w00t */ - channel->SetModeParam('L', parameter); return MODEACTION_ALLOW; } else { if (channel->IsModeSet('L')) { - channel->SetModeParam('L', ""); return MODEACTION_ALLOW; } } diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index 86f26016d..342ee9783 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -131,7 +131,6 @@ class RepeatMode : public ModeHandler MemberInfoExt.unset(i->second); ChanSet.unset(channel); - channel->SetModeParam(this, ""); return MODEACTION_ALLOW; } @@ -156,7 +155,6 @@ class RepeatMode : public ModeHandler return MODEACTION_DENY; ChanSet.set(channel, settings); - channel->SetModeParam(this, parameter); return MODEACTION_ALLOW; } |