Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / channel.c
index 114deb0938487e662f8c07961fd0a8827ebb2468..38a5356a8cd85487ab6779a482195d39df1874aa 100644 (file)
@@ -19,6 +19,8 @@
  *
  * $Id$
  */
+#include "config.h"
+
 #include "channel.h"
 #include "client.h"
 #include "hash.h"
@@ -26,6 +28,7 @@
 #include "ircd_alloc.h"
 #include "ircd_chattr.h"
 #include "ircd_defs.h"
+#include "ircd_features.h"
 #include "ircd_log.h"
 #include "ircd_reply.h"
 #include "ircd_snprintf.h"
@@ -148,7 +151,7 @@ struct Client* find_chasing(struct Client* sptr, const char* user, int* chasing)
   if (who)
     return who;
 
-  if (!(who = get_history(user, KILLCHASETIMELIMIT))) {
+  if (!(who = get_history(user, feature_int(FEAT_KILLCHASETIMELIMIT)))) {
     send_reply(sptr, ERR_NOSUCHNICK, user);
     return 0;
   }
@@ -339,7 +342,9 @@ int add_banid(struct Client *cptr, struct Channel *chptr, char *banid,
       banp = &(*banp)->next;
     }
   }
-  if (MyUser(cptr) && !removed_bans && (len > MAXBANLENGTH || (cnt >= MAXBANS)))
+  if (MyUser(cptr) && !removed_bans &&
+      (len > (feature_int(FEAT_AVBANLEN) * feature_int(FEAT_MAXBANS)) ||
+       (cnt >= feature_int(FEAT_MAXBANS))))
   {
     send_reply(cptr, ERR_BANLISTFULL, chptr->chname, banid);
     return -1;
@@ -696,10 +701,11 @@ int client_can_send_to_channel(struct Client *cptr, struct Channel *chptr)
 
   /*
    * You can't speak if your off channel, if the channel is modeless, or
-   * +n.(no external messages)
+   * +n (no external messages) or +m (moderated).
    */
   if (!member) {
-    if ((chptr->mode.mode & MODE_NOPRIVMSGS) || IsModelessChannel(chptr->chname)) 
+    if ((chptr->mode.mode & (MODE_NOPRIVMSGS|MODE_MODERATED)) 
+       || IsModelessChannel(chptr->chname)) 
       return 0;
     else
       return 1;
@@ -757,11 +763,12 @@ void channel_modes(struct Client *cptr, char *mbuf, char *pbuf,
 
   if (*chptr->mode.key) {
     *mbuf++ = 'k';
+    if (chptr->mode.limit)
+      strcat(pbuf, " ");
     if (is_chan_op(cptr, chptr) || IsServer(cptr)) {
-      if (chptr->mode.limit)
-        strcat(pbuf, " ");
       strcat(pbuf, chptr->mode.key);
-    }
+    } else
+      strcat(pbuf, "*");
   }
   *mbuf = '\0';
 }
@@ -1154,7 +1161,7 @@ void add_invite(struct Client *cptr, struct Channel *chptr)
    * Delete last link in chain if the list is max length
    */
   assert(list_length((cli_user(cptr))->invited) == (cli_user(cptr))->invites);
-  if ((cli_user(cptr))->invites>=MAXCHANNELSPERUSER)
+  if ((cli_user(cptr))->invites >= feature_int(FEAT_MAXCHANNELSPERUSER))
     del_invite(cptr, (cli_user(cptr))->invited->value.chptr);
   /*
    * Add client to channel invite list
@@ -1240,6 +1247,8 @@ void list_next_channels(struct Client *cptr, int nr)
     (cli_listing(cptr))->chptr = chptr;
     chptr->mode.mode |= MODE_LISTED;
   }
+
+  update_write(cptr);
 }
 
 /*
@@ -2171,16 +2180,18 @@ mode_parse_ban(struct ParseState *state, int *flag_p)
     } else if (state->dir == MODE_ADD) {
       /* if the ban already exists, don't worry about it */
       if (!ircd_strcmp(ban->value.ban.banstr, t_str)) {
+       newban->flags &= ~MODE_ADD; /* don't add ban at all */
+       MyFree(newban->value.ban.banstr); /* stopper a leak */
+       state->numbans--; /* deallocate last ban */
        if (state->done & DONE_BANCLEAN) /* If we're cleaning, finish */
          break;
-       continue;
       } else if (!mmatch(ban->value.ban.banstr, t_str)) {
        if (!(ban->flags & MODE_DEL))
          newban->flags |= CHFL_BAN_OVERLAPPED; /* our ban overlaps */
       } else if (!mmatch(t_str, ban->value.ban.banstr))
        ban->flags |= MODE_DEL; /* mark ban for deletion: overlapping */
 
-      if (!ban->next) {
+      if (!ban->next && (newban->flags & MODE_ADD)) {
        ban->next = newban; /* add our ban with its flags */
        break; /* get out of loop */
       }
@@ -2255,7 +2266,8 @@ mode_process_bans(struct ParseState *state)
        MyFree(ban->value.ban.banstr);
       } else {
        if (state->flags & MODE_PARSE_SET && MyUser(state->sptr) &&
-           (len > MAXBANLENGTH || count >= MAXBANS)) {
+           (len > (feature_int(FEAT_AVBANLEN) * feature_int(FEAT_MAXBANS)) ||
+            count >= feature_int(FEAT_MAXBANS))) {
          send_reply(state->sptr, ERR_BANLISTFULL, state->chptr->chname,
                     ban->value.ban.banstr);
          count--;