]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
Branch Merge
authorJD Horelick <redacted>
Sun, 4 Apr 2010 20:25:20 +0000 (16:25 -0400)
committerJD Horelick <redacted>
Sun, 4 Apr 2010 20:25:20 +0000 (16:25 -0400)
1  2 
src/chmode.c

diff --combined src/chmode.c
index 583e30c3a657aec6078cc982f6d2c301caca30cb,5aa618f863a6ee820b7d11a56cbe4c5fb691760b..c2fd63cef00f212dee79036af704504afbc97638
@@@ -74,11 -74,12 +74,11 @@@ int chmode_flags[256]
  
  /* OPTIMIZE ME! -- dwr */
  void
 -construct_noparam_modes(void)
 +construct_cflags_strings(void)
  {
        int i;
          char *ptr = cflagsbuf;
        char *ptr2 = cflagsmyinfo;
 -        static int prev_chmode_flags[256];
          
          *ptr = '\0';
        *ptr2 = '\0';
                        chmode_flags[i] = 0;
                }
                  
 -              if (prev_chmode_flags[i] != 0 && prev_chmode_flags[i] != chmode_flags[i])
 -              {
 -                      if (chmode_flags[i] == 0)
 -                      {
 -                                chmode_table[i].set_func = chm_orphaned;
 -                              sendto_realops_snomask(SNO_DEBUG, L_ALL, "Cmode +%c is now orphaned", i);
 -                      }
 -                      else
 -                      {
 -                              sendto_realops_snomask(SNO_DEBUG, L_ALL, "Orphaned cmode +%c is picked up by module", i);
 -                      }
 -                      chmode_flags[i] = prev_chmode_flags[i];
 -              }
 -              else
 -                      prev_chmode_flags[i] = chmode_flags[i];
 -                
                switch (chmode_flags[i])
                {
                    case MODE_EXLIMIT:
   *                0 if no cflags are available
   * side effects - NONE
   */
 -unsigned int
 +static unsigned int
  find_cflag_slot(void)
  {
        unsigned int all_cflags = 0, my_cflag = 0, i;
        return my_cflag;
  }
  
 +unsigned int
 +cflag_add(char c_, ChannelModeFunc function)
 +{
 +      int c = (unsigned char)c_;
 +
 +      if (chmode_table[c].set_func != chm_nosuch &&
 +                      chmode_table[c].set_func != chm_orphaned)
 +              return 0;
 +
 +      if (chmode_table[c].set_func == chm_nosuch)
 +              chmode_table[c].mode_type = find_cflag_slot();
 +      if (chmode_table[c].mode_type == 0)
 +              return 0;
 +      chmode_table[c].set_func = function;
 +      construct_cflags_strings();
 +      return chmode_table[c].mode_type;
 +}
 +
 +void
 +cflag_orphan(char c_)
 +{
 +      int c = (unsigned char)c_;
 +
 +      s_assert(chmode_flags[c] != 0);
 +      chmode_table[c].set_func = chm_orphaned;
 +      construct_cflags_strings();
 +}
 +
  static int
  get_channel_access(struct Client *source_p, struct membership *msptr)
  {
@@@ -671,6 -660,8 +671,8 @@@ chm_staff(struct Client *source_p, stru
          int alevel, int parc, int *parn,
          const char **parv, int *errors, int dir, char c, long mode_type)
  {
+       int override = 0;
        if(!IsOper(source_p) && !IsServer(source_p))
        {
                if(!(*errors & SM_ERR_NOPRIVS))
                return;
        }
  
+       if(alevel != CHFL_CHANOP && alevel != CHFL_ADMIN && alevel != CHFL_HALFOP)
+       {
+               if (IsOverride(source_p))
+                       override = 1;
+               else
+               {
+                       if(!(*errors & SM_ERR_NOOPS))
+                               sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
+                                               me.name, source_p->name, chptr->chname);
+                       *errors |= SM_ERR_NOOPS;
+                       return;
+               }
+       }
        if(MyClient(source_p) && (++mode_limit_simple > MAXMODES_SIMPLE))
                return;
  
                mode_changes[mode_count].nocaps = 0;
                mode_changes[mode_count].id = NULL;
                mode_changes[mode_count].mems = ALL_MEMBERS;
-               mode_changes[mode_count].override = 0;
+               mode_changes[mode_count].override = override;
                mode_changes[mode_count++].arg = NULL;
        }
        else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type))
                mode_changes[mode_count].caps = 0;
                mode_changes[mode_count].nocaps = 0;
                mode_changes[mode_count].mems = ALL_MEMBERS;
-               mode_changes[mode_count].override = 0;
+               mode_changes[mode_count].override = override;
                mode_changes[mode_count].id = NULL;
                mode_changes[mode_count++].arg = NULL;
        }