Make struct Ban monolithic and improve memory statistics counting.
[ircu2.10.12-pk.git] / ircd / m_burst.c
index 62a3e363a38d7eb57d8ff40efc8ce520bd8900cb..01be1a6a6c9dc6cf3c524ccb77b2e916e43ad1f5 100644 (file)
@@ -87,6 +87,7 @@
 #include "ircd.h"
 #include "ircd_alloc.h"
 #include "ircd_features.h"
+#include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_string.h"
 #include "list.h"
 #include "struct.h"
 #include "ircd_snprintf.h"
 
-#include <assert.h>
+/* #include <assert.h> -- Now using assert in ircd_log.h */
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
@@ -276,6 +277,24 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     modebuf_mode(mbuf, MODE_DEL | chptr->mode.mode); /* wipeout modes */
     chptr->mode.mode &= MODE_BURSTADDED | MODE_WASDELJOINS;
 
+    /* wipe out modes not represented in chptr->mode.mode */
+    if (chptr->mode.limit) {
+      modebuf_mode_uint(mbuf, MODE_DEL | MODE_LIMIT, chptr->mode.limit);
+      chptr->mode.limit = 0;
+    }
+    if (chptr->mode.key[0]) {
+      modebuf_mode_string(mbuf, MODE_DEL | MODE_KEY, chptr->mode.key, 0);
+      chptr->mode.key[0] = '\0';
+    }
+    if (chptr->mode.upass[0]) {
+      modebuf_mode_string(mbuf, MODE_DEL | MODE_UPASS, chptr->mode.upass, 0);
+      chptr->mode.upass[0] = '\0';
+    }
+    if (chptr->mode.apass[0]) {
+      modebuf_mode_string(mbuf, MODE_DEL | MODE_APASS, chptr->mode.apass, 0);
+      chptr->mode.apass[0] = '\0';
+    }
+
     parse_flags |= (MODE_PARSE_SET | MODE_PARSE_WIPEOUT); /* wipeout keys */
 
     /* mark bans for wipeout */
@@ -350,9 +369,7 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
              banstr[banpos++] = *ptr;
 
            newban = make_ban(ban); /* create new ban */
-
-            DupString(newban->who, 
-                      cli_name(feature_bool(FEAT_HIS_BANWHO) ? &me : sptr));
+            strcpy(newban->who, "*");
            newban->when = TStime();
 
            newban->flags = BAN_BURSTED; /* set flags */
@@ -412,7 +429,7 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
                    current_mode_needs_reset = 0;
                  }
                  current_mode = (current_mode & ~CHFL_DELAYED) | CHFL_VOICE;
-                 oplevel = -1; /* subsequential digits are an absolute op-level value. */
+                 oplevel = -1; /* subsequent digits are an absolute op-level value. */
                 }
                else if (isdigit(*ptr)) {
                  int level_increment = 0;
@@ -453,7 +470,12 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
            if (current_mode & CHFL_VOICE)
              nickstr[nickpos++] = 'v';
            if (current_mode & CHFL_CHANOP)
-             nickpos += ircd_snprintf(0, nickstr + nickpos, sizeof(nickstr) - nickpos, "%u", oplevel);
+            {
+              if (chptr->mode.apass[0])
+               nickpos += ircd_snprintf(0, nickstr + nickpos, sizeof(nickstr) - nickpos, "%u", oplevel);
+              else
+                nickstr[nickpos++] = 'o';
+            }
          } else if (current_mode & CHFL_CHANOP && oplevel != last_oplevel) { /* if just op level changed... */
            nickstr[nickpos++] = ':'; /* add a specifier */
            nickpos += ircd_snprintf(0, nickstr + nickpos, sizeof(nickstr) - nickpos, "%u", oplevel - last_oplevel);
@@ -513,8 +535,9 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
          modebuf_mode_client(mbuf, MODE_DEL | CHFL_CHANOP, member->user);
        if (member->status & CHFL_VOICE)
          modebuf_mode_client(mbuf, MODE_DEL | CHFL_VOICE, member->user);
-       member->status = ((member->status & ~(CHFL_CHANOP | CHFL_VOICE)) |
-                         CHFL_DEOPPED);
+       member->status = (member->status
+                          & ~(CHFL_CHANNEL_MANAGER | CHFL_CHANOP | CHFL_VOICE))
+                        | CHFL_DEOPPED;
       }
     }
 
@@ -525,9 +548,10 @@ int ms_burst(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
 
       /* remove ban from channel */
       if (lp->flags & (BAN_OVERLAPPED | BAN_BURST_WIPEOUT)) {
+        char *bandup;
+        DupString(bandup, lp->banstr);
        modebuf_mode_string(mbuf, MODE_DEL | MODE_BAN,
-                           lp->banstr, 1); /* let it free banstr */
-        lp->banstr = NULL; /* do not free this string */
+                           bandup, 1);
        *lp_p = lp->next; /* clip out of list */
         free_ban(lp);
        continue;