diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-06-12 18:11:51 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-06-12 18:11:51 +0200 |
commit | 20e521a9eade796b119b5f7e7bde45541149915c (patch) | |
tree | 1a81be2141e5f5cd5bcb24d1a99755437f422fca /src/modules | |
parent | 62e7254fbe791dc61ebbca0ab3c228f5c1e48994 (diff) |
m_spanningtree FJOIN handler: Merge and take maxmodes into consideration when applying non-prefix modes
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_spanningtree/fjoin.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index c0475613a..ee18c8e87 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -121,19 +121,38 @@ CmdResult CommandFJoin::Handle(const std::vector<std::string>& params, User *src /* First up, apply their modes if they won the TS war */ if (apply_other_sides_modes) { - unsigned int idx = 2; + // Need to use a modestacker here due to maxmodes + irc::modestacker stack(true); + std::vector<std::string>::const_iterator paramit = params.begin() + 3; + const std::vector<std::string>::const_iterator lastparamit = ((params.size() > 3) ? (params.end() - 1) : params.end()); + for (std::string::const_iterator i = params[2].begin(); i != params[2].end(); ++i) + { + ModeHandler* mh = ServerInstance->Modes->FindMode(*i, MODETYPE_CHANNEL); + if (!mh) + continue; + + std::string modeparam; + if ((paramit != lastparamit) && (mh->GetNumParams(true))) + { + modeparam = *paramit; + ++paramit; + } + + stack.Push(*i, modeparam); + } + std::vector<std::string> modelist; // Mode parser needs to know what channel to act on. modelist.push_back(params[0]); - /* Remember, params[params.size() - 1] is nicklist, and we don't want to apply *that* */ - for (idx = 2; idx != (params.size() - 1); idx++) + while (stack.GetStackedLine(modelist)) { - modelist.push_back(params[idx]); + ServerInstance->Modes->Process(modelist, srcuser, true); + modelist.erase(modelist.begin() + 1, modelist.end()); } - ServerInstance->SendMode(modelist, srcuser); + ServerInstance->Modes->Process(modelist, srcuser, true); } /* Now, process every 'modes,nick' pair */ |