X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusermanager.cpp;h=9f5f8c9378e45f50f280e8b6452b9cec4ba2e91b;hb=a14cf3eed86b9ce638a0465e0c4dbb817710fb79;hp=6315f059d7f071cfcb1d0d43b92c63e0e280e51c;hpb=2553e4fff7a5a168ef796dcecb73c7365651c897;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 6315f059d..9f5f8c937 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see @@ -32,15 +32,16 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs ServerInstance->SNO->WriteToSnoMask('a', "WARNING *** Duplicate UUID allocated!"); return; } + UserIOHandler* eh = &New->eh; /* Give each of the modules an attempt to hook the user for I/O */ - FOREACH_MOD(I_OnHookIO, OnHookIO(New, via)); + FOREACH_MOD(I_OnHookIO, OnHookIO(eh, via)); - if (New->GetIOHook()) + if (eh->GetIOHook()) { try { - New->GetIOHook()->OnStreamSocketAccept(New, client, server); + eh->GetIOHook()->OnStreamSocketAccept(eh, client, server); } catch (CoreException& modexcept) { @@ -127,7 +128,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs } } - if (!ServerInstance->SE->AddFd(New, FD_WANT_FAST_READ | FD_WANT_EDGE_WRITE)) + if (!ServerInstance->SE->AddFd(eh, FD_WANT_FAST_READ | FD_WANT_EDGE_WRITE)) { ServerInstance->Logs->Log("USERS", DEBUG,"Internal error on new connection"); this->QuitUser(New, "Internal error handling connection"); @@ -192,12 +193,13 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char { LocalUser* lu = IS_LOCAL(user); FOREACH_MOD(I_OnUserDisconnect,OnUserDisconnect(lu)); - lu->DoWrite(); - if (lu->GetIOHook()) + UserIOHandler* eh = &lu->eh; + eh->DoWrite(); + if (eh->GetIOHook()) { try { - lu->GetIOHook()->OnStreamSocketClose(lu); + eh->GetIOHook()->OnStreamSocketClose(eh); } catch (CoreException& modexcept) { @@ -205,8 +207,8 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char } } - ServerInstance->SE->DelFd(lu); - lu->Close(); + ServerInstance->SE->DelFd(eh); + eh->Close(); } /* @@ -240,6 +242,8 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char this->clientlist->erase(iter); else ServerInstance->Logs->Log("USERS", DEBUG, "iter == clientlist->end, can't remove them from hash... problematic.."); + + ServerInstance->Users->uuidlist->erase(user->uuid); } @@ -390,10 +394,12 @@ void UserManager::ServerPrivmsgAll(const char* text, ...) /* return how many users have a given mode e.g. 'a' */ int UserManager::ModeCount(const char mode) { - ModeHandler* mh = ServerInstance->Modes->FindMode(mode, MODETYPE_USER); - - if (mh) - return mh->GetCount(); - else - return 0; + int c = 0; + for(user_hash::iterator i = clientlist->begin(); i != clientlist->end(); ++i) + { + User* u = i->second; + if (u->modes[mode-65]) + c++; + } + return c; }