]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_spanningtree Netburst: Refactor SendChannelModes()
authorattilamolnar <attilamolnar@hush.com>
Sun, 21 Oct 2012 17:02:38 +0000 (19:02 +0200)
committerattilamolnar <attilamolnar@hush.com>
Fri, 12 Apr 2013 19:03:05 +0000 (21:03 +0200)
Rename it to SyncChannel() and change it to take a Channel* parameter, move iteration into DoBurst()

src/modules/m_spanningtree/netburst.cpp
src/modules/m_spanningtree/treesocket.h

index 8b873a3e7f29aa22b1a8ec2505df61b53c749557..0112dbce6529b29fb34093856587414f92ac792d 100644 (file)
@@ -48,8 +48,10 @@ void TreeSocket::DoBurst(TreeServer* s)
        this->SendServers(Utils->TreeRoot,s,1);
        /* Send users and their oper status */
        this->SendUsers();
-       /* Send everything else (channel modes, xlines etc) */
-       this->SendChannelModes();
+
+       for (chan_hash::const_iterator i = ServerInstance->chanlist->begin(); i != ServerInstance->chanlist->end(); ++i)
+               SyncChannel(i->second);
+
        this->SendXLines();
        FOREACH_MOD(I_OnSyncNetwork,OnSyncNetwork(Utils->Creator,(void*)this));
        this->WriteLine(":" + ServerInstance->Config->GetSID() + " ENDBURST");
@@ -121,8 +123,7 @@ void TreeSocket::SendFJoins(Channel* c)
 void TreeSocket::SendXLines()
 {
        char data[MAXBUF];
-       std::string n = ServerInstance->Config->GetSID();
-       const char* sn = n.c_str();
+       const char* sn = ServerInstance->Config->GetSID().c_str();
 
        std::vector<std::string> types = ServerInstance->XLines->GetAllTypes();
 
@@ -154,31 +155,26 @@ void TreeSocket::SendXLines()
 }
 
 /** Send channel topic, modes and metadata */
-void TreeSocket::SendChannelModes()
+void TreeSocket::SyncChannel(Channel* chan)
 {
        char data[MAXBUF];
-       std::string n = ServerInstance->Config->GetSID();
-       const char* sn = n.c_str();
 
-       for (chan_hash::iterator c = ServerInstance->chanlist->begin(); c != ServerInstance->chanlist->end(); c++)
+       SendFJoins(chan);
+       if (!chan->topic.empty())
        {
-               SendFJoins(c->second);
-               if (!c->second->topic.empty())
-               {
-                       snprintf(data,MAXBUF,":%s FTOPIC %s %lu %s :%s", sn, c->second->name.c_str(), (unsigned long)c->second->topicset, c->second->setby.c_str(), c->second->topic.c_str());
-                       this->WriteLine(data);
-               }
-
-               for(Extensible::ExtensibleStore::const_iterator i = c->second->GetExtList().begin(); i != c->second->GetExtList().end(); i++)
-               {
-                       ExtensionItem* item = i->first;
-                       std::string value = item->serialize(FORMAT_NETWORK, c->second, i->second);
-                       if (!value.empty())
-                               Utils->Creator->ProtoSendMetaData(this, c->second, item->name, value);
-               }
+               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());
+               this->WriteLine(data);
+       }
 
-               FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(c->second,Utils->Creator,this));
+       for (Extensible::ExtensibleStore::const_iterator i = chan->GetExtList().begin(); i != chan->GetExtList().end(); i++)
+       {
+               ExtensionItem* item = i->first;
+               std::string value = item->serialize(FORMAT_NETWORK, chan, i->second);
+               if (!value.empty())
+                       Utils->Creator->ProtoSendMetaData(this, chan, item->name, value);
        }
+
+       FOREACH_MOD(I_OnSyncChannel,OnSyncChannel(chan, Utils->Creator, this));
 }
 
 /** send all users and their oper state/modes */
index 2d975a4bfb41f7a4281b1155ac1c3b941b1051e8..ae54bc6aab3c5ef0aa8a0fdf9cee8203d480bccb 100644 (file)
@@ -217,8 +217,8 @@ class TreeSocket : public BufferedSocket
        /** Send G, Q, Z and E lines */
        void SendXLines();
 
-       /** Send channel modes and topics */
-       void SendChannelModes();
+       /** Send all known information about a channel */
+       void SyncChannel(Channel* chan);
 
        /** send all users and their oper state/modes */
        void SendUsers();