Ver Fonte

Only raise limit if needed, and use proper even value

Bryan Drewery há 14 anos atrás
pai
commit
124248581f
1 ficheiros alterados com 16 adições e 14 exclusões
  1. 16 14
      src/mod/irc.mod/irc.c

+ 16 - 14
src/mod/irc.mod/irc.c

@@ -1400,24 +1400,26 @@ raise_limit(struct chanset_t *chan)
   if (chan->mode_mns_prot & CHANLIMIT)
     return false;
 
-  const int nl = (chan->channel.members - chan->channel.splitmembers) + chan->limitraise;	/* new limit */
   const int limitraise = (chan->limitraise % 2 == 0) ? chan->limitraise : (chan->limitraise + 1);
-  const int i = limitraise >> 2;			/* DIV 4 */
-  /* if the newlimit will be in the range made by these vars, dont change. */
-  const int ul = nl + i;					/* upper limit */
-  const int ll = nl - i;					/* lower limit */
-
-  if ((chan->channel.maxmembers > ll) && (chan->channel.maxmembers < ul)) {
-    return false;                     /* the current limit is in the range, so leave it. */
-  }
+  if (limitraise) {
+    const int nl = (chan->channel.members - chan->channel.splitmembers) + limitraise;	/* new limit */
+    const int i = limitraise >> 2;			/* DIV 4 */
+    /* if the newlimit will be in the range made by these vars, dont change. */
+    const int ul = nl + i;					/* upper limit */
+    const int ll = nl - i;					/* lower limit */
+
+    if ((chan->channel.maxmembers > ll) && (chan->channel.maxmembers < ul)) {
+      return false;                     /* the current limit is in the range, so leave it. */
+    }
 
-  if (nl != chan->channel.maxmembers) {
-    char s[6] = "";
+    if (nl != chan->channel.maxmembers) {
+      char s[6] = "";
 
-    simple_snprintf(s, sizeof(s), "%d", nl);
-    add_mode(chan, '+', 'l', s);
+      simple_snprintf(s, sizeof(s), "%d", nl);
+      add_mode(chan, '+', 'l', s);
 
-    return true;
+      return true;
+    }
   }
 
   return false;