diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/channels.cpp | 4 | ||||
-rw-r--r-- | src/mode.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_namedmodes.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_permchannels.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/translate.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/uid.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 2 |
7 files changed, 22 insertions, 22 deletions
diff --git a/src/channels.cpp b/src/channels.cpp index 7f2485a49..a757cdc5a 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -138,7 +138,7 @@ void Channel::SetDefaultModes() if (mode->IsPrefixMode()) continue; - if (mode->GetNumParams(true)) + if (mode->NeedsParam(true)) { list.GetToken(parameter); // If the parameter begins with a ':' then it's invalid @@ -148,7 +148,7 @@ void Channel::SetDefaultModes() else parameter.clear(); - if ((mode->GetNumParams(true)) && (parameter.empty())) + if ((mode->NeedsParam(true)) && (parameter.empty())) continue; mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, parameter, true); diff --git a/src/mode.cpp b/src/mode.cpp index 3762dc52e..8d3d9ccfa 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -44,18 +44,18 @@ ModeHandler::~ModeHandler() { } -int ModeHandler::GetNumParams(bool adding) +bool ModeHandler::NeedsParam(bool adding) const { switch (parameters_taken) { case PARAM_ALWAYS: - return 1; + return true; case PARAM_SETONLY: - return adding ? 1 : 0; + return adding; case PARAM_NONE: break; } - return 0; + return false; } std::string ModeHandler::GetUserParameter(User* user) @@ -219,7 +219,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode ModeHandler* mh = mcitem.mh; bool adding = mcitem.adding; - int pcnt = mh->GetNumParams(adding); + const bool needs_param = mh->NeedsParam(adding); std::string& parameter = mcitem.param; // crop mode parameter size to 250 characters @@ -283,7 +283,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode return MODEACTION_DENY; // A module whacked the parameter completely, and there was one. Abort. - if (pcnt && parameter.empty()) + if ((needs_param) && (parameter.empty())) return MODEACTION_DENY; } } @@ -318,7 +318,7 @@ ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, Mode /* Call the handler for the mode */ ModeAction ma = mh->OnModeChange(user, targetuser, chan, parameter, adding); - if (pcnt && parameter.empty()) + if ((needs_param) && (parameter.empty())) return MODEACTION_DENY; if (ma != MODEACTION_ALLOW) @@ -363,7 +363,7 @@ void ModeParser::ModeParamsToChangeList(User* user, ModeType type, const std::ve } std::string parameter; - if (mh->GetNumParams(adding) && param_at < endindex) + if ((mh->NeedsParam(adding)) && (param_at < endindex)) parameter = parameters[param_at++]; changelist.push(mh, adding, parameter); @@ -432,7 +432,7 @@ unsigned int ModeParser::ProcessSingle(User* user, Channel* targetchannel, User* // If the mode is supposed to have a parameter then we first take a look at item.param // and, if we were asked to, also handle mode merges now - if (mh->GetNumParams(item.adding)) + if (mh->NeedsParam(item.adding)) { // Skip the mode if the parameter does not pass basic validation if (!IsModeParamValid(user, targetchannel, targetuser, item)) @@ -719,7 +719,7 @@ std::string ModeParser::CreateModeList(ModeType mt, bool needparam) for (unsigned char mode = 'A'; mode <= 'z'; mode++) { ModeHandler* mh = modehandlers[mt][mode-65]; - if ((mh) && ((!needparam) || (mh->GetNumParams(true)))) + if ((mh) && ((!needparam) || (mh->NeedsParam(true)))) modestr.push_back(mode); } @@ -756,7 +756,7 @@ std::string ModeParser::GiveModeList(ModeType mt) /* One parameter when adding */ if (mh) { - if (mh->GetNumParams(true)) + if (mh->NeedsParam(true)) { PrefixMode* pm = mh->IsPrefixMode(); if ((mh->IsListMode()) && ((!pm) || (pm->GetPrefix() == 0))) @@ -766,7 +766,7 @@ std::string ModeParser::GiveModeList(ModeType mt) else { /* ... and one parameter when removing */ - if (mh->GetNumParams(false)) + if (mh->NeedsParam(false)) { /* But not a list mode */ if (!pm) @@ -858,7 +858,7 @@ void ModeHandler::RemoveMode(Channel* channel, Modes::ChangeList& changelist) { if (channel->IsModeSet(this)) { - if (this->GetNumParams(false)) + if (this->NeedsParam(false)) // Removing this mode requires a parameter changelist.push_remove(this, channel->GetModeParameter(this)); else diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp index d4263d899..7a86c9e3c 100644 --- a/src/modules/m_namedmodes.cpp +++ b/src/modules/m_namedmodes.cpp @@ -31,7 +31,7 @@ static void DisplayList(LocalUser* user, Channel* channel) if (!channel->IsModeSet(mh)) continue; numeric.Add("+" + mh->name); - if (mh->GetNumParams(true)) + if (mh->NeedsParam(true)) { if ((mh->name == "key") && (!channel->HasUser(user)) && (!user->HasPrivPermission("channels/auspex"))) numeric.Add("<key>"); @@ -80,7 +80,7 @@ class CommandProp : public SplitCommand ModeHandler* mh = ServerInstance->Modes->FindMode(prop, MODETYPE_CHANNEL); if (mh) { - if (mh->GetNumParams(plus)) + if (mh->NeedsParam(plus)) { if (i != parameters.size()) modes.push(mh, plus, parameters[i++]); @@ -161,7 +161,7 @@ class ModuleNamedModes : public Module } curr.param.clear(); - if (mh->GetNumParams(curr.adding)) + if (mh->NeedsParam(curr.adding)) { if (value.empty()) { diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index 9a5da5ce4..9e77bd60e 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -236,7 +236,7 @@ public: ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL); if (mode) { - if (mode->GetNumParams(true)) + if (mode->NeedsParam(true)) list.GetToken(par); else par.clear(); diff --git a/src/modules/m_spanningtree/translate.cpp b/src/modules/m_spanningtree/translate.cpp index 48c0632e5..66e1bb35b 100644 --- a/src/modules/m_spanningtree/translate.cpp +++ b/src/modules/m_spanningtree/translate.cpp @@ -27,7 +27,7 @@ std::string Translate::ModeChangeListToParams(const Modes::ChangeList::List& mod { const Modes::Change& item = *i; ModeHandler* mh = item.mh; - if (!mh->GetNumParams(item.adding)) + if (!mh->NeedsParam(item.adding)) continue; ret.push_back(' '); diff --git a/src/modules/m_spanningtree/uid.cpp b/src/modules/m_spanningtree/uid.cpp index eff537119..a41fe408d 100644 --- a/src/modules/m_spanningtree/uid.cpp +++ b/src/modules/m_spanningtree/uid.cpp @@ -98,7 +98,7 @@ CmdResult CommandUID::HandleServer(TreeServer* remoteserver, std::vector<std::st if (!mh) throw ProtocolException("Unrecognised mode '" + std::string(1, *v) + "'"); - if (mh->GetNumParams(true)) + if (mh->NeedsParam(true)) { if (paramptr >= params.size() - 1) throw ProtocolException("Out of parameters while processing modes"); diff --git a/src/users.cpp b/src/users.cpp index 24b2928ae..c57b6fc14 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -51,7 +51,7 @@ const char* User::FormatModes(bool showparameters) if (mh && IsModeSet(mh)) { data.push_back(n + 65); - if (showparameters && mh->GetNumParams(true)) + if (showparameters && mh->NeedsParam(true)) { std::string p = mh->GetUserParameter(this); if (p.length()) |