summaryrefslogtreecommitdiff
path: root/src/modules/m_spanningtree
diff options
context:
space:
mode:
authorlinuxdaemon <linuxdaemon@users.noreply.github.com>2019-06-24 11:10:17 -0500
committerPeter Powell <petpow@saberuk.com>2019-06-24 17:10:17 +0100
commit7ad534c1af4578a0d46742c4b6b00a5a33afb63f (patch)
treedacfcae9d65803a1aaa5941588b016f56be10e79 /src/modules/m_spanningtree
parent2ab383f707ec648ceeb29059ce4f54d4bbb056a4 (diff)
Replace large if/else blocks for target.type with switches (#1668).
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r--src/modules/m_spanningtree/main.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index db5265344..1a51955d1 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -392,30 +392,36 @@ void ModuleSpanningTree::OnUserPostMessage(User* user, const MessageTarget& targ
return;
const char* message_type = (details.type == MSG_PRIVMSG ? "PRIVMSG" : "NOTICE");
- if (target.type == MessageTarget::TYPE_USER)
+ switch (target.type)
{
- User* d = target.Get<User>();
- if (!IS_LOCAL(d))
+ case MessageTarget::TYPE_USER:
{
- CmdBuilder params(user, message_type);
- params.push_tags(details.tags_out);
- params.push_back(d->uuid);
- params.push_last(details.text);
- params.Unicast(d);
+ User* d = target.Get<User>();
+ if (!IS_LOCAL(d))
+ {
+ CmdBuilder params(user, message_type);
+ params.push_tags(details.tags_out);
+ params.push_back(d->uuid);
+ params.push_last(details.text);
+ params.Unicast(d);
+ }
+ break;
+ }
+ case MessageTarget::TYPE_CHANNEL:
+ {
+ Utils->SendChannelMessage(user->uuid, target.Get<Channel>(), details.text, target.status, details.tags_out, details.exemptions, message_type);
+ break;
+ }
+ case MessageTarget::TYPE_SERVER:
+ {
+ const std::string* serverglob = target.Get<std::string>();
+ CmdBuilder par(user, message_type);
+ par.push_tags(details.tags_out);
+ par.push_back(*serverglob);
+ par.push_last(details.text);
+ par.Broadcast();
+ break;
}
- }
- else if (target.type == MessageTarget::TYPE_CHANNEL)
- {
- Utils->SendChannelMessage(user->uuid, target.Get<Channel>(), details.text, target.status, details.tags_out, details.exemptions, message_type);
- }
- else if (target.type == MessageTarget::TYPE_SERVER)
- {
- const std::string* serverglob = target.Get<std::string>();
- CmdBuilder par(user, message_type);
- par.push_tags(details.tags_out);
- par.push_back(*serverglob);
- par.push_last(details.text);
- par.Broadcast();
}
}