Author: Isomer <isomer@coders.net>
[ircu2.10.12-pk.git] / ircd / m_endburst.c
index 242614505d3219127a51669e48cc12cefea099a7..9243d30bf4d41ae7b9e06433626abe18b12d9c2f 100644 (file)
  */
 #include "handlers.h"
 #endif /* 0 */
+#include "channel.h"
 #include "client.h"
 #include "hash.h"
 #include "ircd.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
+#include "msg.h"
 #include "numeric.h"
 #include "numnicks.h"
 #include "send.h"
  * This the last message in a net.burst.
  * It clears a flag for the server sending the burst.
  *
+ * As of 10.11, to fix a bug in the way BURST is processed, it also
+ * makes sure empty channels are deleted
+ *
  * parv[0] - sender prefix
  */
 int ms_end_of_burst(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
+  struct Channel *chan, *next_chan;
+
   assert(0 != cptr);
   assert(0 != sptr);
-  if (!IsServer(sptr))
-    return 0;
 
-  sendto_op_mask(SNO_NETWORK, "Completed net.burst from %s.", sptr->name);
-  sendto_serv_butone(cptr, "%s EB", NumServ(sptr));
+  sendto_opmask_butone(0, SNO_NETWORK, "Completed net.burst from %C.", 
+       sptr);
+  sendcmdto_serv_butone(sptr, CMD_END_OF_BURST, cptr, "");
   ClearBurst(sptr);
   SetBurstAck(sptr);
   if (MyConnect(sptr))
-    sendto_one(sptr, "%s EA", NumServ(&me));
+    sendcmdto_one(&me, CMD_END_OF_BURST_ACK, sptr, "");
 
-  return 0;
-}
-
-/*
- * ms_end_of_burst_ack - server message handler
- *
- * This the acknowledge message of the `END_OF_BURST' message.
- * It clears a flag for the server receiving the burst.
- *
- * parv[0] - sender prefix
- */
-int ms_end_of_burst_ack(struct Client *cptr, struct Client *sptr, int parc, char **parv)
-{
-  if (!IsServer(sptr))
-    return 0;
+  /* Count through channels... */
+  for (chan = GlobalChannelList; chan; chan = next_chan) {
+    next_chan = chan->next;
 
-  sendto_op_mask(SNO_NETWORK, "%s acknowledged end of net.burst.", sptr->name);
-  sendto_serv_butone(cptr, "%s EA", NumServ(sptr));
-  ClearBurstAck(sptr);
+    if (!chan->members) { /* empty channel */
+      if (!(chan->mode.mode & MODE_BURSTADDED))
+       sendto_opmask_butone(0, SNO_OLDSNO, "Empty channel %H not added by "
+                            "BURST!", chan);
 
-  return 0;
-}
+      sub1_from_channel(chan); /* ok, nuke channel now */
+    }
 
-
-#if 0
-/*
- * m_end_of_burst  - Added Xorath 6-14-96, rewritten by Run 24-7-96
- *                 - and fixed by record and Kev 8/1/96
- *                 - and really fixed by Run 15/8/96 :p
- * This the last message in a net.burst.
- * It clears a flag for the server sending the burst.
- *
- * parv[0] - sender prefix
- */
-int m_end_of_burst(struct Client *cptr, struct Client *sptr, int parc, char **parv)
-{
-  if (!IsServer(sptr))
-    return 0;
-
-  sendto_op_mask(SNO_NETWORK, "Completed net.burst from %s.", sptr->name);
-  sendto_serv_butone(cptr, "%s EB", NumServ(sptr));
-  ClearBurst(sptr);
-  SetBurstAck(sptr);
-  if (MyConnect(sptr))
-    sendto_one(sptr, "%s EA", NumServ(&me));
+    chan->mode.mode &= ~MODE_BURSTADDED;
+  }
 
   return 0;
 }
+
 /*
- * m_end_of_burst_ack
+ * ms_end_of_burst_ack - server message handler
  *
  * This the acknowledge message of the `END_OF_BURST' message.
  * It clears a flag for the server receiving the burst.
  *
  * parv[0] - sender prefix
  */
-int m_end_of_burst_ack(struct Client *cptr, struct Client *sptr, int parc, char **parv)
+int ms_end_of_burst_ack(struct Client *cptr, struct Client *sptr, int parc, char **parv)
 {
   if (!IsServer(sptr))
     return 0;
 
-  sendto_op_mask(SNO_NETWORK, "%s acknowledged end of net.burst.", sptr->name);
-  sendto_serv_butone(cptr, "%s EA", NumServ(sptr));
+  sendto_opmask_butone(0, SNO_NETWORK, "%C acknowledged end of net.burst.",
+                      sptr);
+  sendcmdto_serv_butone(sptr, CMD_END_OF_BURST_ACK, cptr, "");
   ClearBurstAck(sptr);
 
   return 0;
 }
-
-#endif /* 0 */
-