Просмотр исходного кода

* Fixed cmd_mns_(ban|exempt|invite) to remove the proper ban if a number is used (#38)

svn: 2034
Bryan Drewery 21 лет назад
Родитель
Сommit
0c38de8025
4 измененных файлов с 30 добавлено и 8 удалено
  1. 1 0
      doc/UPDATES
  2. 1 0
      src/chan.h
  3. 24 8
      src/mod/channels.mod/userchan.c
  4. 4 0
      src/userrec.c

+ 1 - 0
doc/UPDATES

@@ -93,6 +93,7 @@ Lines prefixxed with '-' were disabled before release and are not finishsed, or
 * Added some missing logging for msg_pass (#34)
 * Fixed msgs being logged when the msg has triggered an ignore for flooding. (#23)
 * botcmd * wasn't correctly being restricted to +n (#35)
+* Fixed cmd_mns_(ban|exempt|invite) to remove the proper ban if a number is used (#38)
 
 1.2.2
 * Don't sanity check flags for users on DCC CHAT if they are on the bot via .botcmd.

+ 1 - 0
src/chan.h

@@ -79,6 +79,7 @@ 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
 

+ 24 - 8
src/mod/channels.mod/userchan.c

@@ -208,20 +208,26 @@ bool u_match_mask(maskrec *rec, char *mask)
 
 int u_delmask(char type, struct chanset_t *c, char *who, int doit)
 {
-  int j, i = 0;
+  int j, i = 0, *n_mask = NULL;
   char temp[256] = "";
   maskrec **u = NULL, *t;
 
-  if (type == 'b')
+  if (type == 'b') {
     u = c ? &c->bans : &global_bans;
-  if (type == 'e')
+    n_mask = &n_bans;
+  } else if (type == 'e') {
     u = c ? &c->exempts : &global_exempts;
-  if (type == 'I')
+    n_mask = &n_exempts;
+  } else if (type == 'I') {
     u = c ? &c->invites : &global_invites;
+    n_mask = &n_invites;
+  }
 
   if (!strchr(who, '!') && str_isdigit(who)) {
     j = atoi(who);
-    j--;
+    j--;		/* our list starts at 0 */
+    if (c)
+      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);
@@ -262,6 +268,8 @@ 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;
 }
@@ -272,13 +280,18 @@ 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;
-  if (type == 'e')
+    n_mask = &n_bans;
+  } else if (type == 'e') {
     u = chan ? &chan->exempts : &global_exempts;
-  if (type == 'I')
+    n_mask = &n_exempts;
+  } 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 '@') */
@@ -331,6 +344,9 @@ 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;
   p->lastactive = 0;

+ 4 - 0
src/userrec.c

@@ -32,6 +32,10 @@ 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,
 		cache_miss = 0;		/* temporary cache accounting	    */