]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/fjoin.cpp
Remove redundant PriorityState, enum Priority does the exact same thing.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / fjoin.cpp
index fa61cea4a055ea078615ca0889319a717c2ac436..55c72c474e50571abe43f5e0e0ed0e03b500a087 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -49,13 +49,6 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
         * The winning side on the other hand will ignore all user modes from the
         * losing side, so only its own modes get applied. Life is simple for those
         * who succeed at internets. :-)
-        *
-        * NOTE: Unlike TS6 and dreamforge and other protocols which have SJOIN,
-        * FJOIN does not contain the simple-modes such as +iklmnsp. Why not,
-        * you ask? Well, quite simply because we don't need to. They'll be sent
-        * after the FJOIN by FMODE, and FMODE is timestamped, so in the event
-        * the losing side sends any modes for the channel which shouldnt win,
-        * they wont as their timestamp will be too high :-)
         */
        if (params.size() < 3)
                return true;
@@ -67,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 */
 
@@ -84,30 +76,41 @@ 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;
+
+               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 - (unsigned long)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 */
        if (apply_other_sides_modes)
        {
+               ServerInstance->SNO->WriteToSnoMask('d', "Applying remote modestring for %s", params[0].c_str());
                unsigned int idx = 2;
                std::vector<std::string> modelist;
 
@@ -195,8 +198,6 @@ bool TreeSocket::ForceJoin(const std::string &source, std::deque<std::string> &p
        return true;
 }
 
-/** TODO: This creates a total mess of output and needs to really use irc::modestacker.
- */
 bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque<std::string> &params)
 {
        if (params.size() < 1)