]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/fjoin.cpp
Use Utils->ServerUser instead of ServerInstance->FakeClient in m_spanningtree
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / fjoin.cpp
index 0a8c8ca94267c2dc9efe8e8a45a345a71be540c5..28a922c0f56de341f52d7c8141d112dda27b87e1 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -60,7 +60,6 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
        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->ServerInstance->FindChan(channel);                /* The channel we're sending joins to */
-       time_t ourTS = chan ? chan->age : ServerInstance->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 */
 
@@ -77,25 +76,36 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
        }
 
        if (created)
-               chan = new Channel(ServerInstance, channel, ourTS);
-
-       /* If our TS is less than theirs, we dont accept their modes */
-       if (ourTS < TS)
-               apply_other_sides_modes = false;
-
-       /* Our TS greater than theirs, clear all our modes from the channel, accept theirs. */
-       if (ourTS > TS)
        {
-               std::deque<std::string> param_list;
-               if (Utils->AnnounceTSChange && chan)
-                       chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :TS for %s changed from %lu to %lu", chan->name.c_str(), chan->name.c_str(), (unsigned long) ourTS, (unsigned long) TS);
-               ourTS = TS;
-               if (!created)
+               chan = new Channel(ServerInstance, channel, TS);
+               ServerInstance->SNO->WriteToSnoMask('d', "Creation FJOIN recieved for %s, timestamp: %lu", chan->name.c_str(), (unsigned long)TS);
+       }
+       else
+       {
+               time_t ourTS = chan->age;
+
+               if (TS != ourTS)
+                       ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN recieved for %s, ourTS: %lu, TS: %lu, difference: %lu",
+                               chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (unsigned long)(ourTS - TS));
+               /* If our TS is less than theirs, we dont accept their modes */
+               if (ourTS < TS)
                {
+                       ServerInstance->SNO->WriteToSnoMask('d', "NOT Applying modes from other side");
+                       apply_other_sides_modes = false;
+               }
+               else if (ourTS > TS)
+               {
+                       /* Our TS greater than theirs, clear all our modes from the channel, accept theirs. */
+                       ServerInstance->SNO->WriteToSnoMask('d', "Removing our modes, accepting remote");
+                       std::deque<std::string> param_list;
+                       if (Utils->AnnounceTSChange && chan)
+                               chan->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :TS for %s changed from %lu to %lu", chan->name.c_str(), chan->name.c_str(), (unsigned long) ourTS, (unsigned long) TS);
+                       ourTS = TS;
                        chan->age = TS;
                        param_list.push_back(channel);
                        this->RemoveStatus(ServerInstance->Config->GetSID(), param_list);
                }
+               // The silent case here is ourTS == TS, we don't need to remove modes here, just to merge them later on.
        }
 
        /* First up, apply their modes if they won the TS war */
@@ -113,7 +123,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                        modelist.push_back(params[idx]);
                }
 
-               this->ServerInstance->SendMode(modelist, this->ServerInstance->FakeClient);
+               this->ServerInstance->SendMode(modelist, Utils->ServerUser);
        }
 
        /* Now, process every 'modes,nick' pair */
@@ -158,7 +168,7 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
                                for (std::string::iterator x = modes.begin(); x != modes.end(); ++x)
                                        modestack.Push(*x, who->nick);
 
-                               Channel::JoinUser(this->ServerInstance, who, channel.c_str(), true, "", true, TS);
+                               Channel::JoinUser(this->ServerInstance, who, channel.c_str(), true, "", route_back_again->bursting, TS);
                        }
                        else
                        {
@@ -177,11 +187,9 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
 
                while (modestack.GetStackedLine(stackresult))
                {
-                       for (size_t j = 0; j < stackresult.size(); j++)
-                       {
-                               mode_junk.push_back(stackresult[j]);
-                       }
-                       ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient);
+                       mode_junk.insert(mode_junk.end(), stackresult.begin(), stackresult.end());
+                       ServerInstance->SendMode(mode_junk, Utils->ServerUser);
+                       mode_junk.erase(mode_junk.begin() + 1, mode_junk.end());
                }
        }
 
@@ -216,10 +224,9 @@ bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque<std::string>
 
                while (stack.GetStackedLine(stackresult))
                {
-                       for (size_t j = 0; j < stackresult.size(); j++)
-                               mode_junk.push_back(stackresult[j]);
-
-                       ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient);
+                       mode_junk.insert(mode_junk.end(), stackresult.begin(), stackresult.end());
+                       ServerInstance->SendMode(mode_junk, Utils->ServerUser);
+                       mode_junk.erase(mode_junk.begin() + 1, mode_junk.end());
                }
        }
        return true;