X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Fnetburst.cpp;h=2e7aab25fc5f5903a63cb0a7bb38393b83d00fdf;hb=58f4306bb6e1f91076fccf30a3b43a40b3d1915a;hp=c2e365c35129ece0b707aae08198d40452908d0f;hpb=da074814501f23680b579feb1ad649c86e8a1348;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index c2e365c35..2e7aab25f 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -83,12 +83,12 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) { std::string buffer; char list[MAXBUF]; - std::string individual_halfops = std::string(":")+this->Instance->Config->GetSID()+" FMODE "+c->name+" "+ConvToStr(c->age); size_t dlen, curlen; - dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu",this->Instance->Config->GetSID().c_str(),c->name,(unsigned long)c->age); - int numusers = 1; + 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; CUList *ulist = c->GetUsers(); std::string modes; @@ -96,41 +96,45 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c) for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { - // The first parameter gets a : before it - size_t ptrlen = snprintf(ptr, MAXBUF, " %s%s,%s", !numusers ? ":" : "", c->GetAllPrefixChars(i->first), i->first->uuid); - - curlen += ptrlen; - ptr += ptrlen; + size_t ptrlen = 0; + std::string modestr = this->Instance->Modes->ModeString(i->first, c, false); - numusers++; - - if (curlen > (480-NICKMAX)) + 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",this->Instance->Config->GetSID().c_str(),c->name,(unsigned long)c->age); + 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; - ptrlen = 0; numusers = 0; } + + // The first parameter gets a : before it + ptrlen = snprintf(ptr, MAXBUF, " %s%s,%s", !numusers ? ":" : "", modestr.c_str(), i->first->uuid.c_str()); + + looped_once = true; + + curlen += ptrlen; + ptr += ptrlen; + + numusers++; } - if (numusers) + // Okay, permanent channels will (of course) need this \r\n anyway, numusers check is if there + // actually were people in the channel (looped_once == true) + if (!looped_once || numusers > 0) buffer.append(list).append("\r\n"); - buffer.append(":").append(this->Instance->Config->GetSID()).append(" FMODE ").append(c->name).append(" ").append(ConvToStr(c->age)).append(" +").append(c->ChanModes(true)).append("\r\n"); - 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"); @@ -170,7 +174,7 @@ void TreeSocket::SendXLines(TreeServer* Current) if (!i->second->IsBurstable()) break; - snprintf(data,MAXBUF,":%s ADDLINE %s %s %s %lu %lu :%s\r\n",sn, it->c_str(), i->second->Displayable(), + snprintf(data,MAXBUF,":%s ADDLINE %s %s %s %lu %lu :%s",sn, it->c_str(), i->second->Displayable(), i->second->source, (unsigned long)i->second->set_time, (unsigned long)i->second->duration, @@ -188,13 +192,12 @@ void TreeSocket::SendChannelModes(TreeServer* Current) std::deque list; std::string n = this->Instance->Config->GetSID(); const char* sn = n.c_str(); - Instance->Logs->Log("m_spanningtree",DEBUG,"Sending channels and modes, %d to send", this->Instance->chanlist->size()); 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)); @@ -220,19 +223,19 @@ void TreeSocket::SendUsers(TreeServer* Current) TreeServer* theirserver = Utils->FindServer(u->second->server); if (theirserver) { - snprintf(data,MAXBUF,":%s UID %s %lu %s %s %s %s +%s %s %lu :%s", theirserver->GetID().c_str(), u->second->uuid, - (unsigned long)u->second->age, u->second->nick, u->second->host, u->second->dhost, - u->second->ident, u->second->FormatModes(), u->second->GetIPString(), - (unsigned long)u->second->signon, u->second->fullname); + snprintf(data,MAXBUF,":%s UID %s %lu %s %s %s %s +%s %s %lu :%s", theirserver->GetID().c_str(), u->second->uuid.c_str(), + (unsigned long)u->second->age, u->second->nick.c_str(), u->second->host.c_str(), u->second->dhost.c_str(), + u->second->ident.c_str(), u->second->FormatModes(), u->second->GetIPString(), + (unsigned long)u->second->signon, u->second->fullname.c_str()); this->WriteLine(data); if (IS_OPER(u->second)) { - snprintf(data,MAXBUF,":%s OPERTYPE %s", u->second->uuid, u->second->oper); + snprintf(data,MAXBUF,":%s OPERTYPE %s", u->second->uuid.c_str(), u->second->oper.c_str()); this->WriteLine(data); } if (IS_AWAY(u->second)) { - snprintf(data,MAXBUF,":%s AWAY :%s", u->second->uuid, u->second->awaymsg); + snprintf(data,MAXBUF,":%s AWAY :%s", u->second->uuid.c_str(), u->second->awaymsg.c_str()); this->WriteLine(data); } }