]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/fjoin.cpp
Minor spelling errors in m_spanningtree.so
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / fjoin.cpp
index c0475613afece31941cd93a2f9766bdc2d2ab5de..4ec6e1dbb0f3d502209775cbde367ce325455ba3 100644 (file)
@@ -66,7 +66,8 @@ CmdResult CommandFJoin::Handle(const std::vector<std::string>& params, User *src
        bool created = !chan;                                           /* True if the channel doesnt exist here yet */
        std::string item;                                               /* One item in the list of nicks */
 
-       TreeSocket* src_socket = Utils->FindServer(srcuser->server)->GetRoute()->GetSocket();
+       TreeServer* src_server = Utils->FindServer(srcuser->server);
+       TreeSocket* src_socket = src_server->GetRoute()->GetSocket();
 
        if (!TS)
        {
@@ -85,8 +86,8 @@ CmdResult CommandFJoin::Handle(const std::vector<std::string>& params, User *src
                time_t ourTS = chan->age;
 
                if (TS != ourTS)
-                       ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN received for %s, ourTS: %lu, TS: %lu, difference: %lu",
-                               chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (unsigned long)(ourTS - TS));
+                       ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN received for %s, ourTS: %lu, TS: %lu, difference: %ld",
+                               chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (long)(ourTS - TS));
                /* If our TS is less than theirs, we dont accept their modes */
                if (ourTS < TS)
                {
@@ -121,19 +122,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 */
@@ -177,11 +197,11 @@ CmdResult CommandFJoin::Handle(const std::vector<std::string>& params, User *src
                                for (std::string::iterator x = modes.begin(); x != modes.end(); ++x)
                                        modestack.Push(*x, who->nick);
 
-                               Channel::JoinUser(who, channel.c_str(), true, "", route_back_again->bursting, TS);
+                               Channel::JoinUser(who, channel.c_str(), true, "", src_server->bursting, TS);
                        }
                        else
                        {
-                               ServerInstance->Logs->Log("m_spanningtree",SPARSE, "Ignored nonexistant user %s in fjoin to %s (probably quit?)", usr, channel.c_str());
+                               ServerInstance->Logs->Log("m_spanningtree",SPARSE, "Ignored nonexistent user %s in fjoin to %s (probably quit?)", usr, channel.c_str());
                                continue;
                        }
                }