From 8f79485a75bfc6e1da9a65a81b7688514187b57b Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 7 Mar 2006 12:11:25 +0000 Subject: Took strlen's out of fjoin git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3515 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 2ecfdc696..d164bef27 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -1133,15 +1133,19 @@ class TreeSocket : public InspSocket log(DEBUG,"Sending FJOINs to other server for %s",c->name); char list[MAXBUF]; std::string individual_halfops = ":"+Srv->GetServerName()+" FMODE "+c->name; - snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age); + size_t counter = snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age); + size_t initial = counter; + std::map *ulist = c->GetUsers(); std::vector specific_halfop; std::vector specific_voice; + for (std::map::iterator i = ulist->begin(); i != ulist->end(); i++) { char* o = i->second; userrec* otheruser = (userrec*)o; charlcat(list,' ',MAXBUF); + counter++; int x = cflags(otheruser,c); if ((x & UCMODE_HOP) && (x & UCMODE_OP)) { @@ -1167,14 +1171,18 @@ class TreeSocket : public InspSocket } if (n) + { charlcat(list,n,MAXBUF); + counter++; + } + + counter += strlcat(list,otheruser->nick,MAXBUF); - strlcat(list,otheruser->nick,MAXBUF); - if (strlen(list)>(480-NICKMAX)) + if (counter > (480-NICKMAX)) { log(DEBUG,"FJOIN line wrapped"); this->WriteLine(list); - snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age); + counter = snprintf(list,MAXBUF,":%s FJOIN %s %lu",Srv->GetServerName().c_str(),c->name,(unsigned long)c->age); for (unsigned int y = 0; y < specific_voice.size(); y++) { this->WriteLine(":"+Srv->GetServerName()+" FMODE "+c->name+" +v "+specific_voice[y]->nick); @@ -1185,7 +1193,7 @@ class TreeSocket : public InspSocket } } } - if (list[strlen(list)-1] != ':') + if (counter != initial) { log(DEBUG,"Final FJOIN line"); this->WriteLine(list); -- cgit v1.2.3