]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/users.cpp
Split all commands into seperate files and redid command system to take classes,...
[user/henk/code/inspircd.git] / src / users.cpp
index f2a43238a0f60cfdeef8f413171fed92ece3916b..18ec1c318c4ee694ff262d1d0242b122948ab44c 100644 (file)
@@ -45,12 +45,11 @@ extern std::vector<InspSocket*> module_sockets;
 extern int MODCOUNT;
 extern InspSocket* socket_ref[65535];
 extern time_t TIME;
-extern SocketEngine* SE;
 extern userrec* fd_ref_table[65536];
-extern serverstats* stats;
 extern ServerConfig *Config;
 extern user_hash clientlist;
 extern whowas_hash whowas;
+extern Module* IOHookModule;
 std::vector<userrec*> local_users;
 
 std::vector<userrec*> all_opers;
@@ -280,8 +279,12 @@ void userrec::AddWriteBuf(std::string data)
                return;
        if (sendq.length() + data.length() > (unsigned)this->sendqmax)
        {
-               WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
+               /* Fix by brain - Set the error text BEFORE calling writeopers, because
+                * if we dont it'll recursively  call here over and over again trying
+                * to repeatedly add the text to the sendq!
+                */
                this->SetWriteError("SendQ exceeded");
+               WriteOpers("*** User %s SendQ of %d exceeds connect class maximum of %d",this->nick,sendq.length() + data.length(),this->sendqmax);
                return;
        }
         std::stringstream stream;
@@ -372,8 +375,11 @@ void kill_link(userrec *user,const char* r)
 
         if (user->fd > -1)
         {
-                FOREACH_MOD OnRawSocketClose(user->fd);
-                SE->DelFd(user->fd);
+               if (IOHookModule)
+               {
+                       IOHookModule->OnRawSocketClose(user->fd);
+               }
+                ServerInstance->SE->DelFd(user->fd);
                 user->CloseSocket();
         }
 
@@ -432,8 +438,11 @@ void kill_link_silent(userrec *user,const char* r)
 
         if (user->fd > -1)
         {
-                FOREACH_MOD OnRawSocketClose(user->fd);
-                SE->DelFd(user->fd);
+               if (IOHookModule)
+               {
+                       IOHookModule->OnRawSocketClose(user->fd);
+               }
+                ServerInstance->SE->DelFd(user->fd);
                 user->CloseSocket();
         }
 
@@ -634,12 +643,12 @@ void AddClient(int socket, char* host, int port, bool iscached, char* ip)
         }
         fd_ref_table[socket] = clientlist[tempnick];
        local_users.push_back(clientlist[tempnick]);
-        SE->AddFd(socket,true,X_ESTAB_CLIENT);
+        ServerInstance->SE->AddFd(socket,true,X_ESTAB_CLIENT);
 }
 
 void FullConnectUser(userrec* user)
 {
-        stats->statsConnects++;
+        ServerInstance->stats->statsConnects++;
         user->idle_lastmsg = TIME;
         log(DEBUG,"ConnectUser: %s",user->nick);
 
@@ -768,13 +777,13 @@ void force_nickchange(userrec* user,const char* newnick)
 
         FOREACH_RESULT(OnUserPreNick(user,newnick));
         if (MOD_RESULT) {
-                stats->statsCollisions++;
+                ServerInstance->stats->statsCollisions++;
                 kill_link(user,"Nickname collision");
                 return;
         }
         if (matches_qline(newnick))
         {
-                stats->statsCollisions++;
+               ServerInstance->stats->statsCollisions++;
                 kill_link(user,"Nickname collision");
                 return;
         }
@@ -789,7 +798,8 @@ void force_nickchange(userrec* user,const char* newnick)
                 {
                         char* pars[1];
                         pars[0] = nick;
-                        handle_nick(pars,1,user);
+                       std::string cmd = "NICK";
+                        ServerInstance->Parser->CallHandler(cmd,pars,1,user);
                 }
         }
 }