added support for halfop in MODE_NOFLOOD
authorpk910 <philipp@zoelle1.de>
Wed, 25 Jan 2012 22:49:07 +0000 (23:49 +0100)
committerpk910 <philipp@zoelle1.de>
Wed, 25 Jan 2012 22:50:30 +0000 (23:50 +0100)
ircd/channel.c

index 7e9bb09d14b05c1fb3a70fad2e850281f2587940..5a17a6bf21df3d859703b819c3138ecb01c0f797 100644 (file)
@@ -2673,8 +2673,9 @@ mode_parse_noflood(struct ParseState *state, ulong64 *flag_p)
         else t_str++; //simply ignore if it's not an opmode
         tmp++;
     }
-    if(tmp[0] == '+' || tmp[0] == '@') {
+    if(tmp[0] == '+' || tmp[0] == '%' || tmp[0] == '@') {
         if(tmp[0] == '+') flags |= FLFL_VOICE;
+        if(tmp[0] == '%') flags |= FLFL_HALFOP;
         if(tmp[0] == '@') flags |= FLFL_CHANOP;
         tmp++;
     }
@@ -2746,7 +2747,7 @@ mode_parse_noflood(struct ParseState *state, ulong64 *flag_p)
     unsigned int noflood_value = time;
     noflood_value <<= 10;
     noflood_value |= count;
-    noflood_value <<= 3;
+    noflood_value <<= 4;
     noflood_value |= flags;
     state->chptr->mode.noflood_value = noflood_value;
   } else {
@@ -4430,15 +4431,17 @@ int ext_noflood_block(struct Client *cptr, struct Channel *chptr) {
   struct Membership *member = find_member_link(chptr, cptr);
   if(!member) return 0; //TODO: we've no check for -n channels implemented, yet
   //check if this user is really affected by +f
-  unsigned int flags = (chptr->mode.noflood_value & 0x00000007);        //0000 0000 0000 0000 0000 0000 0000 0111 = 0x00000007 >> 0
-  unsigned int count = (chptr->mode.noflood_value & 0x00001ff8) >> 3;   //0000 0000 0000 0000 0001 1111 1111 1000 = 0x00001ff8 >> 3
-  int time           = (chptr->mode.noflood_value & 0x07ffe000) >> 13;  //0000 0111 1111 1111 1110 0000 0000 0000 = 0x07ffe000 >> 13
+  unsigned int flags = (chptr->mode.noflood_value & 0x0000000f);        //0000 0000 0000 0000 0000 0000 0000 1111 = 0x0000000f >> 0
+  unsigned int count = (chptr->mode.noflood_value & 0x00002ff0) >> 4;   //0000 0000 0000 0000 0011 1111 1111 0000 = 0x00002ff0 >> 4
+  int time           = (chptr->mode.noflood_value & 0x0fffc000) >> 14;  //0000 1111 1111 1111 1100 0000 0000 0000 = 0x0fffc000 >> 14
   if(count == 0 || time == 0) return 0;
   if(!(flags & FLFL_NOFLOOD) && HasPriv(cptr, PRIV_FLOOD))
     return 0;
   if(!(flags & FLFL_CHANOP) && (member->status & CHFL_CHANOP)) 
     return 0;
-  if(!(flags & (FLFL_CHANOP | FLFL_VOICE)) && (member->status & CHFL_VOICE)) 
+  if(!(flags & (FLFL_CHANOP | FLFL_HALFOP)) && (member->status & CHFL_HALFOP)) 
+    return 0;
+  if(!(flags & (FLFL_CHANOP | FLFL_HALFOP | FLFL_VOICE)) && (member->status & CHFL_VOICE)) 
     return 0;
   int floodcount = 0;
   struct MemberFlood *floodnode, *prev_floodnode;