diff options
author | linuxdaemon <linuxdaemon@users.noreply.github.com> | 2019-06-24 11:10:17 -0500 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-06-24 17:10:17 +0100 |
commit | 7ad534c1af4578a0d46742c4b6b00a5a33afb63f (patch) | |
tree | dacfcae9d65803a1aaa5941588b016f56be10e79 /src/modules/m_noctcp.cpp | |
parent | 2ab383f707ec648ceeb29059ce4f54d4bbb056a4 (diff) |
Replace large if/else blocks for target.type with switches (#1668).
Diffstat (limited to 'src/modules/m_noctcp.cpp')
-rw-r--r-- | src/modules/m_noctcp.cpp | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp index c73f8308e..f288820b8 100644 --- a/src/modules/m_noctcp.cpp +++ b/src/modules/m_noctcp.cpp @@ -61,33 +61,40 @@ class ModuleNoCTCP : public Module if (!details.IsCTCP(ctcpname) || irc::equals(ctcpname, "ACTION")) return MOD_RES_PASSTHRU; - if (target.type == MessageTarget::TYPE_CHANNEL) + switch (target.type) { - if (user->HasPrivPermission("channels/ignore-noctcp")) - return MOD_RES_PASSTHRU; + case MessageTarget::TYPE_CHANNEL: + { + if (user->HasPrivPermission("channels/ignore-noctcp")) + return MOD_RES_PASSTHRU; - Channel* c = target.Get<Channel>(); - ModResult res = CheckExemption::Call(exemptionprov, user, c, "noctcp"); - if (res == MOD_RES_ALLOW) - return MOD_RES_PASSTHRU; + Channel* c = target.Get<Channel>(); + ModResult res = CheckExemption::Call(exemptionprov, user, c, "noctcp"); + if (res == MOD_RES_ALLOW) + return MOD_RES_PASSTHRU; - if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet(nc))) - { - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send CTCP to channel (+C is set)"); - return MOD_RES_DENY; + if (!c->GetExtBanStatus(user, 'C').check(!c->IsModeSet(nc))) + { + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, c->name, "Can't send CTCP to channel (+C is set)"); + return MOD_RES_DENY; + } + break; } - } - else if (target.type == MessageTarget::TYPE_USER) - { - if (user->HasPrivPermission("users/ignore-noctcp")) - return MOD_RES_PASSTHRU; - - User* u = target.Get<User>(); - if (u->IsModeSet(ncu)) + case MessageTarget::TYPE_USER: { - user->WriteNumeric(ERR_CANTSENDTOUSER, u->nick, "Can't send CTCP to user (+T is set)"); - return MOD_RES_DENY; + if (user->HasPrivPermission("users/ignore-noctcp")) + return MOD_RES_PASSTHRU; + + User* u = target.Get<User>(); + if (u->IsModeSet(ncu)) + { + user->WriteNumeric(ERR_CANTSENDTOUSER, u->nick, "Can't send CTCP to user (+T is set)"); + return MOD_RES_DENY; + } + break; } + case MessageTarget::TYPE_SERVER: + break; } return MOD_RES_PASSTHRU; } |