Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Thu, 30 Mar 2000 19:57:22 +0000 (19:57 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Thu, 30 Mar 2000 19:57:22 +0000 (19:57 +0000)
Log message:

* ircd/m_clearmode.c (do_clearmode): do_clearmode() would remove
+k and +l even if they weren't set...

* ircd/m_opmode.c: implement the OPMODE command using mode_parse()

* ircd/channel.c: make mode_process_clients() clear the DEOPPED
flag; fix +s+p exclusivity; add MODE_ADD/MODE_DEL to flag list
for; test the 0-th member, not the i-th member, of the client
change state stuff

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@107 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/channel.c
ircd/m_clearmode.c
ircd/m_opmode.c

index 3c6f8b14bb8dca70494a9581fe220f044209a83d..58b75adf565e865feedc596db74e54ebdece3fbc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2000-03-30  Kevin L. Mitchell  <klmitch@mit.edu>
 
+       * ircd/m_clearmode.c (do_clearmode): do_clearmode() would remove
+       +k and +l even if they weren't set...
+
+       * ircd/m_opmode.c: implement the OPMODE command using mode_parse()
+
+       * ircd/channel.c: make mode_process_clients() clear the DEOPPED
+       flag; fix +s+p exclusivity; add MODE_ADD/MODE_DEL to flag list
+       for; test the 0-th member, not the i-th member, of the client
+       change state stuff
+
        * ircd/m_clearmode.c (do_clearmode): use the new
        mode_invite_clear() function
 
 #
 # ChangeLog for ircu2.10.11
 #
-# $Id: ChangeLog,v 1.43 2000-03-30 18:36:24 kev Exp $
+# $Id: ChangeLog,v 1.44 2000-03-30 19:57:22 kev Exp $
 #
 # Insert new changes at beginning of the change list.
 #
index ced9ae398ea860664cec972d9964256083703e7a..9bd04d05aec5262a35f8925799af17c649e455e9 100644 (file)
@@ -3539,6 +3539,8 @@ mode_process_clients(struct ParseState *state)
   struct Membership *member;
 
   for (i = 0; state->cli_change[i].flag; i++) {
+    assert(0 != state->cli_change[i].client);
+
     /* look up member link */
     if (!(member = find_member_link(state->chptr,
                                    state->cli_change[i].client)) ||
@@ -3595,10 +3597,12 @@ mode_process_clients(struct ParseState *state)
 
     /* actually effect the change */
     if (state->flags & MODE_PARSE_SET) {
-      if (state->cli_change[i].flag & MODE_ADD)
+      if (state->cli_change[i].flag & MODE_ADD) {
        member->status |= (state->cli_change[i].flag &
                           (MODE_CHANOP | MODE_VOICE));
-      else
+       if (state->cli_change[i].flag & MODE_CHANOP)
+         ClearDeopped(member);
+      } else
        member->status &= ~(state->cli_change[i].flag &
                            (MODE_CHANOP | MODE_VOICE));
     }
@@ -3627,10 +3631,11 @@ mode_parse_mode(struct ParseState *state, int *flag_p)
 
   /* make +p and +s mutually exclusive */
   if (state->dir == MODE_ADD && flag_p[0] & (MODE_SECRET | MODE_PRIVATE)) {
-    if (flag_p[0] == MODE_SECRET)
-      modebuf_mode(state->mbuf, MODE_DEL | MODE_SECRET);
-    else
+    if (flag_p[0] == MODE_SECRET && (state->chptr->mode.mode & MODE_PRIVATE))
       modebuf_mode(state->mbuf, MODE_DEL | MODE_PRIVATE);
+    else if (flag_p[0] == MODE_PRIVATE &&
+            (state->chptr->mode.mode & MODE_SECRET))
+      modebuf_mode(state->mbuf, MODE_DEL | MODE_SECRET);
   }
 
   if (state->flags & MODE_PARSE_SET) { /* set the flags */
@@ -3675,6 +3680,8 @@ mode_parse(struct ModeBuf *mbuf, struct Client *cptr, struct Client *sptr,
     MODE_KEY,          'k',
     MODE_BAN,          'b',
     MODE_LIMIT,                'l',
+    MODE_ADD,          '+',
+    MODE_DEL,          '-',
     0x0, 0x0
   };
   int i;
@@ -3729,10 +3736,8 @@ mode_parse(struct ModeBuf *mbuf, struct Client *cptr, struct Client *sptr,
 
       switch (*modestr) {
       case '+': /* switch direction to MODE_ADD */
-       state.dir = MODE_ADD;
-       break;
       case '-': /* switch direction to MODE_DEL */
-       state.dir = MODE_DEL;
+       state.dir = flag_p[0];
        break;
 
       case 'l': /* deal with limits */
@@ -3797,7 +3802,7 @@ mode_parse(struct ModeBuf *mbuf, struct Client *cptr, struct Client *sptr,
     mode_process_bans(&state);
 
   /* process client changes */
-  if (state.cli_change[i].flag)
+  if (state.cli_change[0].flag)
     mode_process_clients(&state);
 
   return state.args_used; /* tell our parent how many args we gobbled */
index c41c122e40aa463eb44b9b69a3a5aa87062d94f4..a8045ccb00956eab7ab68a09276d016f005f3f99 100644 (file)
@@ -167,11 +167,11 @@ do_clearmode(struct Client *cptr, struct Client *sptr, struct Channel *chptr,
    * If we're removing the key, note that; note that we can't clear
    * the key until after modebuf_* are done with it
    */
-  if (del_mode & MODE_KEY)
+  if (del_mode & MODE_KEY && chptr->mode.mode & MODE_KEY)
     modebuf_mode_string(&mbuf, MODE_DEL | MODE_KEY, chptr->mode.key);
 
   /* If we're removing the limit, note that and clear the limit */
-  if (del_mode & MODE_LIMIT) {
+  if (del_mode & MODE_LIMIT && chptr->mode.mode & MODE_KEY) {
     modebuf_mode_uint(&mbuf, MODE_DEL | MODE_LIMIT, chptr->mode.limit);
     chptr->mode.limit = 0; /* not referenced, so safe */
   }
index 87f261c178316f5ea39a42c6a106f65cc71e1e85..2fd38712d5bbb0d16c39f465ecc559521bc6ec72 100644 (file)
  */
 int ms_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
+  struct Channel *chptr = 0;
+  struct ModeBuf mbuf;
+
+  if (parc < 3)
+    return need_more_params(sptr, "OPMODE");
+
+  if (IsLocalChannel(parv[1]))
+    return 0;
+
+  if ('#' != *parv[1] || !(chptr = FindChannel(parv[1])))
+    return send_error_to_client(sptr, ERR_NOSUCHCHANNEL, parv[1]);
+
+  modebuf_init(&mbuf, sptr, cptr, chptr,
+              (MODEBUF_DEST_CHANNEL | /* Send MODE to channel */
+               MODEBUF_DEST_SERVER  | /* And to server */
+               MODEBUF_DEST_OPMODE  | /* Use OPMODE */
+               MODEBUF_DEST_HACK4));  /* Generate a HACK(4) notice */
+
+  mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
+            (MODE_PARSE_SET    | /* Set the modes on the channel */
+             MODE_PARSE_STRICT | /* Be strict about it */
+             MODE_PARSE_FORCE)); /* And force them to be accepted */
+
+  modebuf_flush(&mbuf); /* flush the modes */
+
   return 0;
 }
 
@@ -114,6 +139,31 @@ int ms_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
  */
 int mo_opmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
+  struct Channel *chptr = 0;
+  struct ModeBuf mbuf;
+  struct Membership *member;
+
+  if (parc < 3)
+    return need_more_params(sptr, "OPMODE");
+
+  if (('#' != *parv[1] && '&' != *parv[1]) || !(chptr = FindChannel(parv[1])))
+    return send_error_to_client(sptr, ERR_NOSUCHCHANNEL, parv[1]);
+
+  if (!(member = find_member_link(chptr, sptr)))
+    return send_error_to_client(sptr, ERR_NOTONCHANNEL, chptr->chname);
+
+  modebuf_init(&mbuf, sptr, cptr, chptr,
+              (MODEBUF_DEST_CHANNEL | /* Send MODE to channel */
+               MODEBUF_DEST_SERVER  | /* And to server */
+               MODEBUF_DEST_OPMODE  | /* Use OPMODE */
+               MODEBUF_DEST_HACK4));  /* Generate a HACK(4) notice */
+
+  mode_parse(&mbuf, cptr, sptr, chptr, parc - 2, parv + 2,
+            (MODE_PARSE_SET |    /* set the modes on the channel */
+             MODE_PARSE_FORCE)); /* And force them to be accepted */
+
+  modebuf_flush(&mbuf); /* flush the modes */
+
   return 0;
 }