]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/netburst.cpp
Revert automated conversion by Special, as it (unfortunately) neglects some details...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / netburst.cpp
index 3a28ca8a9102037c62677b603c83b9469dddcdaa..2e7aab25fc5f5903a63cb0a7bb38393b83d00fdf 100644 (file)
@@ -85,7 +85,7 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
        char list[MAXBUF];
 
        size_t dlen, curlen;
-       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));
+       dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu +%s", this->Instance->Config->GetSID().c_str(), c->name.c_str(),(unsigned long)c->age, c->ChanModes(true));
        int numusers = 0;
        char* ptr = list + dlen;
        bool looped_once = false;
@@ -96,8 +96,19 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
 
        for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++)
        {
+               size_t ptrlen = 0;
+               std::string modestr = this->Instance->Modes->ModeString(i->first, c, false);
+
+               if ((curlen + modestr.length() + i->first->uuid.length() + 4) > 480)
+               {
+                       buffer.append(list).append("\r\n");
+                       dlen = curlen = snprintf(list, MAXBUF, ":%s FJOIN %s %lu +%s", this->Instance->Config->GetSID().c_str(), c->name.c_str(), (unsigned long)c->age, c->ChanModes(true));
+                       ptr = list + dlen;
+                       numusers = 0;
+               }
+
                // The first parameter gets a : before it
-               size_t ptrlen = snprintf(ptr, MAXBUF, " %s%s,%s", !numusers ? ":" : "", this->Instance->Modes->ModeString(i->first, c, false).c_str(), i->first->uuid.c_str());
+               ptrlen = snprintf(ptr, MAXBUF, " %s%s,%s", !numusers ? ":" : "", modestr.c_str(), i->first->uuid.c_str());
 
                looped_once = true;
 
@@ -105,15 +116,6 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
                ptr += ptrlen;
 
                numusers++;
-
-               if (curlen > (480-NICKMAX))
-               {
-                       buffer.append(list).append("\r\n");
-                       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;
-               }
        }
 
        // Okay, permanent channels will (of course) need this \r\n anyway, numusers check is if there
@@ -124,15 +126,15 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
        int linesize = 1;
        for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
        {
-               int size = strlen(b->data) + 2;
+               int size = b->data.length() + 2;
                int currsize = linesize + size;
                if (currsize <= 350)
                {
                        modes.append("b");
                        params.append(" ").append(b->data);
-                       linesize += size; 
+                       linesize += size;
                }
-               if ((params.length() >= MAXMODES) || (currsize > 350))
+               if ((params.length() >= Instance->Config->Limits.MaxModes) || (currsize > 350))
                {
                        /* Wrap at MAXMODES */
                        buffer.append(":").append(this->Instance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(modes).append(params).append("\r\n");
@@ -193,9 +195,9 @@ void TreeSocket::SendChannelModes(TreeServer* Current)
        for (chan_hash::iterator c = this->Instance->chanlist->begin(); c != this->Instance->chanlist->end(); c++)
        {
                SendFJoins(Current, c->second);
-               if (*c->second->topic)
+               if (!c->second->topic.empty())
                {
-                       snprintf(data,MAXBUF,":%s FTOPIC %s %lu %s :%s",sn,c->second->name,(unsigned long)c->second->topicset,c->second->setby,c->second->topic);
+                       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);
                }
                FOREACH_MOD_I(this->Instance,I_OnSyncChannel,OnSyncChannel(c->second,(Module*)Utils->Creator,(void*)this));