]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/netburst.cpp
Merge pull request #495 from SaberUK/master+fix-libcpp
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / netburst.cpp
index 566224c7a6c8b1f5e7057e5453abbee3e3dd9890..21404e68ee2c1e54b657874c3560b2f80f1ddf28 100644 (file)
@@ -44,7 +44,7 @@ void TreeSocket::DoBurst(TreeServer* s)
        /* send our version string */
        this->WriteLine(":" + ServerInstance->Config->GetSID() + " VERSION :"+ServerInstance->GetVersionString());
        /* Send server tree */
-       this->SendServers(Utils->TreeRoot,s,1);
+       this->SendServers(Utils->TreeRoot, s);
        /* Send users and their oper status */
        this->SendUsers();
 
@@ -57,16 +57,14 @@ void TreeSocket::DoBurst(TreeServer* s)
        ServerInstance->SNO->WriteToSnoMask('l',"Finished bursting to \2"+ s->GetName()+"\2.");
 }
 
-/** Recursively send the server tree with distances as hops.
+/** Recursively send the server tree.
  * This is used during network burst to inform the other server
  * (and any of ITS servers too) of what servers we know about.
  * If at any point any of these servers already exist on the other
- * end, our connection may be terminated. The hopcounts given
- * by this function are relative, this doesn't matter so long as
- * they are all >1, as all the remote servers re-calculate them
- * to be relative too, with themselves as hop 0.
+ * end, our connection may be terminated.
+ * The hopcount parameter (3rd) is deprecated, and is always 0.
  */
-void TreeSocket::SendServers(TreeServer* Current, TreeServer* s, int hops)
+void TreeSocket::SendServers(TreeServer* Current, TreeServer* s)
 {
        char command[MAXBUF];
        for (unsigned int q = 0; q < Current->ChildCount(); q++)
@@ -75,13 +73,13 @@ void TreeSocket::SendServers(TreeServer* Current, TreeServer* s, int hops)
                if (recursive_server != s)
                {
                        std::string recursive_servername = recursive_server->GetName();
-                       snprintf(command, MAXBUF, ":%s SERVER %s * %d %s :%s", Current->GetID().c_str(), recursive_servername.c_str(), hops,
+                       snprintf(command, MAXBUF, ":%s SERVER %s * 0 %s :%s", Current->GetID().c_str(), recursive_servername.c_str(),
                                        recursive_server->GetID().c_str(),
                                        recursive_server->GetDesc().c_str());
                        this->WriteLine(command);
                        this->WriteLine(":"+recursive_server->GetID()+" VERSION :"+recursive_server->GetVersion());
                        /* down to next level */
-                       this->SendServers(recursive_server, s, hops+1);
+                       this->SendServers(recursive_server, s);
                }
        }
 }
@@ -104,7 +102,7 @@ void TreeSocket::SendFJoins(Channel* c)
        for (UserMembCIter i = ulist->begin(); i != ulist->end(); ++i)
        {
                const std::string& modestr = i->second->modes;
-               if ((line.length() + modestr.length() + (UUID_LENGTH-1) + 2) > 480)
+               if ((line.length() + modestr.length() + UIDGenerator::UUID_LENGTH + 2) > 480)
                {
                        this->WriteLine(line);
                        line.erase(erase_from);
@@ -159,9 +157,12 @@ void TreeSocket::SyncChannel(Channel* chan)
        char data[MAXBUF];
 
        SendFJoins(chan);
-       if (!chan->topic.empty())
+
+       // If the topic was ever set, send it, even if it's empty now
+       // because a new empty topic should override an old non-empty topic
+       if (chan->topicset != 0)
        {
-               snprintf(data,MAXBUF,":%s FTOPIC %s %lu %s :%s", ServerInstance->Config->GetSID().c_str(), chan->name.c_str(), (unsigned long)chan->topicset, chan->setby.c_str(), chan->topic.c_str());
+               snprintf(data,MAXBUF,":%s FTOPIC %s %lu %lu %s :%s", ServerInstance->Config->GetSID().c_str(), chan->name.c_str(), (unsigned long) chan->age, (unsigned long)chan->topicset, chan->setby.c_str(), chan->topic.c_str());
                this->WriteLine(data);
        }