]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/cmd_nick.cpp
Advanced to RC1
[user/henk/code/inspircd.git] / src / cmd_nick.cpp
index 83bb96859f39e15f054544ec2bf27830db321250..7779926e88e5686402ed4467803b452115a30fb7 100644 (file)
@@ -42,6 +42,7 @@ using namespace std;
 #include "xline.h"
 #include "inspstring.h"
 #include "dnsqueue.h"
+#include "dns.h"
 #include "helperfuncs.h"
 #include "hashcomp.h"
 #include "socketengine.h"
@@ -64,6 +65,8 @@ extern userrec* fd_ref_table[65536];
 
 void cmd_nick::Handle (char **parameters, int pcnt, userrec *user)
 {
+       char oldnick[NICKMAX];
+
        if (pcnt < 1) 
        {
                log(DEBUG,"not enough params for handle_nick");
@@ -89,9 +92,25 @@ void cmd_nick::Handle (char **parameters, int pcnt, userrec *user)
                log(DEBUG,"invalid old nick passed to handle_nick");
                return;
        }
-       if (!strcasecmp(user->nick,parameters[0]))
+       if (irc::string(user->nick) == irc::string(parameters[0]))
        {
-               log(DEBUG,"old nick is new nick, skipping");
+               /* If its exactly the same, even case, dont do anything. */
+               if (!strcmp(user->nick,parameters[0]))
+                       return;
+               /* Its a change of case. People insisted that they should be
+                * able to do silly things like this even though the RFC says
+                * the nick AAA is the same as the nick aaa.
+                */
+               log(DEBUG,"old nick is new nick, not updating hash (case change only)");
+               strlcpy(oldnick,user->nick,NICKMAX);
+               int MOD_RESULT = 0;
+               FOREACH_RESULT(OnUserPreNick(user,parameters[0]));
+               if (MOD_RESULT)
+                       return;
+               strlcpy(user->nick,parameters[0],NICKMAX);
+               if (user->registered == 7)
+                       WriteCommon(user,"NICK %s",parameters[0]);
+               FOREACH_MOD OnUserPostNick(user,oldnick);
                return;
        }
        else
@@ -133,8 +152,7 @@ void cmd_nick::Handle (char **parameters, int pcnt, userrec *user)
                WriteCommon(user,"NICK %s",parameters[0]);
                
        }
-       
-       char oldnick[NICKMAX];
+
        strlcpy(oldnick,user->nick,NICKMAX);
 
        /* change the nick of the user in the users_hash */