]> jfr.im git - solanum.git/blobdiff - ircd/channel.c
support RSFNC indicating type of FNC (e.g. FORCE vs REGAIN) (#406)
[solanum.git] / ircd / channel.c
index c09a717d12c1bf797a3a919b78cac85d90c4e0d4..0a01f972cbe62d9a0e9f7fce60264d3ba76634c6 100644 (file)
@@ -487,11 +487,6 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo
        struct membership *msptr;
        struct Client *target_p;
        rb_dlink_node *ptr;
-       char lbuf[BUFSIZE];
-       char *t;
-       int mlen;
-       int tlen;
-       int cur_len;
        int is_member;
        int stack = IsCapable(client_p, CLICAP_MULTI_PREFIX);
 
@@ -499,11 +494,11 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo
        {
                is_member = IsMember(client_p, chptr);
 
-               cur_len = mlen = sprintf(lbuf, form_str(RPL_NAMREPLY),
-                                           me.name, client_p->name,
-                                           channel_pub_or_secret(chptr), chptr->chname);
-
-               t = lbuf + cur_len;
+               send_multiline_init(client_p, " ", form_str(RPL_NAMREPLY),
+                               me.name,
+                               client_p->name,
+                               channel_pub_or_secret(chptr),
+                               chptr->chname);
 
                RB_DLINK_FOREACH(ptr, chptr->members.head)
                {
@@ -515,49 +510,21 @@ channel_member_names(struct Channel *chptr, struct Client *client_p, int show_eo
 
                        if (IsCapable(client_p, CLICAP_USERHOST_IN_NAMES))
                        {
-                               /* space, possible "@+" prefix */
-                               if (cur_len + strlen(target_p->name) + strlen(target_p->username) + strlen(target_p->host) + 5 >= BUFSIZE - 5)
-                               {
-                                       *(t - 1) = '\0';
-                                       sendto_one(client_p, "%s", lbuf);
-                                       cur_len = mlen;
-                                       t = lbuf + mlen;
-                               }
-
-                               tlen = sprintf(t, "%s%s!%s@%s ", find_channel_status(msptr, stack),
-                                                 target_p->name, target_p->username, target_p->host);
+                               send_multiline_item(client_p, "%s%s!%s@%s",
+                                               find_channel_status(msptr, stack),
+                                               target_p->name,
+                                               target_p->username,
+                                               target_p->host);
                        }
                        else
                        {
-                               /* space, possible "@+" prefix */
-                               if(cur_len + strlen(target_p->name) + 3 >= BUFSIZE - 3)
-                               {
-                                       *(t - 1) = '\0';
-                                       sendto_one(client_p, "%s", lbuf);
-                                       cur_len = mlen;
-                                       t = lbuf + mlen;
-                               }
-
-                               tlen = sprintf(t, "%s%s ", find_channel_status(msptr, stack),
-                                                 target_p->name);
+                               send_multiline_item(client_p, "%s%s",
+                                               find_channel_status(msptr, stack),
+                                               target_p->name);
                        }
-
-                       cur_len += tlen;
-                       t += tlen;
                }
 
-               /* The old behaviour here was to always output our buffer,
-                * even if there are no clients we can show.  This happens
-                * when a client does "NAMES" with no parameters, and all
-                * the clients on a -sp channel are +i.  I dont see a good
-                * reason for keeping that behaviour, as it just wastes
-                * bandwidth.  --anfl
-                */
-               if(cur_len != mlen)
-               {
-                       *(t - 1) = '\0';
-                       sendto_one(client_p, "%s", lbuf);
-               }
+               send_multiline_fini(client_p, NULL);
        }
 
        if(show_eon)
@@ -894,7 +861,7 @@ can_send(struct Channel *chptr, struct Client *source_p, struct membership *mspt
  * side effects        - check for flood attack on target chptr
  */
 bool
-flood_attack_channel(int p_or_n, struct Client *source_p, struct Channel *chptr, char *chname)
+flood_attack_channel(enum message_type msgtype, struct Client *source_p, struct Channel *chptr, char *chname)
 {
        int delta;
 
@@ -927,7 +894,7 @@ flood_attack_channel(int p_or_n, struct Client *source_p, struct Channel *chptr,
                                /* Add a bit of penalty */
                                chptr->received_number_of_privmsgs += 2;
                        }
-                       if(MyClient(source_p) && (p_or_n != 1))
+                       if(MyClient(source_p) && (msgtype != MESSAGE_TYPE_NOTICE))
                                sendto_one(source_p,
                                           ":%s NOTICE %s :*** Message to %s throttled due to flooding",
                                           me.name, source_p->name, chptr->chname);
@@ -1174,7 +1141,7 @@ channel_modes(struct Channel *chptr, struct Client *client_p)
 
        for (i = 0; i < 256; i++)
        {
-               if(chmode_table[i].set_func == chm_hidden && (!HasPrivilege(client_p, "auspex:cmodes") || !IsClient(client_p)))
+               if(chmode_table[i].set_func == chm_hidden && !HasPrivilege(client_p, "auspex:cmodes") && IsClient(client_p))
                        continue;
                if(chptr->mode.mode & chmode_flags[i])
                        *mbuf++ = i;