diff options
| author | 2022-05-17 13:41:40 +0100 | |
|---|---|---|
| committer | 2022-05-17 13:45:18 +0100 | |
| commit | c31e4c6a970b844e500f3feb807e1801b2d55543 (patch) | |
| tree | 8ccef31dd5f1dbe97ee42573bbfe54beae2e5f7e /src/modules | |
| parent | Store a set of list mode pointers in Membership instead of characters. (diff) | |
Add a typedef for a mode rank.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_autoop.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_customprefix.cpp | 22 | ||||
| -rw-r--r-- | src/modules/m_exemptchanops.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_hidelist.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_hidemode.cpp | 4 | ||||
| -rw-r--r-- | src/modules/m_ircv3_ctctags.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_ircv3_invitenotify.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_ojoin.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_operprefix.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_override.cpp | 4 | ||||
| -rw-r--r-- | src/modules/m_remove.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/main.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/main.h | 2 | ||||
| -rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 2 | ||||
| -rw-r--r-- | src/modules/m_timedbans.cpp | 2 |
15 files changed, 32 insertions, 30 deletions
diff --git a/src/modules/m_autoop.cpp b/src/modules/m_autoop.cpp index 23b4b9c0d..c7bd7039c 100644 --- a/src/modules/m_autoop.cpp +++ b/src/modules/m_autoop.cpp @@ -57,7 +57,7 @@ public: if (pos == 0 || pos == std::string::npos) return change.adding ? MOD_RES_DENY : MOD_RES_PASSTHRU; - unsigned int mylevel = channel->GetPrefixValue(source); + ModeHandler::Rank mylevel = channel->GetPrefixValue(source); std::string mid(change.param, 0, pos); PrefixMode* mh = FindMode(mid); diff --git a/src/modules/m_customprefix.cpp b/src/modules/m_customprefix.cpp index 093f8a9e0..5dce050a3 100644 --- a/src/modules/m_customprefix.cpp +++ b/src/modules/m_customprefix.cpp @@ -32,14 +32,15 @@ public: : PrefixMode(parent, Name, Letter, 0, Prefix) , tag(Tag) { - unsigned int rank = static_cast<unsigned int>(tag->getUInt("rank", 1, 1, UINT_MAX)); - unsigned int setrank = static_cast<unsigned int>(tag->getUInt("ranktoset", prefixrank, rank, UINT_MAX)); - unsigned int unsetrank = static_cast<unsigned int>(tag->getUInt("ranktounset", setrank, setrank, UINT_MAX)); + ModeHandler::Rank rank = static_cast<ModeHandler::Rank>(tag->getUInt("rank", 1, 1, std::numeric_limits<ModeHandler::Rank>::max())); + ModeHandler::Rank setrank = static_cast<ModeHandler::Rank>(tag->getUInt("ranktoset", prefixrank, rank, std::numeric_limits<ModeHandler::Rank>::max())); + ModeHandler::Rank unsetrank = static_cast<ModeHandler::Rank>(tag->getUInt("ranktounset", setrank, setrank, std::numeric_limits<ModeHandler::Rank>::max())); bool depriv = tag->getBool("depriv", true); this->Update(rank, setrank, unsetrank, depriv); - ServerInstance->Logs.Debug(MODNAME, "Created the %s prefix: letter=%c prefix=%c rank=%u ranktoset=%u ranktounset=%i depriv=%d", - name.c_str(), GetModeChar(), GetPrefix(), GetPrefixRank(), GetLevelRequired(true), GetLevelRequired(false), CanSelfRemove()); + ServerInstance->Logs.Debug(MODNAME, "Created the %s prefix: letter=%c prefix=%c rank=%lu ranktoset=%lu ranktounset=%lu depriv=%s", + name.c_str(), GetModeChar(), GetPrefix(), GetPrefixRank(), GetLevelRequired(true), GetLevelRequired(false), + CanSelfRemove() ? "yes" : "no"); } }; @@ -76,14 +77,15 @@ public: if (!pm) throw ModuleException(this, "<customprefix:change> specified for a non-prefix mode at " + tag->source.str()); - unsigned int rank = static_cast<unsigned int>(tag->getUInt("rank", pm->GetPrefixRank(), 0, UINT_MAX)); - unsigned int setrank = static_cast<unsigned int>(tag->getUInt("ranktoset", pm->GetLevelRequired(true), rank, UINT_MAX)); - unsigned int unsetrank = static_cast<unsigned int>(tag->getUInt("ranktounset", pm->GetLevelRequired(false), setrank, UINT_MAX)); + ModeHandler::Rank rank = static_cast<ModeHandler::Rank>(tag->getUInt("rank", pm->GetPrefixRank(), 1, std::numeric_limits<ModeHandler::Rank>::max())); + ModeHandler::Rank setrank = static_cast<ModeHandler::Rank>(tag->getUInt("ranktoset", pm->GetLevelRequired(true), rank, std::numeric_limits<ModeHandler::Rank>::max())); + ModeHandler::Rank unsetrank = static_cast<ModeHandler::Rank>(tag->getUInt("ranktounset", pm->GetLevelRequired(false), setrank, std::numeric_limits<ModeHandler::Rank>::max())); bool depriv = tag->getBool("depriv", pm->CanSelfRemove()); pm->Update(rank, setrank, unsetrank, depriv); - ServerInstance->Logs.Debug(MODNAME, "Changed the %s prefix: depriv=%u rank=%u ranktoset=%u ranktounset=%u", - pm->name.c_str(), pm->CanSelfRemove(), pm->GetPrefixRank(), pm->GetLevelRequired(true), pm->GetLevelRequired(false)); + ServerInstance->Logs.Debug(MODNAME, "Changed the %s prefix: letter=%c prefix=%c rank=%lu ranktoset=%lu ranktounset=%lu depriv=%s", + name.c_str(), pm->GetModeChar(), pm->GetPrefix(), pm->GetPrefixRank(), pm->GetLevelRequired(true), + pm->GetLevelRequired(false), pm->CanSelfRemove() ? "yes" : "no"); continue; } diff --git a/src/modules/m_exemptchanops.cpp b/src/modules/m_exemptchanops.cpp index c384e723f..9c366f1f3 100644 --- a/src/modules/m_exemptchanops.cpp +++ b/src/modules/m_exemptchanops.cpp @@ -127,7 +127,7 @@ public: ModResult OnCheckExemption(User* user, Channel* chan, const std::string& restriction) override { - unsigned int mypfx = chan->GetPrefixValue(user); + ModeHandler::Rank mypfx = chan->GetPrefixValue(user); std::string minmode; ListModeBase::ModeList* list = ec.GetList(chan); diff --git a/src/modules/m_hidelist.cpp b/src/modules/m_hidelist.cpp index 00d9a615d..27903e8eb 100644 --- a/src/modules/m_hidelist.cpp +++ b/src/modules/m_hidelist.cpp @@ -25,10 +25,10 @@ class ListWatcher final : public ModeWatcher { // Minimum rank required to view the list - const unsigned int minrank; + const ModeHandler::Rank minrank; public: - ListWatcher(Module* mod, const std::string& modename, unsigned int rank) + ListWatcher(Module* mod, const std::string& modename, ModeHandler::Rank rank) : ModeWatcher(mod, modename, MODETYPE_CHANNEL) , minrank(rank) { @@ -70,7 +70,7 @@ public: throw ModuleException(this, "Empty <hidelist:mode> at " + tag->source.str()); // If rank is set to 0 everyone inside the channel can view the list, // but non-members may not - unsigned long rank = tag->getUInt("rank", HALFOP_VALUE); + ModeHandler::Rank rank = tag->getUInt("rank", HALFOP_VALUE); newconfigs.push_back(std::make_pair(modename, rank)); } diff --git a/src/modules/m_hidemode.cpp b/src/modules/m_hidemode.cpp index 56acdd01e..2dee42a2a 100644 --- a/src/modules/m_hidemode.cpp +++ b/src/modules/m_hidemode.cpp @@ -62,7 +62,7 @@ public: class ModeHook final : public ClientProtocol::EventHook { - typedef insp::flat_map<unsigned int, const ClientProtocol::MessageList*> FilteredModeMap; + typedef insp::flat_map<ModeHandler::Rank, const ClientProtocol::MessageList*> FilteredModeMap; std::vector<Modes::ChangeList> modechangelists; std::list<ClientProtocol::Messages::Mode> filteredmodelist; @@ -82,7 +82,7 @@ class ModeHook final return MOD_RES_PASSTHRU; } - Modes::ChangeList* FilterModeChangeList(const ClientProtocol::Events::Mode& mode, unsigned int rank) + Modes::ChangeList* FilterModeChangeList(const ClientProtocol::Events::Mode& mode, ModeHandler::Rank rank) { Modes::ChangeList* modechangelist = NULL; for (Modes::ChangeList::List::const_iterator i = mode.GetChangeList().getlist().begin(); i != mode.GetChangeList().getlist().end(); ++i) diff --git a/src/modules/m_ircv3_ctctags.cpp b/src/modules/m_ircv3_ctctags.cpp index b2b059a7a..afa5341dc 100644 --- a/src/modules/m_ircv3_ctctags.cpp +++ b/src/modules/m_ircv3_ctctags.cpp @@ -82,7 +82,7 @@ private: if (!FirePreEvents(source, msgtarget, msgdetails)) return CmdResult::FAILURE; - unsigned int minrank = pm ? pm->GetPrefixRank() : 0; + ModeHandler::Rank minrank = pm ? pm->GetPrefixRank() : 0; CTCTags::TagMessage message(source, chan, msgdetails.tags_out, msgtarget.status); message.SetSideEffect(true); diff --git a/src/modules/m_ircv3_invitenotify.cpp b/src/modules/m_ircv3_invitenotify.cpp index 916d6fa6f..a5fe298d6 100644 --- a/src/modules/m_ircv3_invitenotify.cpp +++ b/src/modules/m_ircv3_invitenotify.cpp @@ -33,7 +33,7 @@ public: { } - void OnUserInvite(User* source, User* dest, Channel* chan, time_t expiry, unsigned int notifyrank, CUList& notifyexcepts) override + void OnUserInvite(User* source, User* dest, Channel* chan, time_t expiry, ModeHandler::Rank notifyrank, CUList& notifyexcepts) override { ClientProtocol::Messages::Invite invitemsg(source, dest, chan); ClientProtocol::Event inviteevent(ServerInstance->GetRFCEvents().invite, invitemsg); diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index 76e0e51f6..7b28bff3f 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -91,7 +91,7 @@ public: NetworkPrefix(Module* parent, char NPrefix) : PrefixMode(parent, "official-join", 'Y', NETWORK_VALUE, NPrefix) { - ranktoset = ranktounset = UINT_MAX; + ranktoset = ranktounset = std::numeric_limits<ModeHandler::Rank>::max(); } ModResult AccessCheck(User* source, Channel* channel, Modes::Change& change) override diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index 3e22ddd8c..bc8236798 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -39,7 +39,7 @@ class OperPrefixMode final : PrefixMode(Creator, "operprefix", 'y', OPERPREFIX_VALUE) { prefix = ServerInstance->Config->ConfValue("operprefix")->getCharacter("prefix", '!'); - ranktoset = ranktounset = UINT_MAX; + ranktoset = ranktounset = std::numeric_limits<ModeHandler::Rank>::max(); } }; diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 684557820..7823b1869 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -99,7 +99,7 @@ private: ChanModeReference limit; Invite::API invapi; - static bool IsOverride(unsigned int userlevel, const Modes::ChangeList::List& list) + static bool IsOverride(ModeHandler::Rank userlevel, const Modes::ChangeList::List& list) { for (const auto& change : list) { @@ -206,7 +206,7 @@ public: return MOD_RES_PASSTHRU; const Modes::ChangeList::List& list = modes.getlist(); - unsigned int mode = channel->GetPrefixValue(source); + ModeHandler::Rank mode = channel->GetPrefixValue(source); if (!IsOverride(mode, list)) return MOD_RES_PASSTHRU; diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index 5b41b1ccf..0ffaa007a 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -39,7 +39,7 @@ private: UserModeReference servprotectmode; public: - unsigned long protectedrank; + ModeHandler::Rank protectedrank; bool supportnokicks; CommandRemove(Module* Creator) @@ -100,8 +100,8 @@ public: * a services target will get a higher level than it's possible for a /remover to get..so they're safe. * Nobody may remove people with >= protectedrank rank. */ - unsigned int ulevel = channel->GetPrefixValue(user); - unsigned int tlevel = channel->GetPrefixValue(target); + ModeHandler::Rank ulevel = channel->GetPrefixValue(user); + ModeHandler::Rank tlevel = channel->GetPrefixValue(target); if ((!IS_LOCAL(user)) || ((ulevel > VOICE_VALUE) && (ulevel >= tlevel) && ((protectedrank == 0) || (tlevel < protectedrank)))) { // REMOVE will be sent to the target's server and it will reply with a PART (or do nothing if it doesn't understand the command) diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index fd130c787..cc5f27ccc 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -374,7 +374,7 @@ ModResult ModuleSpanningTree::HandleConnect(const CommandBase::Params& parameter return MOD_RES_DENY; } -void ModuleSpanningTree::OnUserInvite(User* source, User* dest, Channel* channel, time_t expiry, unsigned int notifyrank, CUList& notifyexcepts) +void ModuleSpanningTree::OnUserInvite(User* source, User* dest, Channel* channel, time_t expiry, ModeHandler::Rank notifyrank, CUList& notifyexcepts) { if (IS_LOCAL(source)) { diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 81ac1e9eb..d4edfebef 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -179,7 +179,7 @@ public: ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) override; void OnPostCommand(Command*, const CommandBase::Params& parameters, LocalUser* user, CmdResult result, bool loop) override; void OnUserConnect(LocalUser* source) override; - void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, unsigned int notifyrank, CUList& notifyexcepts) override; + void OnUserInvite(User* source, User* dest, Channel* channel, time_t timeout, ModeHandler::Rank notifyrank, CUList& notifyexcepts) override; ModResult OnPreTopicChange(User* user, Channel* chan, const std::string& topic) override; void OnPostTopicChange(User* user, Channel* chan, const std::string &topic) override; void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) override; diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index e104bd63d..1d42af1ea 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -137,7 +137,7 @@ SpanningTreeUtilities::~SpanningTreeUtilities() // Returns a list of DIRECT servers for a specific channel void SpanningTreeUtilities::GetListOfServersForChannel(Channel* c, TreeSocketSet& list, char status, const CUList& exempt_list) { - unsigned int minrank = 0; + ModeHandler::Rank minrank = 0; if (status) { PrefixMode* mh = ServerInstance->Modes.FindPrefix(status); diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index f33d5d43b..432d1d09a 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -89,7 +89,7 @@ public: return CmdResult::FAILURE; } - unsigned int cm = channel->GetPrefixValue(user); + ModeHandler::Rank cm = channel->GetPrefixValue(user); if (cm < HALFOP_VALUE) { user->WriteNumeric(Numerics::ChannelPrivilegesNeeded(channel, HALFOP_VALUE, "set timed bans")); |
