Explorar o código

* The -ban fixes for removal by number weren't working right.

svn: 2061
Bryan Drewery %!s(int64=21) %!d(string=hai) anos
pai
achega
c414af4829
Modificáronse 3 ficheiros con 18 adicións e 21 borrados
  1. 0 1
      src/chan.h
  2. 18 17
      src/mod/channels.mod/userchan.c
  3. 0 3
      src/userrec.c

+ 0 - 1
src/chan.h

@@ -79,7 +79,6 @@ typedef struct maskrec {
        *user;
 } maskrec;
 extern maskrec *global_bans, *global_exempts, *global_invites;
-extern int	n_bans, n_exempts, n_invites;
 #define MASKREC_STICKY 1
 #define MASKREC_PERM   2
 

+ 18 - 17
src/mod/channels.mod/userchan.c

@@ -206,28 +206,38 @@ bool u_match_mask(maskrec *rec, char *mask)
   return 0;
 }
 
+static int count_mask(maskrec *rec)
+{
+  int ret = 0;
+
+  for (; rec; rec = rec->next)
+    ret++;
+
+  return ret;
+}
+
 int u_delmask(char type, struct chanset_t *c, char *who, int doit)
 {
-  int j, i = 0, *n_mask = NULL;
+  int j, i = 0, n_mask = 0;
   char temp[256] = "";
   maskrec **u = NULL, *t;
 
   if (type == 'b') {
     u = c ? &c->bans : &global_bans;
-    n_mask = &n_bans;
+    n_mask = count_mask(global_bans);
   } else if (type == 'e') {
     u = c ? &c->exempts : &global_exempts;
-    n_mask = &n_exempts;
+    n_mask = count_mask(global_exempts);
   } else if (type == 'I') {
     u = c ? &c->invites : &global_invites;
-    n_mask = &n_invites;
+    n_mask = count_mask(global_invites);
   }
 
   if (!strchr(who, '!') && str_isdigit(who)) {
     j = atoi(who);
     j--;		/* our list starts at 0 */
     if (c)
-      j -= *n_mask;	/* subtract out the globals as the number given is globals+j */
+      j -= n_mask;	/* subtract out the globals as the number given is globals+j */
     for (; (*u) && j; u = &((*u)->next), j--);
     if (*u) {
       strlcpy(temp, (*u)->mask, sizeof temp);
@@ -268,8 +278,6 @@ int u_delmask(char type, struct chanset_t *c, char *who, int doit)
     t = *u;
     *u = (*u)->next;
     free(t);
-    if (!c)
-      (*n_mask)--;
   }
   return i;
 }
@@ -280,18 +288,13 @@ bool u_addmask(char type, struct chanset_t *chan, char *who, char *from, char *n
 {
   char host[1024] = "", s[1024] = "";
   maskrec *p = NULL, *l = NULL, **u = NULL;
-  int *n_mask = NULL;
 
-  if (type == 'b') {
+  if (type == 'b')
     u = chan ? &chan->bans : &global_bans;
-    n_mask = &n_bans;
-  } else if (type == 'e') {
+  else if (type == 'e')
     u = chan ? &chan->exempts : &global_exempts;
-    n_mask = &n_exempts;
-  } else if (type == 'I') {
+  else if (type == 'I')
     u = chan ? &chan->invites : &global_invites;
-    n_mask = &n_invites;
-  }
 
   strcpy(host, who);
   /* Choke check: fix broken bans (must have '!' and '@') */
@@ -344,8 +347,6 @@ bool u_addmask(char type, struct chanset_t *chan, char *who, char *from, char *n
     free( p->user );
     free( p->desc );
   }
-  if (!chan)
-    (*n_mask)++;
 
   p->expire = expire_time;
   p->added = now;

+ 0 - 3
src/userrec.c

@@ -32,9 +32,6 @@ struct userrec	*lastuser = NULL;	/* last accessed user record	    */
 maskrec		*global_bans = NULL,
 		*global_exempts = NULL,
 		*global_invites = NULL;
-int		n_bans = 0;
-int		n_exempts = 0;
-int		n_invites = 0;
 
 struct igrec	*global_ign = NULL;
 int		cache_hit = 0,