From 9924e5631193ad581d885380fd11ae8bfb91fa0b Mon Sep 17 00:00:00 2001 From: danieldg Date: Wed, 21 Oct 2009 23:44:48 +0000 Subject: Split LocalUser and RemoteUser git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11940 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/users.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index fbb2309c3..e24f59a0c 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -233,13 +233,9 @@ User::User(const std::string &uid) server_sa.sa.sa_family = AF_UNSPEC; client_sa.sa.sa_family = AF_UNSPEC; AllowedPrivs = AllowedOperCommands = NULL; + uuid = uid; - if (uid.empty()) - uuid = ServerInstance->GetUID(); - else - uuid = uid; - - ServerInstance->Logs->Log("USERS", DEBUG,"New UUID for user: %s (%s)", uuid.c_str(), uid.empty() ? "allocated new" : "used remote"); + ServerInstance->Logs->Log("USERS", DEBUG, "New UUID for user: %s", uuid.c_str()); user_hash::iterator finduuid = ServerInstance->Users->uuidlist->find(uuid); if (finduuid == ServerInstance->Users->uuidlist->end()) @@ -248,6 +244,10 @@ User::User(const std::string &uid) throw CoreException("Duplicate UUID "+std::string(uuid)+" in User constructor"); } +LocalUser::LocalUser() : User(ServerInstance->GetUID()) +{ +} + User::~User() { if (uuid.length()) @@ -603,7 +603,7 @@ CullResult User::cull() if (fd != INT_MAX) Close(); - std::vector::iterator x = find(ServerInstance->Users->local_users.begin(),ServerInstance->Users->local_users.end(),this); + std::vector::iterator x = find(ServerInstance->Users->local_users.begin(),ServerInstance->Users->local_users.end(),this); if (x != ServerInstance->Users->local_users.end()) ServerInstance->Users->local_users.erase(x); else @@ -1341,12 +1341,18 @@ void User::WriteCommonQuit(const std::string &normal_text, const std::string &op } } -void User::SendText(const std::string& line) +void LocalUser::SendText(const std::string& line) +{ + Write(line); +} + +void RemoteUser::SendText(const std::string& line) +{ + ServerInstance->PI->PushToClient(this, line); +} + +void FakeUser::SendText(const std::string& line) { - if (IS_LOCAL(this)) - Write(line); - else if (!IS_SERVER(this)) - ServerInstance->PI->PushToClient(this, line); } void User::SendText(const char *text, ...) @@ -1557,7 +1563,7 @@ void User::SendAll(const char* command, const char* text, ...) snprintf(formatbuffer,MAXBUF,":%s %s $* :%s", this->GetFullHost().c_str(), command, textbuffer); std::string fmt = formatbuffer; - for (std::vector::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++) + for (std::vector::const_iterator i = ServerInstance->Users->local_users.begin(); i != ServerInstance->Users->local_users.end(); i++) { (*i)->Write(fmt); } -- cgit v1.2.3