diff options
| author | 2019-06-24 11:10:17 -0500 | |
|---|---|---|
| committer | 2019-06-24 17:10:17 +0100 | |
| commit | 7ad534c1af4578a0d46742c4b6b00a5a33afb63f (patch) | |
| tree | dacfcae9d65803a1aaa5941588b016f56be10e79 /src/modules/m_silence.cpp | |
| parent | Add OnUserPreQuit event to allow modules to change quit messages (#1629). (diff) | |
| download | inspircd++-7ad534c1af4578a0d46742c4b6b00a5a33afb63f.tar.gz inspircd++-7ad534c1af4578a0d46742c4b6b00a5a33afb63f.tar.bz2 inspircd++-7ad534c1af4578a0d46742c4b6b00a5a33afb63f.zip | |
Replace large if/else blocks for target.type with switches (#1668).
Diffstat (limited to 'src/modules/m_silence.cpp')
| -rw-r--r-- | src/modules/m_silence.cpp | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 87b70dfa4..1e73bda27 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -384,32 +384,38 @@ class ModuleSilence bool is_ctcp = details.IsCTCP(ctcpname) && !irc::equals(ctcpname, "ACTION"); SilenceEntry::SilenceFlags flag = SilenceEntry::SF_NONE; - if (target.type == MessageTarget::TYPE_CHANNEL) - { - if (is_ctcp) - flag = SilenceEntry::SF_CTCP_CHANNEL; - else if (details.type == MSG_NOTICE) - flag = SilenceEntry::SF_NOTICE_CHANNEL; - else if (details.type == MSG_PRIVMSG) - flag = SilenceEntry::SF_PRIVMSG_CHANNEL; - - return BuildChannelExempts(user, target.Get<Channel>(), flag, details.exemptions); - } - - if (target.type == MessageTarget::TYPE_USER) + switch (target.type) { - if (is_ctcp) - flag = SilenceEntry::SF_CTCP_USER; - else if (details.type == MSG_NOTICE) - flag = SilenceEntry::SF_NOTICE_USER; - else if (details.type == MSG_PRIVMSG) - flag = SilenceEntry::SF_PRIVMSG_USER; + case MessageTarget::TYPE_CHANNEL: + { + if (is_ctcp) + flag = SilenceEntry::SF_CTCP_CHANNEL; + else if (details.type == MSG_NOTICE) + flag = SilenceEntry::SF_NOTICE_CHANNEL; + else if (details.type == MSG_PRIVMSG) + flag = SilenceEntry::SF_PRIVMSG_CHANNEL; - if (!CanReceiveMessage(user, target.Get<User>(), flag)) + return BuildChannelExempts(user, target.Get<Channel>(), flag, details.exemptions); + break; + } + case MessageTarget::TYPE_USER: { - details.echo_original = true; - return MOD_RES_DENY; + if (is_ctcp) + flag = SilenceEntry::SF_CTCP_USER; + else if (details.type == MSG_NOTICE) + flag = SilenceEntry::SF_NOTICE_USER; + else if (details.type == MSG_PRIVMSG) + flag = SilenceEntry::SF_PRIVMSG_USER; + + if (!CanReceiveMessage(user, target.Get<User>(), flag)) + { + details.echo_original = true; + return MOD_RES_DENY; + } + break; } + case MessageTarget::TYPE_SERVER: + break; } return MOD_RES_PASSTHRU; |
