]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/netburst.cpp
Addendum to previous ping patch: NextPingTime was not being set at endburst, and...
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / netburst.cpp
index b97c582d0b2fca9b29ca4baaea0b3f5428eeeaf4..e31508cb2f3cfbea1d7e925d81e85f91d2934f9c 100644 (file)
@@ -2,8 +2,8 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
@@ -84,10 +84,11 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
        std::string buffer;
        char list[MAXBUF];
 
-       size_t dlen, curlen;
-       dlen = curlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu +%s", this->ServerInstance->Config->GetSID().c_str(), c->name.c_str(),(unsigned long)c->age, c->ChanModes(true));
+       size_t curlen, headlen;
+       curlen = headlen = snprintf(list,MAXBUF,":%s FJOIN %s %lu +%s :",
+               this->ServerInstance->Config->GetSID().c_str(), c->name.c_str(), (unsigned long)c->age, c->ChanModes(true));
        int numusers = 0;
-       char* ptr = list + dlen;
+       char* ptr = list + curlen;
        bool looped_once = false;
 
        CUList *ulist = c->GetUsers();
@@ -101,14 +102,16 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
 
                if ((curlen + modestr.length() + i->first->uuid.length() + 4) > 480)
                {
+                       // remove the final space
+                       if (ptr[-1] == ' ')
+                               ptr[-1] = '\0';
                        buffer.append(list).append("\r\n");
-                       dlen = curlen = snprintf(list, MAXBUF, ":%s FJOIN %s %lu +%s", this->ServerInstance->Config->GetSID().c_str(), c->name.c_str(), (unsigned long)c->age, c->ChanModes(true));
-                       ptr = list + dlen;
+                       curlen = headlen;
+                       ptr = list + headlen;
                        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());
+               ptrlen = snprintf(ptr, MAXBUF-curlen, "%s,%s ", modestr.c_str(), i->first->uuid.c_str());
 
                looped_once = true;
 
@@ -121,7 +124,12 @@ void TreeSocket::SendFJoins(TreeServer* Current, Channel* c)
        // 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)
+       {
+               // remove the final space
+               if (ptr[-1] == ' ')
+                       ptr[-1] = '\0';
                buffer.append(list).append("\r\n");
+       }
 
        int linesize = 1;
        for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
@@ -159,6 +167,7 @@ void TreeSocket::SendXLines(TreeServer* Current)
        const char* sn = n.c_str();
 
        std::vector<std::string> types = ServerInstance->XLines->GetAllTypes();
+       time_t current = ServerInstance->Time();
 
        for (std::vector<std::string>::iterator it = types.begin(); it != types.end(); ++it)
        {
@@ -174,6 +183,11 @@ void TreeSocket::SendXLines(TreeServer* Current)
                                if (!i->second->IsBurstable())
                                        break;
 
+                               /* If it's expired, don't bother to burst it
+                                */
+                               if (i->second->duration && current > i->second->expiry)
+                                       continue;
+
                                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,