From 2591562ada4cb1f866e5d1c98340fb19332b3844 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 9 Aug 2006 17:52:10 +0000 Subject: Move tons more stuff into class InspIRCd git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4819 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/users.cpp | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index cb6fbc1f3..40c29ded1 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -39,7 +39,6 @@ extern std::vector module_sockets; extern int MODCOUNT; extern time_t TIME; extern Server* MyServer; -extern std::vector local_users; irc::whowas::whowas_users whowas; static unsigned long already_sent[MAX_DESCRIPTORS] = {0}; @@ -713,8 +712,8 @@ void userrec::QuitUser(userrec *user,const std::string &quitreason) if (IS_LOCAL(user)) { ServerInstance->fd_ref_table[user->fd] = NULL; - if (find(local_users.begin(),local_users.end(),user) != local_users.end()) - local_users.erase(find(local_users.begin(),local_users.end(),user)); + if (find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),user) != ServerInstance->local_users.end()) + ServerInstance->local_users.erase(find(ServerInstance->local_users.begin(),ServerInstance->local_users.end(),user)); } ServerInstance->clientlist.erase(iter); DELETE(user); @@ -873,15 +872,15 @@ void userrec::AddClient(int socket, int port, bool iscached, insp_inaddr ip) _new->recvqmax = class_rqmax; ServerInstance->fd_ref_table[socket] = _new; - local_users.push_back(_new); + ServerInstance->local_users.push_back(_new); - if (local_users.size() > ServerInstance->Config->SoftLimit) + if (ServerInstance->local_users.size() > ServerInstance->Config->SoftLimit) { userrec::QuitUser(_new,"No more connections allowed"); return; } - if (local_users.size() >= MAXCLIENTS) + if (ServerInstance->local_users.size() >= MAXCLIENTS) { userrec::QuitUser(_new,"No more connections allowed"); return; @@ -946,7 +945,7 @@ long userrec::GlobalCloneCount() long userrec::LocalCloneCount() { long x = 0; - for (std::vector::const_iterator a = local_users.begin(); a != local_users.end(); a++) + for (std::vector::const_iterator a = ServerInstance->local_users.begin(); a != ServerInstance->local_users.end(); a++) { userrec* comp = *a; #ifdef IPV6 @@ -1538,7 +1537,7 @@ void userrec::WriteWallOps(const std::string &text) std::string wallop = "WALLOPS :"; wallop.append(text); - for (std::vector::const_iterator i = local_users.begin(); i != local_users.end(); i++) + for (std::vector::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++) { userrec* t = *i; if ((IS_LOCAL(t)) && (t->modes[UM_WALLOPS])) @@ -1634,3 +1633,22 @@ bool userrec::ChangeDisplayedHost(const char* host) return true; } +void userrec::NoticeAll(char* text, ...) +{ + 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",textbuffer); + + for (std::vector::const_iterator i = ServerInstance->local_users.begin(); i != ServerInstance->local_users.end(); i++) + { + userrec* t = *i; + t->WriteFrom(this, std::string(formatbuffer)); + } +} + -- cgit v1.3.1-10-gc9f91