Author: Isomer <isomer@coders.net>
[ircu2.10.12-pk.git] / ircd / m_nick.c
index fe02d167a9c9f9c9e47d99d2dcfa8139a5666774..aa388825fe470858dbd7de1aded3e6ed87dcc4d6 100644 (file)
@@ -217,7 +217,6 @@ int m_nick(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
    */
   if (IsUnknown(acptr) && MyConnect(acptr)) {
     ++ServerStats->is_ref;
-    ip_registry_connect_fail(acptr->ip.s_addr);
     exit_client(cptr, acptr, &me, "Overridden by other sign on");
     return set_nick_name(cptr, sptr, nick, parc, parv);
   }
@@ -244,6 +243,7 @@ int m_nick(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
  *   parv[4] = username
  *   parv[5] = hostname
  *   parv[6] = umode (optional)
+ *   parv[parc-4] = %<lastmod>:<mask>   <- Only if matching GLINE
  *   parv[parc-3] = IP#                 <- Only Protocol >= 10
  *   parv[parc-2] = YXX, numeric nick   <- Only Protocol >= 10
  *   parv[parc-1] = info
@@ -269,17 +269,15 @@ int ms_nick(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   ircd_strncpy(nick, parv[1], NICKLEN);
   nick[NICKLEN] = '\0';
 
-  if (!IsBurstOrBurstAck(sptr)) {
-     if (IsServer(sptr)) {
-       lastnick = atoi(parv[3]);
-       if (lastnick > OLDEST_TS) 
-         sptr->serv->lag = TStime() - lastnick;
-     }
-     else {
-       lastnick = atoi(parv[2]); 
-       if (lastnick > OLDEST_TS)
-         sptr->user->server->serv->lag = TStime() - lastnick;
-     }
+  if (IsServer(sptr)) {
+    lastnick = atoi(parv[3]);
+    if (lastnick > OLDEST_TS && !IsBurstOrBurstAck(sptr)) 
+      sptr->serv->lag = TStime() - lastnick;
+  }
+  else {
+    lastnick = atoi(parv[2]); 
+    if (lastnick > OLDEST_TS && !IsBurstOrBurstAck(sptr))
+      sptr->user->server->serv->lag = TStime() - lastnick;
   }
   /*
    * If do_nick_name() returns a null name OR if the server sent a nick
@@ -316,7 +314,9 @@ int ms_nick(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
    * is present in the nicklist (due to the way the below for loop is
    * constructed). -avalon
    */
-  if (!(acptr = FindClient(nick))) {
+   
+  acptr = FindClient(nick);
+  if (!acptr) {
     /*
      * No collisions, all clear...
      */
@@ -382,7 +382,6 @@ int ms_nick(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
    */
   if (IsUnknown(acptr) && MyConnect(acptr)) {
     ++ServerStats->is_ref;
-    ip_registry_connect_fail(acptr->ip.s_addr);
     exit_client(cptr, acptr, &me, "Overridden by other sign on");
     return set_nick_name(cptr, sptr, nick, parc, parv);
   }
@@ -602,13 +601,20 @@ int m_nick(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
    * is present in the nicklist (due to the way the below for loop is
    * constructed). -avalon
    */
-  if ((acptr = FindServer(nick))) {
+   
+  acptr = FindServer(nick);
+  
+  if (acptr) { /* There is a nick collision with a server */
     if (MyConnect(sptr))
     {
+      /* Local user trying to use a nick thats a server
+       * Return an error message and ignore the command
+       */
       sendto_one(sptr, err_str(ERR_NICKNAMEINUSE), me.name, /* XXX DEAD */
           EmptyString(parv[0]) ? "*" : parv[0], nick);
       return 0;                        /* NICK message ignored */
     }
+    
     /*
      * We have a nickname trying to use the same name as
      * a server. Send out a nick collision KILL to remove
@@ -625,9 +631,12 @@ int m_nick(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
     sptr->flags |= FLAGS_KILLED;
     return exit_client(cptr, sptr, &me, "Nick/Server collision");
   }
+  
+  acptr = FindClient(nick);
 
-  if (!(acptr = FindClient(nick)))
-    return set_nick_name(cptr, sptr, nick, parc, parv);  /* No collisions, all clear... */
+  /* No collisions?  Set the nick name and we're done */
+  if (!acptr)
+    return set_nick_name(cptr, sptr, nick, parc, parv);
   /*
    * If acptr == sptr, then we have a client doing a nick
    * change between *equivalent* nicknames as far as server
@@ -665,7 +674,6 @@ int m_nick(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
   if (IsUnknown(acptr) && MyConnect(acptr))
   {
     ++ServerStats->is_ref;
-    ip_registry_connect_fail(acptr->ip.s_addr);
     exit_client(cptr, acptr, &me, "Overridden by other sign on");
     return set_nick_name(cptr, sptr, nick, parc, parv);
   }