X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fnetburst.cpp;h=2e7aab25fc5f5903a63cb0a7bb38393b83d00fdf;hb=58f4306bb6e1f91076fccf30a3b43a40b3d1915a;hp=40718cedb34deaf2d72aa2817af8b5fe65fcdde9;hpb=869bd02318d94a38369a125726b8edeb54ba0706;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 40718cedb..2e7aab25f 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -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 @@ -130,9 +132,9 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) { 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));