]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add simple modes to FJOIN instead of sending a seperate FMODE all the time. This...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 4 Apr 2008 19:36:39 +0000 (19:36 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 4 Apr 2008 19:36:39 +0000 (19:36 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9333 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_spanningtree/fjoin.cpp
src/modules/m_spanningtree/fmode.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/netburst.cpp

index 3d119ee786bbc095accac2dc05e77db87d32333b..dfe2fe13cf8c3c23ea6e2ee050e0f789e549e5d4 100644 (file)
@@ -21,7 +21,7 @@
 /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
 
 
-/** FJOIN, similar to TS6 SJOIN, but not quite. */
+/** FJOIN, almost identical to TS6 SJOIN, except for nicklist handling. */
 bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &params)
 {
        /* 1.1 FJOIN works as follows:
@@ -57,23 +57,22 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
         * the losing side sends any modes for the channel which shouldnt win,
         * they wont as their timestamp will be too high :-)
         */
-
-       if (params.size() < 2)
+       if (params.size() < 3)
                return true;
 
        irc::modestacker modestack(true);                               /* Modes to apply from the users in the user list */
        User* who = NULL;                                               /* User we are currently checking */
        std::string channel = params[0];                                /* Channel name, as a string */
        time_t TS = atoi(params[1].c_str());                            /* Timestamp given to us for remote side */
-       irc::tokenstream users((params.size() > 2) ? params[2] : "");   /* users from the user list */
+       irc::tokenstream users((params.size() > 3) ? params[params.size() - 1] : "");   /* users from the user list */
        bool apply_other_sides_modes = true;                            /* True if we are accepting the other side's modes */
        Channel* chan = this->Instance->FindChan(channel);              /* The channel we're sending joins to */
        time_t ourTS = chan ? chan->age : Instance->Time()+600; /* The TS of our side of the link */
        bool created = !chan;                                           /* True if the channel doesnt exist here yet */
        std::string item;                                               /* One item in the list of nicks */
 
-       if (params.size() > 2)
-               params[2] = ":" + params[2];
+       if (params.size() > 3)
+               params[params.size() - 1] = ":" + params[params.size() - 1];
                
        Utils->DoOneToAllButSender(source,"FJOIN",params,source);
 
@@ -106,7 +105,27 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                }
        }
 
-       /* Now, process every 'prefixes,nick' pair */
+       /* First up, apply their modes if they won the TS war */
+       if (apply_other_sides_modes)
+       {
+               unsigned int idx = 2;
+               int numpara = 1;
+               const char* modelist[64];
+               memset(&modelist,0,sizeof(modelist));
+
+               // Mode parser needs to know what channel to act on.
+               modelist[0] = params[0].c_str();
+
+               /* Remember, params[params.size() - 1] is nicklist, and we don't want to apply *that* */
+               for (idx = 2; idx != (params.size() - 1); idx++)
+               {
+                       modelist[numpara++] = params[idx].c_str();
+               }
+
+               this->Instance->SendMode(modelist, numpara, this->Instance->FakeClient);
+       }
+
+       /* Now, process every 'modes,nick' pair */
        while (users.GetToken(item))
        {
                const char* usr = item.c_str();
index 94a5c1dce0e1b5da3900f445e7e2c4aedb642d20..6fa269584b3584f8b9925651f841d10570b46029 100644 (file)
@@ -33,6 +33,7 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> &p
 
        bool smode = false;
        std::string sourceserv;
+
        /* Are we dealing with an FMODE from a user, or from a server? */
        User* who = this->Instance->FindNick(source);
        if (who)
@@ -44,7 +45,7 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> &p
        {
                /* FMODE from a server, use a fake user to receive mode feedback */
                who = this->Instance->FakeClient;
-               smode = true;      /* Setting this flag tells us we should free the User later */
+               smode = true;                   /* Setting this flag tells us it is a server mode*/
                sourceserv = source;    /* Set sourceserv to the actual source string */
        }
        const char* modelist[64];
@@ -72,6 +73,7 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> &p
        User* dst = this->Instance->FindNick(params[0]);
        Channel* chan = NULL;
        time_t ourTS = 0;
+
        if (dst)
        {
                ourTS = dst->age;
@@ -99,9 +101,6 @@ bool TreeSocket::ForceMode(const std::string &source, std::deque<std::string> &p
         */
        if (TS <= ourTS)
        {
-               if ((TS < ourTS) && (!dst))
-                       Instance->Logs->Log("m_spanningtree",DEFAULT,"*** BUG *** Channel TS sent in FMODE to %s is %lu which is not equal to %lu!", params[0].c_str(), (unsigned long) TS, (unsigned long) ourTS);
-
                if (smode)
                {
                        this->Instance->SendMode(modelist, n, who);
index afc05bdbc4ea6c8f4082ea769ae951fdcf305dca..de149e473c0e508c27fa2e758d01ca94fe507851 100644 (file)
@@ -576,12 +576,9 @@ void ModuleSpanningTree::OnUserJoin(User* user, Channel* channel, bool sync, boo
                        // new joining permissions for the user.
                        params.push_back(channel->name);
                        params.push_back(ConvToStr(channel->age));
+                       params.push_back(std::string("+") + channel->ChanModes(true));
                        params.push_back(std::string(channel->GetAllPrefixChars(user))+","+std::string(user->uuid));
                        Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FJOIN",params);
-                       /* First user in, sync the modes for the channel */
-                       params.pop_back();
-                       params.push_back(std::string("+") + channel->ChanModes(true));
-                       Utils->DoOneToMany(ServerInstance->Config->GetSID(),"FMODE",params);
                }
                else
                {
index 978a798ff238541ccb35272e4dfbc658f0d8725c..75f9b8e5ba2e099aa2fa9cb8aa1b5e26ca87f1b7 100644 (file)
@@ -83,10 +83,9 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
 {
        std::string buffer;
        char list[MAXBUF];
-       std::string individual_halfops = std::string(":")+this->Instance->Config->GetSID()+" FMODE "+c->name+" "+ConvToStr(c->age);
 
        size_t dlen, curlen;
-       dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->GetSID().c_str(),c->name,(unsigned long)c->age);
+       dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu +%s",this->Instance->Config->GetSID().c_str(),c->name,(unsigned long)c->age, c->ChanModes(true));
        int numusers = 1;
        char* ptr = list + dlen;
 
@@ -107,7 +106,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
                if (curlen > (480-NICKMAX))
                {
                        buffer.append(list).append("\r\n");
-                       dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->GetSID().c_str(),c->name,(unsigned long)c->age);
+                       dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu +%s",this->Instance->Config->GetSID().c_str(),c->name,(unsigned long)c->age, c->ChanModes(true));
                        ptr = list + dlen;
                        ptrlen = 0;
                        numusers = 0;
@@ -117,8 +116,6 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
        if (numusers)
                buffer.append(list).append("\r\n");
 
-       buffer.append(":").append(this->Instance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(c->ChanModes(true)).append("\r\n");
-
        int linesize = 1;
        for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
        {