diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-08-30 16:19:31 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-08-30 16:19:31 +0200 |
commit | e0931343939bc15ea9aaa884eab61d80827074c6 (patch) | |
tree | 7842c30db2823be50e739412e097fa899bb5ea6c | |
parent | cf6a8ee7e3fb11ea19d627216f53118c563a0a71 (diff) |
Change Membership:hasMode() to accept a PrefixMode
-rw-r--r-- | include/membership.h | 8 | ||||
-rw-r--r-- | src/coremods/core_reloadmodule.cpp | 3 | ||||
-rw-r--r-- | src/mode.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_channelban.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_ojoin.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_operprefix.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_rmode.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_servprotect.cpp | 6 |
8 files changed, 17 insertions, 12 deletions
diff --git a/include/membership.h b/include/membership.h index 05d6b3796..92e0f790b 100644 --- a/include/membership.h +++ b/include/membership.h @@ -70,13 +70,13 @@ class CoreExport Membership : public Extensible, public insp::intrusive_list_nod */ Membership(User* u, Channel* c) : user(u), chan(c) {} - /** Returns true if this member has a given prefix mode set - * @param m The prefix mode letter to check + /** Check if this member has a given prefix mode set + * @param pm Prefix mode to check * @return True if the member has the prefix mode set, false otherwise */ - inline bool hasMode(char m) const + bool HasMode(const PrefixMode* pm) const { - return modes.find(m) != std::string::npos; + return (modes.find(pm->GetModeChar()) != std::string::npos); } /** Returns the rank of this member. diff --git a/src/coremods/core_reloadmodule.cpp b/src/coremods/core_reloadmodule.cpp index 6fcec8ac2..68db9e25a 100644 --- a/src/coremods/core_reloadmodule.cpp +++ b/src/coremods/core_reloadmodule.cpp @@ -353,7 +353,8 @@ void DataKeeper::SaveMemberData(Channel* chan, std::vector<OwnedModesExts>& memb for (size_t j = 0; j < handledmodes[MODETYPE_CHANNEL].size(); j++) { ModeHandler* mh = handledmodes[MODETYPE_CHANNEL][j].mh; - if ((mh->IsPrefixMode()) && (memb->hasMode(mh->GetModeChar()))) + const PrefixMode* const pm = mh->IsPrefixMode(); + if ((pm) && (memb->HasMode(pm))) currdata.modelist.push_back(InstanceData(j, memb->user->uuid)); // Need to pass the user's uuid to the mode parser to set the mode later } diff --git a/src/mode.cpp b/src/mode.cpp index d58944f1f..fec614ab4 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -867,7 +867,7 @@ void PrefixMode::RemoveMode(Channel* chan, Modes::ChangeList& changelist) const Channel::MemberMap& userlist = chan->GetUsers(); for (Channel::MemberMap::const_iterator i = userlist.begin(); i != userlist.end(); ++i) { - if (i->second->hasMode(this->GetModeChar())) + if (i->second->HasMode(this)) changelist.push_remove(this, i->first->nick); } } diff --git a/src/modules/m_channelban.cpp b/src/modules/m_channelban.cpp index 189c0d0bc..ffb43eef1 100644 --- a/src/modules/m_channelban.cpp +++ b/src/modules/m_channelban.cpp @@ -34,7 +34,7 @@ class ModuleBadChannelExtban : public Module { std::string rm(mask, 2); char status = 0; - ModeHandler* mh = ServerInstance->Modes->FindPrefix(rm[0]); + const PrefixMode* const mh = ServerInstance->Modes->FindPrefix(rm[0]); if (mh) { rm.assign(mask, 3, std::string::npos); @@ -44,7 +44,7 @@ class ModuleBadChannelExtban : public Module { if (InspIRCd::Match((*i)->chan->name, rm)) { - if (!status || (*i)->hasMode(status)) + if ((!status) || ((*i)->HasMode(mh))) return MOD_RES_DENY; } } diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index 56cef10b4..2573e8b78 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -139,7 +139,7 @@ class ModuleOjoin : public Module ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason) CXX11_OVERRIDE { // Don't do anything if they're not +Y - if (!memb->hasMode(np.GetModeChar())) + if (!memb->HasMode(&np)) return MOD_RES_PASSTHRU; // Let them do whatever they want to themselves. diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index 51281a528..d66f99450 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -77,7 +77,7 @@ class ModuleOperPrefixMode : public Module if ((!IS_LOCAL(memb->user)) || (!memb->user->IsOper()) || (memb->user->IsModeSet(hideopermode))) return; - if (memb->hasMode(opm.GetModeChar())) + if (memb->HasMode(&opm)) return; // The user was force joined and OnUserPreJoin() did not run. Set the operprefix now. diff --git a/src/modules/m_rmode.cpp b/src/modules/m_rmode.cpp index feb17383d..37c6e62ff 100644 --- a/src/modules/m_rmode.cpp +++ b/src/modules/m_rmode.cpp @@ -70,7 +70,7 @@ class CommandRMode : public Command { if (!InspIRCd::Match(it->first->nick, pattern)) continue; - if (it->second->hasMode(modeletter) && !((it->first == user) && (pm->GetPrefixRank() > VOICE_VALUE))) + if (it->second->HasMode(pm) && !((it->first == user) && (pm->GetPrefixRank() > VOICE_VALUE))) changelist.push_remove(mh, it->first->nick); } } diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp index 88bde9b57..97670237b 100644 --- a/src/modules/m_servprotect.cpp +++ b/src/modules/m_servprotect.cpp @@ -73,6 +73,10 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public */ if (!adding && chan && IS_LOCAL(user) && !param.empty()) { + const PrefixMode* const pm = mh->IsPrefixMode(); + if (!pm) + return MOD_RES_PASSTHRU; + /* Check if the parameter is a valid nick/uuid */ User *u = ServerInstance->FindNick(param); @@ -83,7 +87,7 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public * This includes any prefix permission mode, even those registered in other modules, e.g. +qaohv. Using ::ModeString() * here means that the number of modes is restricted to only modes the user has, limiting it to as short a loop as possible. */ - if (u->IsModeSet(bm) && memb && memb->hasMode(mh->GetModeChar())) + if ((u->IsModeSet(bm)) && (memb) && (memb->HasMode(pm))) { /* BZZZT, Denied! */ user->WriteNumeric(ERR_CHANOPRIVSNEEDED, chan->name, InspIRCd::Format("You are not permitted to remove privileges from %s services", ServerInstance->Config->Network.c_str())); |