/[svn]/ircd-hybrid/branches/8.1.x/modules/core/m_nick.c
ViewVC logotype

Diff of /ircd-hybrid/branches/8.1.x/modules/core/m_nick.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2366 by michael, Wed Jun 19 12:09:18 2013 UTC revision 2367 by michael, Thu Jul 4 22:42:00 2013 UTC
# Line 187  set_initial_nick(struct Client *source_p Line 187  set_initial_nick(struct Client *source_p
187  static void  static void
188  change_local_nick(struct Client *source_p, const char *nick)  change_local_nick(struct Client *source_p, const char *nick)
189  {  {
190      int samenick = 0;
191    
192    assert(source_p->name[0] && !EmptyString(nick));    assert(source_p->name[0] && !EmptyString(nick));
193    assert(MyConnect(source_p));    assert(MyConnect(source_p));
194    
# Line 198  change_local_nick(struct Client *source_ Line 200  change_local_nick(struct Client *source_
200    if ((source_p->localClient->last_nick_change +    if ((source_p->localClient->last_nick_change +
201         ConfigFileEntry.max_nick_time) < CurrentTime)         ConfigFileEntry.max_nick_time) < CurrentTime)
202      source_p->localClient->number_of_nick_changes = 0;      source_p->localClient->number_of_nick_changes = 0;
203    
204      if (ConfigFileEntry.anti_nick_flood &&
205          !HasUMode(source_p, UMODE_OPER) &&
206          source_p->localClient->number_of_nick_changes >
207          ConfigFileEntry.max_nick_changes)
208      {
209        sendto_one(source_p, form_str(ERR_NICKTOOFAST), me.name,
210                   source_p->name, source_p->name, nick,
211                   ConfigFileEntry.max_nick_time);
212        return;
213      }
214    
215    source_p->localClient->last_nick_change = CurrentTime;    source_p->localClient->last_nick_change = CurrentTime;
216    source_p->localClient->number_of_nick_changes++;    source_p->localClient->number_of_nick_changes++;
217    
218    if ((ConfigFileEntry.anti_nick_flood &&    samenick = !irccmp(source_p->name, nick);
219        (source_p->localClient->number_of_nick_changes  
220         <= ConfigFileEntry.max_nick_changes)) ||    if (!samenick)
      !ConfigFileEntry.anti_nick_flood ||  
      (HasUMode(source_p, UMODE_OPER) && ConfigFileEntry.no_oper_flood))  
221    {    {
222      int samenick = !irccmp(source_p->name, nick);      source_p->tsinfo = CurrentTime;
223        clear_ban_cache_client(source_p);
224        watch_check_hash(source_p, RPL_LOGOFF);
225    
226      if (!samenick)      if (HasUMode(source_p, UMODE_REGISTERED))
227      {      {
228        source_p->tsinfo = CurrentTime;        unsigned int oldmodes = source_p->umodes;
229        clear_ban_cache_client(source_p);        char modebuf[IRCD_BUFSIZE] = { '\0' };
230        watch_check_hash(source_p, RPL_LOGOFF);  
231          DelUMode(source_p, UMODE_REGISTERED);
232        if (HasUMode(source_p, UMODE_REGISTERED))        send_umode(source_p, source_p, oldmodes, 0xffffffff, modebuf);
       {  
         unsigned int oldmodes = source_p->umodes;  
         char modebuf[IRCD_BUFSIZE] = { '\0' };  
   
         DelUMode(source_p, UMODE_REGISTERED);  
         send_umode(source_p, source_p, oldmodes, 0xffffffff, modebuf);  
       }  
233      }      }
234      }
235    
236      sendto_realops_flags(UMODE_NCHANGE, L_ALL, SEND_NOTICE,    sendto_realops_flags(UMODE_NCHANGE, L_ALL, SEND_NOTICE,
237                           "Nick change: From %s to %s [%s@%s]",                         "Nick change: From %s to %s [%s@%s]",
238                           source_p->name, nick, source_p->username, source_p->host);                         source_p->name, nick, source_p->username, source_p->host);
239      sendto_common_channels_local(source_p, 1, 0, ":%s!%s@%s NICK :%s",    sendto_common_channels_local(source_p, 1, 0, ":%s!%s@%s NICK :%s",
240                                   source_p->name, source_p->username,                                 source_p->name, source_p->username,
241                                   source_p->host, nick);                                 source_p->host, nick);
242      whowas_add_history(source_p, 1);    whowas_add_history(source_p, 1);
243    
244      sendto_server(source_p, CAP_TS6, NOCAPS,    sendto_server(source_p, CAP_TS6, NOCAPS,
245                    ":%s NICK %s :%lu",                  ":%s NICK %s :%lu",
246                    ID(source_p), nick, (unsigned long)source_p->tsinfo);                  ID(source_p), nick, (unsigned long)source_p->tsinfo);
247      sendto_server(source_p, NOCAPS, CAP_TS6,    sendto_server(source_p, NOCAPS, CAP_TS6,
248                    ":%s NICK %s :%lu",                  ":%s NICK %s :%lu",
249                    source_p->name, nick, (unsigned long)source_p->tsinfo);                  source_p->name, nick, (unsigned long)source_p->tsinfo);
250    
251      hash_del_client(source_p);    hash_del_client(source_p);
252      strlcpy(source_p->name, nick, sizeof(source_p->name));    strlcpy(source_p->name, nick, sizeof(source_p->name));
253      hash_add_client(source_p);    hash_add_client(source_p);
254    
255      if (!samenick)    if (!samenick)
256        watch_check_hash(source_p, RPL_LOGON);      watch_check_hash(source_p, RPL_LOGON);
257    
258      /* fd_desc is long enough */    /* fd_desc is long enough */
259      fd_note(&source_p->localClient->fd, "Nick: %s", nick);    fd_note(&source_p->localClient->fd, "Nick: %s", nick);
   }  
   else  
     sendto_one(source_p, form_str(ERR_NICKTOOFAST), me.name,  
                source_p->name, source_p->name, nick,  
                ConfigFileEntry.max_nick_time);  
260  }  }
261    
262  /*  /*

Legend:
Removed from v.2366  
changed lines
  Added in v.2367

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28