diff options
| author | 2023-01-22 22:01:25 +0000 | |
|---|---|---|
| committer | 2023-01-22 22:52:30 +0000 | |
| commit | 8389fbba6d92dec84745e5b8db4739f97561585e (patch) | |
| tree | a1ef829a156d002639035acec8bab8a4e8d1bdfd /src/modules | |
| parent | Convert various enums to strongly typed scoped enums. (diff) | |
| download | inspircd++-8389fbba6d92dec84745e5b8db4739f97561585e.tar.gz inspircd++-8389fbba6d92dec84745e5b8db4739f97561585e.tar.bz2 inspircd++-8389fbba6d92dec84745e5b8db4739f97561585e.zip | |
Replace ModeAction with bool.
This enum is functionally the same as bool but with weird semantics.
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/m_anticaps.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_chanhistory.cpp | 10 | ||||
| -rw-r--r-- | src/modules/m_cloak.cpp | 14 | ||||
| -rw-r--r-- | src/modules/m_deaf.cpp | 16 | ||||
| -rw-r--r-- | src/modules/m_delayjoin.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_delaymsg.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_hideoper.cpp | 8 | ||||
| -rw-r--r-- | src/modules/m_joinflood.cpp | 8 | ||||
| -rw-r--r-- | src/modules/m_kicknorejoin.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_messageflood.cpp | 8 | ||||
| -rw-r--r-- | src/modules/m_nickflood.cpp | 8 | ||||
| -rw-r--r-- | src/modules/m_override.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_permchannels.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_redirect.cpp | 10 | ||||
| -rw-r--r-- | src/modules/m_repeat.cpp | 10 | ||||
| -rw-r--r-- | src/modules/m_services.cpp | 8 | ||||
| -rw-r--r-- | src/modules/m_servprotect.cpp | 6 | ||||
| -rw-r--r-- | src/modules/m_sslmodes.cpp | 22 |
18 files changed, 82 insertions, 82 deletions
diff --git a/src/modules/m_anticaps.cpp b/src/modules/m_anticaps.cpp index 319e85cea..b7a4d4caa 100644 --- a/src/modules/m_anticaps.cpp +++ b/src/modules/m_anticaps.cpp @@ -111,7 +111,7 @@ public: syntax = "{ban|block|mute|kick|kickban}:<minlen>:<percent>"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { irc::sepstream stream(parameter, ':'); AntiCapsMethod method; @@ -122,11 +122,11 @@ public: if (!ParseMethod(stream, method) || !ParseMinimumLength(stream, minlen) || !ParsePercent(stream, percent)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } ext.SetFwd(channel, method, minlen, percent); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const AntiCapsSettings* acs, std::string& out) diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index 9e058c629..4a33451b8 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -87,20 +87,20 @@ public: syntax = "<max-messages>:<max-duration>"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { std::string::size_type colon = parameter.find(':'); if (colon == std::string::npos) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } std::string duration(parameter, colon+1); if ((IS_LOCAL(source)) && ((duration.length() > 10) || (!InspIRCd::IsValidDuration(duration)))) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } unsigned long len = ConvToNum<unsigned long>(parameter.substr(0, colon)); @@ -108,7 +108,7 @@ public: if (!InspIRCd::Duration(duration, time) || len == 0 || (len > maxlines && IS_LOCAL(source))) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } if (len > maxlines) len = maxlines; @@ -128,7 +128,7 @@ public: { ext.SetFwd(channel, len, time); } - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const HistoryList* history, std::string& out) diff --git a/src/modules/m_cloak.cpp b/src/modules/m_cloak.cpp index 50bb95ec4..8c02ffc1e 100644 --- a/src/modules/m_cloak.cpp +++ b/src/modules/m_cloak.cpp @@ -146,7 +146,7 @@ public: return cloaks->empty() ? nullptr : cloaks; } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { // For remote users blindly allow this LocalUser* user = IS_LOCAL(dest); @@ -155,12 +155,12 @@ public: // Remote setters broadcast mode before host while local setters do the opposite. active = IS_LOCAL(source) ? change.adding : !change.adding; dest->SetMode(this, change.adding); - return MODEACTION_ALLOW; + return true; } // Don't allow the mode change if its a no-op or a spam change. if (change.adding == user->IsModeSet(this) || CheckSpam(user)) - return MODEACTION_DENY; + return false; // Penalise changing the mode to avoid spam. if (source == dest) @@ -171,7 +171,7 @@ public: // Remove the mode and restore their real host. user->SetMode(this, false); user->ChangeDisplayedHost(user->GetRealHost()); - return MODEACTION_ALLOW; + return true; } // If a user is not fully connected and their displayed hostname is @@ -179,7 +179,7 @@ public: // them by services. We should avoid automatically setting cloak on // them in this case. if (!user->IsFullyConnected() && user->GetRealHost() != user->GetDisplayedHost()) - return MODEACTION_DENY; + return false; auto* cloaks = GetCloaks(user); if (cloaks) @@ -187,9 +187,9 @@ public: // We were able to generate cloaks for this user. user->ChangeDisplayedHost(cloaks->front()); user->SetMode(this, true); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } }; diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp index d8ee9bfcf..68c926697 100644 --- a/src/modules/m_deaf.cpp +++ b/src/modules/m_deaf.cpp @@ -38,15 +38,15 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - if (SimpleUserMode::OnModeChange(source, dest, channel, change) == MODEACTION_ALLOW) + if (SimpleUserMode::OnModeChange(source, dest, channel, change) == true) { dest->WriteNotice("*** You have enabled user mode +d, deaf mode. This mode means you WILL NOT receive any messages from any channels you are in. If you did NOT mean to do this, use /mode " + dest->nick + " -d."); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } }; @@ -60,15 +60,15 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - if (SimpleUserMode::OnModeChange(source, dest, channel, change) == MODEACTION_ALLOW) + if (SimpleUserMode::OnModeChange(source, dest, channel, change) == true) { dest->WriteNotice("*** You have enabled user mode +D, private deaf mode. This mode means you WILL NOT receive any messages and notices from any nicks. If you did NOT mean to do this, use /mode " + dest->nick + " -D."); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } }; diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index 96c3b5185..c6d6ae249 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -47,7 +47,7 @@ public: ranktoset = ranktounset = OP_VALUE; } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { if (SimpleChannelMode::OnModeChange(source, dest, channel, change)) { @@ -57,9 +57,9 @@ public: */ for (const auto& [member, _] : channel->GetUsers()) RevealUser(member, channel); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } void RevealUser(User* user, Channel* chan); diff --git a/src/modules/m_delaymsg.cpp b/src/modules/m_delaymsg.cpp index fedc45b6f..25d744656 100644 --- a/src/modules/m_delaymsg.cpp +++ b/src/modules/m_delaymsg.cpp @@ -44,7 +44,7 @@ public: return ConvToNum<intptr_t>(their_param) < ConvToNum<intptr_t>(our_param); } - ModeAction OnSet(User* source, Channel* chan, std::string& parameter) override; + bool OnSet(User* source, Channel* chan, std::string& parameter) override; void OnUnset(User* source, Channel* chan) override; void SerializeParam(Channel* chan, intptr_t n, std::string& out) @@ -78,7 +78,7 @@ public: void ReadConfig(ConfigStatus& status) override; }; -ModeAction DelayMsgMode::OnSet(User* source, Channel* chan, std::string& parameter) +bool DelayMsgMode::OnSet(User* source, Channel* chan, std::string& parameter) { // Setting a new limit, sanity check intptr_t limit = ConvToNum<intptr_t>(parameter); @@ -86,7 +86,7 @@ ModeAction DelayMsgMode::OnSet(User* source, Channel* chan, std::string& paramet limit = 1; ext.Set(chan, limit); - return MODEACTION_ALLOW; + return true; } void DelayMsgMode::OnUnset(User* source, Channel* chan) diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index 884e1c2b4..a8bf2947a 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -44,17 +44,17 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - if (SimpleUserMode::OnModeChange(source, dest, channel, change) == MODEACTION_DENY) - return MODEACTION_DENY; + if (SimpleUserMode::OnModeChange(source, dest, channel, change) == false) + return false; if (change.adding) opercount++; else opercount--; - return MODEACTION_ALLOW; + return true; } }; diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index d31053421..b6c5afb3d 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -101,13 +101,13 @@ public: syntax = "<joins>:<seconds>"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } /* Set up the flood parameters for this channel */ @@ -116,11 +116,11 @@ public: if ((njoins<1) || (nsecs<1)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } ext.SetFwd(channel, nsecs, njoins); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const joinfloodsettings* jfs, std::string& out) diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index 1bdd8f7da..588adf73c 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -102,20 +102,20 @@ public: syntax = "<seconds>"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { unsigned int v = ConvToNum<unsigned int>(parameter); if (v <= 0) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } if (IS_LOCAL(source) && v > max) v = max; ext.Set(channel, v); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const KickRejoinData* krd, std::string& out) diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index ff919c4bc..324331275 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -78,13 +78,13 @@ public: syntax = "[*]<messages>:<seconds>"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } /* Set up the flood parameters for this channel */ @@ -95,11 +95,11 @@ public: if ((nlines<2) || (nsecs<1)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } ext.SetFwd(channel, ban, nsecs, nlines); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const floodsettings* fs, std::string& out) diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index 37e4a56c0..7bd3fcc14 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -94,13 +94,13 @@ public: syntax = "<nick-changes>:<seconds>"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { std::string::size_type colon = parameter.find(':'); if ((colon == std::string::npos) || (parameter.find('-') != std::string::npos)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } /* Set up the flood parameters for this channel */ @@ -110,11 +110,11 @@ public: if ((nnicks<1) || (nsecs<1)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } ext.SetFwd(channel, nsecs, nnicks); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const nickfloodsettings* nfs, std::string& out) diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 6f4e75605..5c1125340 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -76,10 +76,10 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - ModeAction res = SimpleUserMode::OnModeChange(source, dest, channel, change); - if (change.adding && res == MODEACTION_ALLOW && IS_LOCAL(dest) && timeout) + bool res = SimpleUserMode::OnModeChange(source, dest, channel, change); + if (change.adding && res && IS_LOCAL(dest) && timeout) ext.Set(dest, new UnsetTimer(IS_LOCAL(dest), timeout, *this)); return res; } diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index 4482795e3..c9beae1f1 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -40,17 +40,17 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { if (SimpleChannelMode::OnModeChange(source, dest, channel, change)) { if (!change.adding) channel->CheckDestroy(); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } void SetOperOnly(bool value) diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index 8f89836c6..521ccb091 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -41,14 +41,14 @@ public: syntax = "<target>"; } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { if (IS_LOCAL(source)) { if (!ServerInstance->Channels.IsChannel(parameter)) { source->WriteNumeric(Numerics::NoSuchChannel(parameter)); - return MODEACTION_DENY; + return false; } } @@ -58,12 +58,12 @@ public: if (!c) { source->WriteNumeric(690, InspIRCd::Format("Target channel %s must exist to be set as a redirect.", parameter.c_str())); - return MODEACTION_DENY; + return false; } else if (c->GetPrefixValue(source) < OP_VALUE) { source->WriteNumeric(690, InspIRCd::Format("You must be opped on %s to set it as a redirect.", parameter.c_str())); - return MODEACTION_DENY; + return false; } } @@ -72,7 +72,7 @@ public: * now catch +L looping in PreJoin. Remove it, since O(n) logic makes me sad, and we catch it anyway. :) -- w00t */ ext.Set(channel, parameter); - return MODEACTION_ALLOW; + return true; } void SerializeParam(Channel* chan, const std::string* str, std::string& out) diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index 0268850bb..85953c851 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -150,29 +150,29 @@ public: MemberInfoExt.Unset(memb); } - ModeAction OnSet(User* source, Channel* channel, std::string& parameter) override + bool OnSet(User* source, Channel* channel, std::string& parameter) override { ChannelSettings settings; if (!ParseSettings(source, parameter, settings)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter)); - return MODEACTION_DENY; + return false; } if ((settings.Backlog > 0) && (settings.Lines > settings.Backlog)) { source->WriteNumeric(Numerics::InvalidModeParameter(channel, this, parameter, "You can't set lines higher than backlog.")); - return MODEACTION_DENY; + return false; } LocalUser* localsource = IS_LOCAL(source); if ((localsource) && (!ValidateSettings(localsource, channel, parameter, settings))) - return MODEACTION_DENY; + return false; ext.Set(channel, settings); - return MODEACTION_ALLOW; + return true; } bool MatchLine(Membership* memb, ChannelSettings* rs, std::string message) diff --git a/src/modules/m_services.cpp b/src/modules/m_services.cpp index 6e557334c..ece510f7d 100644 --- a/src/modules/m_services.cpp +++ b/src/modules/m_services.cpp @@ -31,12 +31,12 @@ public: DisableAutoRegister(); } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { if (IS_LOCAL(source)) { source->WriteNumeric(ERR_NOPRIVILEGES, "Only a server may modify the +r channel mode"); - return MODEACTION_DENY; + return false; } return SimpleChannelMode::OnModeChange(source, dest, channel, change); @@ -55,12 +55,12 @@ public: DisableAutoRegister(); } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { if (IS_LOCAL(source)) { source->WriteNumeric(ERR_NOPRIVILEGES, "Only a server may modify the +r user mode"); - return MODEACTION_DENY; + return false; } return SimpleUserMode::OnModeChange(source, dest, channel, change); diff --git a/src/modules/m_servprotect.cpp b/src/modules/m_servprotect.cpp index 05e9de178..c9f25c45b 100644 --- a/src/modules/m_servprotect.cpp +++ b/src/modules/m_servprotect.cpp @@ -40,9 +40,9 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { - /* Because this returns MODEACTION_DENY all the time, there is only ONE + /* Because this returns false all the time, there is only ONE * way to add this mode and that is at client introduction in the UID command, * as this calls OnModeChange for each mode but disregards the return values. * The mode cannot be manually added or removed, not even by a server or by a remote @@ -50,7 +50,7 @@ public: * I'm sure if someone really wants to do that they can make a copy of this module * that does the job. It won't be me though! */ - return MODEACTION_DENY; + return false; } }; diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp index 2610aa084..d0a184cf3 100644 --- a/src/modules/m_sslmodes.cpp +++ b/src/modules/m_sslmodes.cpp @@ -76,7 +76,7 @@ public: { } - ModeAction OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* source, User* dest, Channel* channel, Modes::Change& change) override { if (change.adding) { @@ -87,7 +87,7 @@ public: if (!API) { source->WriteNumeric(ERR_ALLMUSTSSL, channel->name, "Unable to determine whether all members of the channel are connected via TLS"); - return MODEACTION_DENY; + return false; } size_t nonssl = 0; @@ -102,15 +102,15 @@ public: { source->WriteNumeric(ERR_ALLMUSTSSL, channel->name, InspIRCd::Format("All members of the channel must be connected via TLS (%zu/%zu are non-TLS)", nonssl, channel->GetUsers().size())); - return MODEACTION_DENY; + return false; } } channel->SetMode(this, true); - return MODEACTION_ALLOW; + return true; } else { - return MODEACTION_DENY; + return false; } } else @@ -118,10 +118,10 @@ public: if (channel->IsModeSet(this)) { channel->SetMode(this, false); - return MODEACTION_ALLOW; + return true; } - return MODEACTION_DENY; + return false; } } }; @@ -141,16 +141,16 @@ public: { } - ModeAction OnModeChange(User* user, User* dest, Channel* channel, Modes::Change& change) override + bool OnModeChange(User* user, User* dest, Channel* channel, Modes::Change& change) override { if (change.adding == dest->IsModeSet(this)) - return MODEACTION_DENY; + return false; if (change.adding && IS_LOCAL(user) && (!API || !API->GetCertificate(user))) - return MODEACTION_DENY; + return false; dest->SetMode(this, change.adding); - return MODEACTION_ALLOW; + return true; } }; |
