]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
fixed std:: stuff
[user/henk/code/inspircd.git] / src / users.cpp
index 6b2aebfc7466380b12a2649897e857ff56d1c43d..edcc54be56b7f9c5a2f7ae84f68a2c8834cb7100 100644 (file)
@@ -884,25 +884,33 @@ bool User::ForceNickChange(const char* newnick)
 {
        try
        {
-               int MOD_RESULT = 0;
+               /*
+                * XXX this makes no sense..
+                * why do we do nothing for change on users not REG_ALL?
+                * why do we trigger events twice for everyone previously (and just them now)
+                * i think the first if () needs removing totally, or? -- w00t
+                */
+               if (this->registered != REG_ALL)
+               {
+                       int MOD_RESULT = 0;
 
-               this->InvalidateCache();
+                       this->InvalidateCache();
 
-               FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(this, newnick));
+                       FOREACH_RESULT(I_OnUserPreNick,OnUserPreNick(this, newnick));
 
-               if (MOD_RESULT)
-               {
-                       ServerInstance->stats->statsCollisions++;
-                       return false;
-               }
+                       if (MOD_RESULT)
+                       {
+                               ServerInstance->stats->statsCollisions++;
+                               return false;
+                       }
 
-               if (ServerInstance->XLines->MatchesLine("Q",newnick))
-               {
-                       ServerInstance->stats->statsCollisions++;
-                       return false;
+                       if (ServerInstance->XLines->MatchesLine("Q",newnick))
+                       {
+                               ServerInstance->stats->statsCollisions++;
+                               return false;
+                       }
                }
-
-               if (this->registered == REG_ALL)
+               else
                {
                        std::deque<classbase*> dummy;
                        Command* nickhandler = ServerInstance->Parser->GetHandler("NICK");
@@ -926,6 +934,8 @@ bool User::ForceNickChange(const char* newnick)
 
 void User::SetSockAddr(int protocol_family, const char* ip, int port)
 {
+       this->cachedip = "";
+
        switch (protocol_family)
        {
 #ifdef SUPPORT_IP6LINKS
@@ -1001,6 +1011,9 @@ const char* User::GetIPString()
        if (this->ip == NULL)
                return "";
 
+       if (!this->cachedip.empty())
+               return this->cachedip.c_str();
+
        switch (this->GetProtocolFamily())
        {
 #ifdef SUPPORT_IP6LINKS
@@ -1015,8 +1028,11 @@ const char* User::GetIPString()
                        {
                                strlcpy(&temp[1], buf, sizeof(temp) - 1);
                                *temp = '0';
+                               this->cachedip = temp;
                                return temp;
                        }
+                       
+                       this->cachedip = buf;
                        return buf;
                }
                break;
@@ -1025,12 +1041,15 @@ const char* User::GetIPString()
                {
                        sockaddr_in* sin = (sockaddr_in*)this->ip;
                        inet_ntop(sin->sin_family, &sin->sin_addr, buf, sizeof(buf));
+                       this->cachedip = buf;
                        return buf;
                }
                break;
                default:
                break;
        }
+       
+       // Unreachable, probably
        return "";
 }