]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Fix bad throws and some other stuff in this module
[user/henk/code/inspircd.git] / src / users.cpp
index 6efbee651db6eeea062d169fc3efeeb0e5b41efb..d8ed553a79dde4247bcd08d60e720e8b9ff740da 100644 (file)
 #include "bancache.h"
 #include "commands/cmd_whowas.h"
 
+/* XXX: Used for speeding up WriteCommon operations */
+unsigned long uniq_id = 1;
+
 static unsigned long* already_sent = NULL;
 
 
 void InitializeAlreadySent(SocketEngine* SE)
 {
        already_sent = new unsigned long[SE->GetMaxFds()];
-       memset(already_sent, 0, sizeof(already_sent));
+       memset(already_sent, 0, SE->GetMaxFds() * sizeof(unsigned long));
 }
 
-/* XXX: Used for speeding up WriteCommon operations */
-unsigned long uniq_id = 1;
 
 std::string User::ProcessNoticeMasks(const char *sm)
 {
@@ -788,8 +789,11 @@ void User::UnOper()
                        }
                }
 
-               const char* parameters[] = { this->nick, moderemove.c_str() };
-               ServerInstance->Parser->CallHandler("MODE", parameters, 2, this);
+               std::vector<std::string> parameters;
+               parameters.push_back(this->nick);
+               parameters.push_back(moderemove);
+
+               ServerInstance->Parser->CallHandler("MODE", parameters, this);
 
                /* unset their oper type (what IS_OPER checks), and remove +o */
                *this->oper = 0;
@@ -859,6 +863,25 @@ void User::CheckClass()
        this->MaxChans = a->GetMaxChans();
 }
 
+void User::CheckLines()
+{
+       const char* check[] = { "G" , "K", NULL };
+
+       if (!this->exempt)
+       {
+               for (int n = 0; check[n]; ++n)
+               {
+                       XLine *r = ServerInstance->XLines->MatchesLine(check[n], this);
+
+                       if (r)
+                       {
+                               r->Apply(this);
+                               return;
+                       }
+               }
+       }
+}
+
 void User::FullConnect()
 {
        ServerInstance->stats->statsConnects++;
@@ -881,24 +904,7 @@ void User::FullConnect()
                return;
        }
 
-       if (!this->exempt)
-       {
-               GLine *r = (GLine *)ServerInstance->XLines->MatchesLine("G", this);
-
-               if (r)
-               {
-                       r->Apply(this);
-                       return;
-               }
-
-               KLine *n = (KLine *)ServerInstance->XLines->MatchesLine("K", this);
-
-               if (n)
-               {
-                       n->Apply(this);
-                       return;
-               }
-       }
+       CheckLines();
 
        this->WriteServ("NOTICE Auth :Welcome to \002%s\002!",ServerInstance->Config->Network);
        this->WriteNumeric(001, "%s :Welcome to the %s IRC Network %s!%s@%s",this->nick, ServerInstance->Config->Network, this->nick, this->ident, this->host);
@@ -918,9 +924,9 @@ void User::FullConnect()
 
        /* Trigger LUSERS output, give modules a chance too */
        int MOD_RESULT = 0;
-       FOREACH_RESULT(I_OnPreCommand, OnPreCommand("LUSERS", NULL, 0, this, true, "LUSERS"));
+       FOREACH_RESULT(I_OnPreCommand, OnPreCommand("LUSERS", std::vector<std::string>(), this, true, "LUSERS"));
        if (!MOD_RESULT)
-               ServerInstance->CallCommandHandler("LUSERS", NULL, 0, this);
+               ServerInstance->CallCommandHandler("LUSERS", std::vector<std::string>(), this);
 
        /*
         * We don't set REG_ALL until triggering OnUserConnect, so some module events don't spew out stuff
@@ -990,8 +996,10 @@ bool User::ForceNickChange(const char* newnick)
        Command* nickhandler = ServerInstance->Parser->GetHandler("NICK");
        if (nickhandler) // wtfbbq, when would this not be here
        {
+               std::vector<std::string> parameters;
                nickhandler->HandleInternal(1, dummy);
-               bool result = (ServerInstance->Parser->CallHandler("NICK", &newnick, 1, this) == CMD_SUCCESS);
+               parameters.push_back(newnick);
+               bool result = (ServerInstance->Parser->CallHandler("NICK", parameters, this) == CMD_SUCCESS);
                nickhandler->HandleInternal(0, dummy);
                return result;
        }
@@ -1096,7 +1104,7 @@ const char* User::GetIPString(bool translate4in6)
                        {
                                strlcpy(&temp[1], buf, sizeof(temp) - 1);
                                *temp = '0';
-                               if (translate4in6 && !strncmp(GetIPString(), "0::ffff:", 8))
+                               if (translate4in6 && !strncmp(temp, "0::ffff:", 8))
                                {
                                        this->cachedip = temp + 8;
                                        return temp + 8;