diff options
33 files changed, 281 insertions, 328 deletions
diff --git a/include/command_parse.h b/include/command_parse.h index 93a36885c..c2fa78177 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -16,7 +16,6 @@ #include <string> #include "ctables.h" -#include "typedefs.h" /** Required forward declaration */ diff --git a/include/inspircd.h b/include/inspircd.h index fb6b313a2..d78e25b48 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -25,15 +25,20 @@ #undef ERROR #endif +// Required system headers. #include <time.h> -#include <string> -#include <sstream> -#include <list> +#include <stdarg.h> + + +//#include <string> +//#include <sstream> #include "inspircd_config.h" #include "uid.h" #include "users.h" -#include "usermanager.h" #include "channels.h" +#include "hashcomp.h" +#include "typedefs.h" +#include "usermanager.h" #include "socket.h" #include "mode.h" #include "socketengine.h" @@ -358,11 +363,6 @@ class CoreExport InspIRCd : public classbase */ void BuildISupport(); - /** Number of unregistered users online right now. - * (Unregistered means before USER/NICK/dns) - */ - int unregistered_count; - /** List of server names we've seen. */ servernamelist servernames; @@ -410,27 +410,6 @@ class CoreExport InspIRCd : public classbase */ SnomaskManager* SNO; - /** Client list, a hash_map containing all clients, local and remote - */ - user_hash* clientlist; - - /** Client list stored by UUID. Contains all clients, and is updated - * automatically by the constructor and destructor of User. - */ - user_hash* uuidlist; - - /** Channel list, a hash_map containing all channels - */ - chan_hash* chanlist; - - /** Local client list, a vector containing only local clients - */ - std::vector<User*> local_users; - - /** Oper list, a vector containing all local and remote opered users - */ - std::list<User*> all_opers; - /** DNS class, provides resolver facilities to the core and modules */ DNS* Res; @@ -447,6 +426,10 @@ class CoreExport InspIRCd : public classbase */ UserManager *Users; + /** Channel list, a hash_map containing all channels XXX move to channel manager class + */ + chan_hash* chanlist; + /** Set to the current signal recieved */ int s_signal; @@ -466,10 +449,6 @@ class CoreExport InspIRCd : public classbase * @return The old time delta */ int SetTimeDelta(int delta); - - /** Number of users with a certain mode set on them - */ - int ModeCount(const char mode); /** Get the time offset in seconds * @return The current time delta (in seconds) @@ -580,28 +559,6 @@ class CoreExport InspIRCd : public classbase */ void CloseLog(); - /** Send a server notice to all local users - * @param text The text format string to send - * @param ... The format arguments - */ - void ServerNoticeAll(char* text, ...); - - /** Send a server message (PRIVMSG) to all local users - * @param text The text format string to send - * @param ... The format arguments - */ - void ServerPrivmsgAll(char* text, ...); - - /** Send text to all users with a specific set of modes - * @param modes The modes to check against, without a +, e.g. 'og' - * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the - * mode characters in the first parameter causes receipt of the message, and - * if you specify WM_OR, all the modes must be present. - * @param text The text format string to send - * @param ... The format arguments - */ - void WriteMode(const char* modes, int flags, const char* text, ...); - /** Return true if a channel name is valid * @param chname A channel name to verify * @return True if the name is valid diff --git a/include/typedefs.h b/include/typedefs.h index 44d24b1f6..2a98da4ae 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -14,18 +14,6 @@ #ifndef __TYPEDEF_H__ #define __TYPEDEF_H__ - -#include <string> -#include "inspircd_config.h" -#include "hash_map.h" -#include "users.h" -#include "channels.h" -#include "hashcomp.h" -#include "inspstring.h" -#include "ctables.h" -#include "modules.h" -#include "globals.h" - #ifndef WIN32 /** User hash (POSIX systems with GCC) */ diff --git a/include/usermanager.h b/include/usermanager.h index f994e9739..33b97129a 100644 --- a/include/usermanager.h +++ b/include/usermanager.h @@ -14,6 +14,8 @@ #ifndef __USERMANAGER_H #define __USERMANAGER_H +#include <list> + /** A list of ip addresses cross referenced against clone counts */ typedef std::map<irc::string, unsigned int> clonemap; @@ -31,6 +33,29 @@ class CoreExport UserManager : public classbase ServerInstance = Instance; } + + /** Client list, a hash_map containing all clients, local and remote + */ + user_hash* clientlist; + + /** Client list stored by UUID. Contains all clients, and is updated + * automatically by the constructor and destructor of User. + */ + user_hash* uuidlist; + + /** Local client list, a vector containing only local clients + */ + std::vector<User*> local_users; + + /** Oper list, a vector containing all local and remote opered users + */ + std::list<User*> all_opers; + + /** Number of unregistered users online right now. + * (Unregistered means before USER/NICK/dns) + */ + int unregistered_count; + /** Map of global ip addresses for clone counting * XXX - this should be private, but m_clones depends on it currently. */ @@ -101,6 +126,35 @@ class CoreExport UserManager : public classbase * @return The number of local users */ unsigned int LocalUserCount(); + + + + + /** Number of users with a certain mode set on them + */ + int ModeCount(const char mode); + + /** Send a server notice to all local users + * @param text The text format string to send + * @param ... The format arguments + */ + void ServerNoticeAll(char* text, ...); + + /** Send a server message (PRIVMSG) to all local users + * @param text The text format string to send + * @param ... The format arguments + */ + void ServerPrivmsgAll(char* text, ...); + + /** Send text to all users with a specific set of modes + * @param modes The modes to check against, without a +, e.g. 'og' + * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the + * mode characters in the first parameter causes receipt of the message, and + * if you specify WM_OR, all the modes must be present. + * @param text The text format string to send + * @param ... The format arguments + */ + void WriteMode(const char* modes, int flags, const char* text, ...); }; #endif diff --git a/src/commands.cpp b/src/commands.cpp index 495fb821b..017264621 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -31,7 +31,7 @@ bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user) if (Config->ConfValueBool(Config->config_data, "insane","hostmasks", 0)) return false; - for (user_hash::iterator u = clientlist->begin(); u != clientlist->end(); u++) + for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++) { if ((match(u->second->MakeHost(),mask.c_str(),true)) || (match(u->second->MakeHostIP(),mask.c_str(),true))) { @@ -42,7 +42,7 @@ bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user) if (!matches) return false; - float percent = ((float)matches / (float)clientlist->size()) * 100; + float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100; if (percent > (float)atof(itrigger)) { SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick,mask.c_str(),percent); @@ -62,7 +62,7 @@ bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user) if (Config->ConfValueBool(Config->config_data, "insane","ipmasks",0)) return false; - for (user_hash::iterator u = clientlist->begin(); u != clientlist->end(); u++) + for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++) { if (match(u->second->GetIPString(),ip.c_str(),true)) matches++; @@ -71,7 +71,7 @@ bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user) if (!matches) return false; - float percent = ((float)matches / (float)clientlist->size()) * 100; + float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100; if (percent > (float)atof(itrigger)) { SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent); @@ -91,7 +91,7 @@ bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user) if (Config->ConfValueBool(Config->config_data, "insane","nickmasks",0)) return false; - for (user_hash::iterator u = clientlist->begin(); u != clientlist->end(); u++) + for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++) { if (match(u->second->nick,nick.c_str())) matches++; @@ -100,7 +100,7 @@ bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user) if (!matches) return false; - float percent = ((float)matches / (float)clientlist->size()) * 100; + float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100; if (percent > (float)atof(itrigger)) { SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent); diff --git a/src/commands/cmd_lusers.cpp b/src/commands/cmd_lusers.cpp index f91266a15..317229ceb 100644 --- a/src/commands/cmd_lusers.cpp +++ b/src/commands/cmd_lusers.cpp @@ -25,7 +25,7 @@ CmdResult CommandLusers::Handle (const char**, int, User *user) { // this lusers command shows one server at all times because // a protocol module must override it to show those stats. - user->WriteServ("251 %s :There are %d users and %d invisible on 1 server",user->nick,ServerInstance->Users->UserCount()-ServerInstance->ModeCount('i'),ServerInstance->ModeCount('i')); + user->WriteServ("251 %s :There are %d users and %d invisible on 1 server",user->nick,ServerInstance->Users->UserCount()-ServerInstance->Users->ModeCount('i'),ServerInstance->Users->ModeCount('i')); if (ServerInstance->Users->OperCount()) user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->Users->OperCount()); if (ServerInstance->Users->UnregisteredUserCount()) diff --git a/src/commands/cmd_stats.cpp b/src/commands/cmd_stats.cpp index 3d81dd84f..de9237c61 100644 --- a/src/commands/cmd_stats.cpp +++ b/src/commands/cmd_stats.cpp @@ -126,7 +126,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str case 'P': { int idx = 0; - for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++) + for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++) { if (IS_OPER(i->second) && !ServerInstance->ULine(i->second->server)) { @@ -171,7 +171,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str case 'z': { results.push_back(sn+" 240 "+user->nick+" :InspIRCd(CLASS) "+ConvToStr(sizeof(InspIRCd))+" bytes"); - results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->clientlist->size())+" ("+ConvToStr(ServerInstance->clientlist->size()*sizeof(User))+" bytes)"); + results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(ServerInstance->Users->clientlist->size())+" ("+ConvToStr(ServerInstance->Users->clientlist->size()*sizeof(User))+" bytes)"); results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(ServerInstance->chanlist->size())+" ("+ConvToStr(ServerInstance->chanlist->size()*sizeof(Channel))+" bytes)"); results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(Command))+" bytes)"); @@ -255,7 +255,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str /* stats l (show user I/O stats) */ case 'l': results.push_back(sn+" 211 "+user->nick+" :nick[ident@host] sendq cmds_out bytes_out cmds_in bytes_in time_open"); - for (std::vector<User*>::iterator n = ServerInstance->local_users.begin(); n != ServerInstance->local_users.end(); n++) + for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++) { User* i = *n; if (ServerInstance->IsNick(i->nick)) @@ -268,7 +268,7 @@ DllExport void DoStats(InspIRCd* ServerInstance, char statschar, User* user, str /* stats L (show user I/O stats with IP addresses) */ case 'L': results.push_back(sn+" 211 "+user->nick+" :nick[ident@ip] sendq cmds_out bytes_out cmds_in bytes_in time_open"); - for (std::vector<User*>::iterator n = ServerInstance->local_users.begin(); n != ServerInstance->local_users.end(); n++) + for (std::vector<User*>::iterator n = ServerInstance->Users->local_users.begin(); n != ServerInstance->Users->local_users.end(); n++) { User* i = *n; if (ServerInstance->IsNick(i->nick)) diff --git a/src/commands/cmd_trace.cpp b/src/commands/cmd_trace.cpp deleted file mode 100644 index b81a732b8..000000000 --- a/src/commands/cmd_trace.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -#include "inspircd.h" -#include "commands/cmd_trace.h" - -extern "C" DllExport Command* init_command(InspIRCd* Instance) -{ - return new CommandTrace(Instance); -} - -/** XXX: This is crap. someone fix this when you have time, to be more useful. - */ -CmdResult CommandTrace::Handle (const char**, int, User *user) -{ - for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++) - { - if (i->second->registered == REG_ALL) - { - if (IS_OPER(i->second)) - { - user->WriteServ("205 %s :Oper 0 %s",user->nick,i->second->nick); - } - else - { - user->WriteServ("204 %s :User 0 %s",user->nick,i->second->nick); - } - } - else - { - user->WriteServ("203 %s :???? 0 [%s]",user->nick,i->second->host); - } - } - return CMD_SUCCESS; -} diff --git a/src/commands/cmd_who.cpp b/src/commands/cmd_who.cpp index 1a323edd4..091ba728b 100644 --- a/src/commands/cmd_who.cpp +++ b/src/commands/cmd_who.cpp @@ -298,7 +298,7 @@ CmdResult CommandWho::Handle (const char** parameters, int pcnt, User *user) if (opt_viewopersonly) { /* Showing only opers */ - for (std::list<User*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++) + for (std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin(); i != ServerInstance->Users->all_opers.end(); i++) { User* oper = *i; @@ -316,7 +316,7 @@ CmdResult CommandWho::Handle (const char** parameters, int pcnt, User *user) } else { - for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++) + for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++) { if (whomatch(i->second, matchtext)) { diff --git a/src/configreader.cpp b/src/configreader.cpp index a9c41be7b..945780a54 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -2298,7 +2298,7 @@ bool DoELine(ServerConfig* conf, const char* tag, char** entries, ValueList &val // this should probably be moved to configreader, but atm it relies on CheckELines above. bool DoneELine(ServerConfig* conf, const char* tag) { - for (std::vector<User*>::const_iterator u2 = conf->GetInstance()->local_users.begin(); u2 != conf->GetInstance()->local_users.end(); u2++) + for (std::vector<User*>::const_iterator u2 = conf->GetInstance()->Users->local_users.begin(); u2 != conf->GetInstance()->Users->local_users.end(); u2++) { User* u = (User*)(*u2); u->exempt = false; diff --git a/src/cull_list.cpp b/src/cull_list.cpp index fee326ea3..b3fd1c9e3 100644 --- a/src/cull_list.cpp +++ b/src/cull_list.cpp @@ -49,7 +49,7 @@ int CullList::Apply() std::vector<User *>::iterator a = list.begin(); User *u = (*a); - user_hash::iterator iter = ServerInstance->clientlist->find(u->nick); + user_hash::iterator iter = ServerInstance->Users->clientlist->find(u->nick); const char* preset_reason = u->GetOperQuit(); std::string reason = u->operquitmsg; std::string oper_reason = *preset_reason ? preset_reason : u->operquitmsg; @@ -60,8 +60,8 @@ int CullList::Apply() oper_reason.resize(MAXQUIT - 1); if (u->registered != REG_ALL) - if (ServerInstance->unregistered_count) - ServerInstance->unregistered_count--; + if (ServerInstance->Users->unregistered_count) + ServerInstance->Users->unregistered_count--; if (IS_LOCAL(u)) { @@ -119,15 +119,15 @@ int CullList::Apply() u->AddToWhoWas(); } - if (iter != ServerInstance->clientlist->end()) + if (iter != ServerInstance->Users->clientlist->end()) { if (IS_LOCAL(u)) { - std::vector<User*>::iterator x = find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),u); - if (x != ServerInstance->local_users.end()) - ServerInstance->local_users.erase(x); + std::vector<User*>::iterator x = find(ServerInstance->Users->local_users.begin(),ServerInstance->Users->local_users.end(),u); + if (x != ServerInstance->Users->local_users.end()) + ServerInstance->Users->local_users.erase(x); } - ServerInstance->clientlist->erase(iter); + ServerInstance->Users->clientlist->erase(iter); } delete u; diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 2d8a6f060..3f60cac80 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -14,7 +14,6 @@ /* $Core: libIRCDhelper */ #include "inspircd.h" -#include <stdarg.h> #include "wildcard.h" #include "xline.h" #include "exitcodes.h" @@ -95,119 +94,15 @@ std::string InspIRCd::GetServerDescription(const char* servername) } } -void InspIRCd::ServerNoticeAll(char* text, ...) -{ - if (!text) - return; - - char textbuffer[MAXBUF]; - char formatbuffer[MAXBUF]; - va_list argsPtr; - va_start (argsPtr, text); - vsnprintf(textbuffer, MAXBUF, text, argsPtr); - va_end(argsPtr); - - snprintf(formatbuffer,MAXBUF,"NOTICE $%s :%s",Config->ServerName,textbuffer); - - for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++) - { - User* t = *i; - t->WriteServ(std::string(formatbuffer)); - } -} - -void InspIRCd::ServerPrivmsgAll(char* text, ...) -{ - if (!text) - return; - - char textbuffer[MAXBUF]; - char formatbuffer[MAXBUF]; - va_list argsPtr; - va_start (argsPtr, text); - vsnprintf(textbuffer, MAXBUF, text, argsPtr); - va_end(argsPtr); - - snprintf(formatbuffer,MAXBUF,"PRIVMSG $%s :%s",Config->ServerName,textbuffer); - - for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++) - { - User* t = *i; - t->WriteServ(std::string(formatbuffer)); - } -} - -void InspIRCd::WriteMode(const char* modes, int flags, const char* text, ...) -{ - char textbuffer[MAXBUF]; - int modelen; - va_list argsPtr; - - if (!text || !modes || !flags) - { - this->Log(DEFAULT,"*** BUG *** WriteMode was given an invalid parameter"); - return; - } - - va_start(argsPtr, text); - vsnprintf(textbuffer, MAXBUF, text, argsPtr); - va_end(argsPtr); - modelen = strlen(modes); - - if (flags == WM_AND) - { - for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++) - { - User* t = *i; - bool send_to_user = true; - - for (int n = 0; n < modelen; n++) - { - if (!t->IsModeSet(modes[n])) - { - send_to_user = false; - break; - } - } - if (send_to_user) - { - t->WriteServ("NOTICE %s :%s", t->nick, textbuffer); - } - } - } - else if (flags == WM_OR) - { - for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++) - { - User* t = *i; - bool send_to_user = false; - - for (int n = 0; n < modelen; n++) - { - if (t->IsModeSet(modes[n])) - { - send_to_user = true; - break; - } - } - - if (send_to_user) - { - t->WriteServ("NOTICE %s :%s", t->nick, textbuffer); - } - } - } -} - /* Find a user record by nickname and return a pointer to it */ User* InspIRCd::FindNick(const std::string &nick) { if (!nick.empty() && isdigit(*nick.begin())) return FindUUID(nick); - user_hash::iterator iter = clientlist->find(nick); + user_hash::iterator iter = this->Users->clientlist->find(nick); - if (iter == clientlist->end()) + if (iter == this->Users->clientlist->end()) /* Couldn't find it */ return NULL; @@ -219,9 +114,9 @@ User* InspIRCd::FindNick(const char* nick) if (isdigit(*nick)) return FindUUID(nick); - user_hash::iterator iter = clientlist->find(nick); + user_hash::iterator iter = this->Users->clientlist->find(nick); - if (iter == clientlist->end()) + if (iter == this->Users->clientlist->end()) return NULL; return iter->second; @@ -229,9 +124,9 @@ User* InspIRCd::FindNick(const char* nick) User* InspIRCd::FindNickOnly(const std::string &nick) { - user_hash::iterator iter = clientlist->find(nick); + user_hash::iterator iter = this->Users->clientlist->find(nick); - if (iter == clientlist->end()) + if (iter == this->Users->clientlist->end()) return NULL; return iter->second; @@ -239,9 +134,9 @@ User* InspIRCd::FindNickOnly(const std::string &nick) User* InspIRCd::FindNickOnly(const char* nick) { - user_hash::iterator iter = clientlist->find(nick); + user_hash::iterator iter = this->Users->clientlist->find(nick); - if (iter == clientlist->end()) + if (iter == this->Users->clientlist->end()) return NULL; return iter->second; @@ -254,9 +149,9 @@ User *InspIRCd::FindUUID(const std::string &uid) User *InspIRCd::FindUUID(const char *uid) { - user_hash::iterator finduuid = uuidlist->find(uid); + user_hash::iterator finduuid = this->Users->uuidlist->find(uid); - if (finduuid == uuidlist->end()) + if (finduuid == this->Users->uuidlist->end()) return NULL; return finduuid->second; @@ -288,7 +183,7 @@ Channel* InspIRCd::FindChan(const std::string &chan) /* Send an error notice to all users, registered or not */ void InspIRCd::SendError(const std::string &s) { - for (std::vector<User*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++) + for (std::vector<User*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++) { if ((*i)->registered == REG_ALL) { @@ -307,17 +202,6 @@ void InspIRCd::SendError(const std::string &s) } } -/* return how many users have a given mode e.g. 'a' */ -int InspIRCd::ModeCount(const char mode) -{ - ModeHandler* mh = this->Modes->FindMode(mode, MODETYPE_USER); - - if (mh) - return mh->GetCount(); - else - return 0; -} - /* return channel count */ long InspIRCd::ChannelCount() { diff --git a/src/inspircd.cpp b/src/inspircd.cpp index b77b5cc0a..7eb52ebc8 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -82,7 +82,7 @@ void InspIRCd::Cleanup() } /* Close all client sockets, or the new process inherits them */ - for (std::vector<User*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++) + for (std::vector<User*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++) { (*i)->SetWriteError("Server shutdown"); (*i)->CloseSocket(); @@ -156,21 +156,21 @@ void InspIRCd::ResetMaxBans() */ void InspIRCd::RehashUsersAndChans() { - user_hash* old_users = this->clientlist; - user_hash* old_uuid = this->uuidlist; + user_hash* old_users = this->Users->clientlist; + user_hash* old_uuid = this->Users->uuidlist; chan_hash* old_chans = this->chanlist; - this->clientlist = new user_hash(); - this->uuidlist = new user_hash(); + this->Users->clientlist = new user_hash(); + this->Users->uuidlist = new user_hash(); this->chanlist = new chan_hash(); for (user_hash::const_iterator n = old_users->begin(); n != old_users->end(); n++) - this->clientlist->insert(*n); + this->Users->clientlist->insert(*n); delete old_users; for (user_hash::const_iterator n = old_uuid->begin(); n != old_uuid->end(); n++) - this->uuidlist->insert(*n); + this->Users->uuidlist->insert(*n); delete old_uuid; @@ -309,10 +309,10 @@ InspIRCd::InspIRCd(int argc, char** argv) this->s_signal = 0; - this->unregistered_count = 0; + this->Users->unregistered_count = 0; - this->clientlist = new user_hash(); - this->uuidlist = new user_hash(); + this->Users->clientlist = new user_hash(); + this->Users->uuidlist = new user_hash(); this->chanlist = new chan_hash(); this->Res = NULL; diff --git a/src/mode.cpp b/src/mode.cpp index d32bfb212..758c02c20 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -754,7 +754,7 @@ bool ModeParser::DelMode(ModeHandler* mh) switch (mh->GetModeType()) { case MODETYPE_USER: - for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++) + for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++) { mh->RemoveMode(i->second); } diff --git a/src/modes/umode_o.cpp b/src/modes/umode_o.cpp index 622af0206..5d8b68ae2 100644 --- a/src/modes/umode_o.cpp +++ b/src/modes/umode_o.cpp @@ -45,5 +45,5 @@ ModeAction ModeUserOperator::OnModeChange(User* source, User* dest, Channel*, st unsigned int ModeUserOperator::GetCount() { - return ServerInstance->all_opers.size(); + return count; } diff --git a/src/modules.cpp b/src/modules.cpp index cd869585f..25a53fefe 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -512,7 +512,7 @@ bool ModuleManager::Unload(const char* filename) { modfind->second.second->OnCleanup(TYPE_CHANNEL,c->second); } - for (user_hash::iterator u = Instance->clientlist->begin(); u != Instance->clientlist->end(); u++) + for (user_hash::iterator u = Instance->Users->clientlist->begin(); u != Instance->Users->clientlist->end(); u++) { modfind->second.second->OnCleanup(TYPE_USER,u->second); } diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index d3df1948b..7fea35d34 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -48,7 +48,7 @@ void RemoveData(User* who) void RemoveFromAllAccepts(InspIRCd* ServerInstance, User* who) { - for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); ++i) + for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); ++i) { callerid_data* dat = GetData(i->second, false); if (!dat) continue; diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index cc8c7846b..af8aaa3fc 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -129,7 +129,7 @@ class CommandCheck : public Command long x = 0; /* hostname or other */ - for (user_hash::const_iterator a = ServerInstance->clientlist->begin(); a != ServerInstance->clientlist->end(); a++) + for (user_hash::const_iterator a = ServerInstance->Users->clientlist->begin(); a != ServerInstance->Users->clientlist->end(); a++) { if (match(a->second->host, parameters[0]) || match(a->second->dhost, parameters[0])) { diff --git a/src/modules/m_close.cpp b/src/modules/m_close.cpp index 5d703c0d0..9b868e61e 100644 --- a/src/modules/m_close.cpp +++ b/src/modules/m_close.cpp @@ -28,7 +28,7 @@ class CommandClose : public Command { std::map<std::string,int> closed; - for (std::vector<User*>::iterator u = ServerInstance->local_users.begin(); u != ServerInstance->local_users.end(); u++) + for (std::vector<User*>::iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); u++) { if ((*u)->registered != REG_ALL) { diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index de72dc339..63ddedcb8 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -73,7 +73,7 @@ class ModuleHttpStats : public Module so->clear(); for (StatsIter a = sh->begin(); a != sh->end(); a++) InsertOrder(a->first, a->second); - for (user_hash::iterator u = ServerInstance->clientlist->begin(); u != ServerInstance->clientlist->end(); u++) + for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++) { StatsHash::iterator n = Servers->find(u->second->server); if (n != Servers->end()) @@ -103,9 +103,9 @@ class ModuleHttpStats : public Module data << "<server><name>" << ServerInstance->Config->ServerName << "</name><gecos>" << ServerInstance->Config->ServerDesc << "</gecos></server>"; data << "<general>"; - data << "<usercount>" << ServerInstance->clientlist->size() << "</usercount>"; + data << "<usercount>" << ServerInstance->Users->clientlist->size() << "</usercount>"; data << "<channelcount>" << ServerInstance->chanlist->size() << "</channelcount>"; - data << "<opercount>" << ServerInstance->all_opers.size() << "</opercount>"; + data << "<opercount>" << ServerInstance->Users->all_opers.size() << "</opercount>"; data << "<socketcount>" << (ServerInstance->SE->GetMaxFds() - ServerInstance->SE->GetRemainingFds()) << "</socketcount><socketmax>" << ServerInstance->SE->GetMaxFds() << "</socketmax><socketengine>" << ServerInstance->SE->GetName() << "</socketengine>"; diff --git a/src/modules/m_invisible.cpp b/src/modules/m_invisible.cpp index 30935c1dd..3f816b3c0 100644 --- a/src/modules/m_invisible.cpp +++ b/src/modules/m_invisible.cpp @@ -47,7 +47,7 @@ class InvisibleMode : public ModeHandler ~InvisibleMode() { - for (user_hash::iterator i = ServerInstance->clientlist->begin(); i != ServerInstance->clientlist->end(); i++) + for (user_hash::iterator i = ServerInstance->Users->clientlist->begin(); i != ServerInstance->Users->clientlist->end(); i++) if (i->second->Visibility == qo) i->second->Visibility = NULL; delete qo; @@ -166,7 +166,7 @@ class ModuleInvisible : public Module throw ModuleException("Could not add new mode watcher on usermode +o!"); /* Yeah i know people can take this out. I'm not about to obfuscate code just to be a pain in the ass. */ - ServerInstance->ServerNoticeAll("*** m_invisible.so has just been loaded on this network. For more information, please visit http://inspircd.org/wiki/Modules/invisible"); + ServerInstance->Users->ServerNoticeAll("*** m_invisible.so has just been loaded on this network. For more information, please visit http://inspircd.org/wiki/Modules/invisible"); Implementation eventlist[] = { I_OnUserPreMessage, I_OnUserPreNotice, I_OnUserJoin, I_OnUserPart, I_OnUserQuit, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, 6); } diff --git a/src/modules/m_jumpserver.cpp b/src/modules/m_jumpserver.cpp index 86df62332..255d3eac9 100644 --- a/src/modules/m_jumpserver.cpp +++ b/src/modules/m_jumpserver.cpp @@ -84,7 +84,7 @@ class CommandJumpserver : public Command if (redirect_all_immediately) { /* Redirect everyone but the oper sending the command */ - for (std::vector<User*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++) + for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++) { User* t = *i; if (!IS_OPER(t)) diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 270d7ef82..496840489 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -64,7 +64,7 @@ ModuleSpanningTree::ModuleSpanningTree(InspIRCd* Me) }; ServerInstance->Modules->Attach(eventlist, this, 29); - for (std::vector<User*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++) + for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++) { this->OnPostConnect((*i)); } @@ -150,8 +150,8 @@ void ModuleSpanningTree::HandleLusers(const char** parameters, int pcnt, User* u } } user->WriteServ("251 %s :There are %d users and %d invisible on %d servers",user->nick, - n_users-ServerInstance->ModeCount('i'), - ServerInstance->ModeCount('i'), + n_users-ServerInstance->Users->ModeCount('i'), + ServerInstance->Users->ModeCount('i'), ulined_count ? this->CountServs() - ulined_count : this->CountServs()); if (ServerInstance->Users->OperCount()) diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp index d50215b76..9b117272a 100644 --- a/src/modules/m_spanningtree/override_map.cpp +++ b/src/modules/m_spanningtree/override_map.cpp @@ -66,14 +66,14 @@ void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, cha /* Neat and tidy default values, as we're dealing with a matrix not a simple string */ memset(text, 0, 128); - if (ServerInstance->clientlist->size() == 0) + if (ServerInstance->Users->clientlist->size() == 0) { // If there are no users, WHO THE HELL DID THE /MAP?!?!?! percent = 0; } else { - percent = ((float)Current->GetUserCount() / (float)ServerInstance->clientlist->size()) * 100; + percent = ((float)Current->GetUserCount() / (float)ServerInstance->Users->clientlist->size()) * 100; } const std::string operdata = IS_OPER(user) ? MapOperInfo(Current) : ""; diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 8b0f95b71..50b5d7949 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -150,7 +150,7 @@ int TreeServer::QuitUsers(const std::string &reason) { const char* reason_s = reason.c_str(); std::vector<User*> time_to_die; - for (user_hash::iterator n = ServerInstance->clientlist->begin(); n != ServerInstance->clientlist->end(); n++) + for (user_hash::iterator n = ServerInstance->Users->clientlist->begin(); n != ServerInstance->Users->clientlist->end(); n++) { if (!strcmp(n->second->server, this->ServerName.c_str())) { diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 407717bde..81a339f2e 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -1046,9 +1046,9 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa /* check for collision */ - user_hash::iterator iter = this->Instance->clientlist->find(tempnick); + user_hash::iterator iter = this->Instance->Users->clientlist->find(tempnick); - if (iter != this->Instance->clientlist->end()) + if (iter != this->Instance->Users->clientlist->end()) { /* * Nick collision. @@ -1076,7 +1076,7 @@ bool TreeSocket::ParseUID(const std::string &source, std::deque<std::string> &pa SendError("Protocol violation - Duplicate UUID '" + params[0] + "' on introduction of new user"); return false; } - (*(this->Instance->clientlist))[tempnick] = _new; + (*(this->Instance->Users->clientlist))[tempnick] = _new; _new->SetFd(FD_MAGIC_NUMBER); strlcpy(_new->nick, tempnick, NICKMAX - 1); strlcpy(_new->host, params[3].c_str(),64); @@ -1267,7 +1267,7 @@ void TreeSocket::SendUsers(TreeServer* Current) char data[MAXBUF]; std::deque<std::string> list; std::string dataline; - for (user_hash::iterator u = this->Instance->clientlist->begin(); u != this->Instance->clientlist->end(); u++) + for (user_hash::iterator u = this->Instance->Users->clientlist->begin(); u != this->Instance->Users->clientlist->end(); u++) { if (u->second->registered == REG_ALL) { diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 7c2df1e2a..28f66f0d2 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -242,7 +242,7 @@ bool TreeSocket::OperType(const std::string &prefix, std::deque<std::string> &pa if (u) { if (!u->IsModeSet('o')) - this->Instance->all_opers.push_back(u); + this->Instance->Users->all_opers.push_back(u); u->modes[UM_OPERATOR] = 1; strlcpy(u->oper,opertype.c_str(),NICKMAX-1); Utils->DoOneToAllButSender(u->nick,"OPERTYPE",params,u->server); @@ -1073,7 +1073,7 @@ bool TreeSocket::ProcessLine(std::string &line) if (prefix.empty()) { - this->SendError("BUG (??) Empty prefix recieved."); + this->SendError("BUG (?) Empty prefix recieved."); return false; } } @@ -1480,7 +1480,7 @@ bool TreeSocket::ProcessLine(std::string &line) sourceserv = this->InboundServerName; if (params.size() >= 2) { - Instance->WriteMode(params[0].c_str(), WM_AND, "*** From %s: %s", prefix.c_str(), params[1].c_str()); + Instance->Users->WriteMode(params[0].c_str(), WM_AND, "*** From %s: %s", prefix.c_str(), params[1].c_str()); } return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params); } diff --git a/src/modules/m_tline.cpp b/src/modules/m_tline.cpp index 06941c168..28a3d2f69 100644 --- a/src/modules/m_tline.cpp +++ b/src/modules/m_tline.cpp @@ -34,7 +34,7 @@ class CommandTline : public Command float n_match_host = 0; float n_match_ip = 0; - for (user_hash::const_iterator u = ServerInstance->clientlist->begin(); u != ServerInstance->clientlist->end(); u++) + for (user_hash::const_iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++) { n_counted++; if (match(u->second->GetFullRealHost(),parameters[0])) diff --git a/src/snomasks.cpp b/src/snomasks.cpp index 3154d3ec0..32c77e99f 100644 --- a/src/snomasks.cpp +++ b/src/snomasks.cpp @@ -125,7 +125,7 @@ void Snomask::Flush() ServerInstance->Log(DEBUG, "Flusing snomask %s", this->Description.c_str()); /* Only opers can receive snotices, so we iterate the oper list */ - for (std::list<User*>::iterator i = ServerInstance->all_opers.begin(); i != ServerInstance->all_opers.end(); i++) + for (std::list<User*>::iterator i = ServerInstance->Users->all_opers.begin(); i != ServerInstance->Users->all_opers.end(); i++) { User* a = *i; if (IS_LOCAL(a) && a->IsModeSet('s') && a->IsModeSet('n') && a->IsNoticeMaskSet(MySnomask) && !a->quitting) diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 1917c780e..5ee84590b 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -39,7 +39,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac int j = 0; - Instance->unregistered_count++; + this->unregistered_count++; char ipaddr[MAXBUF]; #ifdef IPV6 @@ -49,7 +49,7 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac #endif inet_ntop(AF_INET, &((const sockaddr_in*)ip)->sin_addr, ipaddr, sizeof(ipaddr)); - (*(Instance->clientlist))[New->uuid] = New; + (*(this->clientlist))[New->uuid] = New; /* The users default nick is their UUID */ strlcpy(New->nick, New->uuid, NICKMAX - 1); @@ -92,9 +92,9 @@ void UserManager::AddClient(InspIRCd* Instance, int socket, int port, bool iscac */ New->CheckClass(); - Instance->local_users.push_back(New); + this->local_users.push_back(New); - if ((Instance->local_users.size() > Instance->Config->SoftLimit) || (Instance->local_users.size() >= MAXCLIENTS)) + if ((this->local_users.size() > Instance->Config->SoftLimit) || (this->local_users.size() >= MAXCLIENTS)) { Instance->SNO->WriteToSnoMask('A', "Warning: softlimit value has been reached: %d clients", Instance->Config->SoftLimit); User::QuitUser(Instance, New,"No more connections allowed"); @@ -243,32 +243,148 @@ unsigned int UserManager::UserCount() * As part of this restructuring, move clientlist/etc fields into usermanager. * -- w00t */ - return ServerInstance->clientlist->size(); + return this->clientlist->size(); } /* this counts only registered users, so that the percentages in /MAP don't mess up */ unsigned int UserManager::RegisteredUserCount() { - return ServerInstance->clientlist->size() - this->UnregisteredUserCount(); + return this->clientlist->size() - this->UnregisteredUserCount(); } /* return how many users are opered */ unsigned int UserManager::OperCount() { - return ServerInstance->all_opers.size(); + return this->all_opers.size(); } /* return how many users are unregistered */ unsigned int UserManager::UnregisteredUserCount() { - return ServerInstance->unregistered_count; + return this->unregistered_count; } /* return how many local registered users there are */ unsigned int UserManager::LocalUserCount() { /* Doesnt count unregistered clients */ - return (ServerInstance->local_users.size() - this->UnregisteredUserCount()); + return (this->local_users.size() - this->UnregisteredUserCount()); } +void UserManager::ServerNoticeAll(char* text, ...) +{ + if (!text) + return; + + char textbuffer[MAXBUF]; + char formatbuffer[MAXBUF]; + va_list argsPtr; + va_start (argsPtr, text); + vsnprintf(textbuffer, MAXBUF, text, argsPtr); + va_end(argsPtr); + + snprintf(formatbuffer,MAXBUF,"NOTICE $%s :%s", ServerInstance->Config->ServerName, textbuffer); + + for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++) + { + User* t = *i; + t->WriteServ(std::string(formatbuffer)); + } +} + +void UserManager::ServerPrivmsgAll(char* text, ...) +{ + if (!text) + return; + + char textbuffer[MAXBUF]; + char formatbuffer[MAXBUF]; + va_list argsPtr; + va_start (argsPtr, text); + vsnprintf(textbuffer, MAXBUF, text, argsPtr); + va_end(argsPtr); + + snprintf(formatbuffer,MAXBUF,"PRIVMSG $%s :%s", ServerInstance->Config->ServerName, textbuffer); + + for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++) + { + User* t = *i; + t->WriteServ(std::string(formatbuffer)); + } +} + +void UserManager::WriteMode(const char* modes, int flags, const char* text, ...) +{ + char textbuffer[MAXBUF]; + int modelen; + va_list argsPtr; + + if (!text || !modes || !flags) + { + ServerInstance->Log(DEFAULT,"*** BUG *** WriteMode was given an invalid parameter"); + return; + } + + va_start(argsPtr, text); + vsnprintf(textbuffer, MAXBUF, text, argsPtr); + va_end(argsPtr); + modelen = strlen(modes); + + if (flags == WM_AND) + { + for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++) + { + User* t = *i; + bool send_to_user = true; + + for (int n = 0; n < modelen; n++) + { + if (!t->IsModeSet(modes[n])) + { + send_to_user = false; + break; + } + } + if (send_to_user) + { + t->WriteServ("NOTICE %s :%s", t->nick, textbuffer); + } + } + } + else if (flags == WM_OR) + { + for (std::vector<User*>::const_iterator i = local_users.begin(); i != local_users.end(); i++) + { + User* t = *i; + bool send_to_user = false; + + for (int n = 0; n < modelen; n++) + { + if (t->IsModeSet(modes[n])) + { + send_to_user = true; + break; + } + } + + if (send_to_user) + { + t->WriteServ("NOTICE %s :%s", t->nick, textbuffer); + } + } + } +} + +/* return how many users have a given mode e.g. 'a' */ +int UserManager::ModeCount(const char mode) +{ + ModeHandler* mh = this->ServerInstance->Modes->FindMode(mode, MODETYPE_USER); + + if (mh) + return mh->GetCount(); + else + return 0; +} + + diff --git a/src/userprocess.cpp b/src/userprocess.cpp index 5ec2581f7..dd1ca1799 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -167,7 +167,7 @@ void InspIRCd::DoBackgroundUserStuff() /* * loop over all local users.. */ - for (std::vector<User*>::iterator count2 = local_users.begin(); count2 != local_users.end(); count2++) + for (std::vector<User*>::iterator count2 = this->Users->local_users.begin(); count2 != this->Users->local_users.end(); count2++) { User *curr = *count2; diff --git a/src/users.cpp b/src/users.cpp index 731f5a603..6b2aebfc7 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -205,9 +205,9 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance ServerInstance->Log(DEBUG,"New UUID for user: %s (%s)", uuid, uid.empty() ? "allocated new" : "used remote"); - user_hash::iterator finduuid = Instance->uuidlist->find(uuid); - if (finduuid == Instance->uuidlist->end()) - (*Instance->uuidlist)[uuid] = this; + user_hash::iterator finduuid = Instance->Users->uuidlist->find(uuid); + if (finduuid == Instance->Users->uuidlist->end()) + (*Instance->Users->uuidlist)[uuid] = this; else throw CoreException("Duplicate UUID "+std::string(uuid)+" in User constructor"); } @@ -245,7 +245,7 @@ User::~User() #endif } - ServerInstance->uuidlist->erase(uuid); + ServerInstance->Users->uuidlist->erase(uuid); } char* User::MakeHost() @@ -636,7 +636,7 @@ void User::Oper(const std::string &opertype, const std::string &opername) FOREACH_MOD(I_OnOper, OnOper(this, opertype)); ServerInstance->Log(DEFAULT,"OPER: %s!%s@%s opered as type: %s", this->nick, this->ident, this->host, opertype.c_str()); strlcpy(this->oper, opertype.c_str(), NICKMAX - 1); - ServerInstance->all_opers.push_back(this); + ServerInstance->Users->all_opers.push_back(this); opertype_t::iterator iter_opertype = ServerInstance->Config->opertypes.find(this->oper); if (iter_opertype != ServerInstance->Config->opertypes.end()) @@ -688,7 +688,7 @@ void User::UnOper() this->modes[UM_OPERATOR] = 0; // remove the user from the oper list. Will remove multiple entries as a safeguard against bug #404 - ServerInstance->all_opers.remove(this); + ServerInstance->Users->all_opers.remove(this); if (AllowedOperCommands) { @@ -811,8 +811,8 @@ void User::FullConnect() this->ShowMOTD(); /* Now registered */ - if (ServerInstance->unregistered_count) - ServerInstance->unregistered_count--; + if (ServerInstance->Users->unregistered_count) + ServerInstance->Users->unregistered_count--; /* Trigger LUSERS output, give modules a chance too */ int MOD_RESULT = 0; @@ -845,17 +845,17 @@ User* User::UpdateNickHash(const char* New) try { //user_hash::iterator newnick; - user_hash::iterator oldnick = ServerInstance->clientlist->find(this->nick); + user_hash::iterator oldnick = ServerInstance->Users->clientlist->find(this->nick); if (!strcasecmp(this->nick,New)) return oldnick->second; - if (oldnick == ServerInstance->clientlist->end()) + if (oldnick == ServerInstance->Users->clientlist->end()) return NULL; /* doesnt exist */ User* olduser = oldnick->second; - (*(ServerInstance->clientlist))[New] = olduser; - ServerInstance->clientlist->erase(oldnick); + (*(ServerInstance->Users->clientlist))[New] = olduser; + ServerInstance->Users->clientlist->erase(oldnick); return olduser; } @@ -1312,7 +1312,7 @@ void User::WriteWallOps(const std::string &text) std::string wallop("WALLOPS :"); wallop.append(text); - for (std::vector<User*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++) + for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++) { User* t = *i; if (t->IsModeSet('w')) @@ -1456,7 +1456,7 @@ void User::SendAll(const char* command, char* text, ...) snprintf(formatbuffer,MAXBUF,":%s %s $* :%s", this->GetFullHost(), command, textbuffer); std::string fmt = formatbuffer; - for (std::vector<User*>::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++) + for (std::vector<User*>::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++) { (*i)->Write(fmt); } diff --git a/src/xline.cpp b/src/xline.cpp index 20df92dd0..268804f9d 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -70,7 +70,7 @@ void XLineManager::CheckELines() if (ELines.empty()) return; - for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++) + for (std::vector<User*>::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { User* u = (User*)(*u2); @@ -203,7 +203,7 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User* void ELine::Unset() { /* remove exempt from everyone and force recheck after deleting eline */ - for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++) + for (std::vector<User*>::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { User* u = (User*)(*u2); u->exempt = false; @@ -310,7 +310,7 @@ void XLineManager::ExpireLine(ContainerIter container, LookupIter item) // applies lines, removing clients and changing nicks etc as applicable void XLineManager::ApplyLines() { - for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++) + for (std::vector<User*>::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { User* u = (User*)(*u2); @@ -536,7 +536,7 @@ bool GLine::Matches(const std::string &str) void ELine::OnAdd() { /* When adding one eline, only check the one eline */ - for (std::vector<User*>::const_iterator u2 = ServerInstance->local_users.begin(); u2 != ServerInstance->local_users.end(); u2++) + for (std::vector<User*>::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++) { User* u = (User*)(*u2); if (this->Matches(u)) |