X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusermanager.cpp;h=1966c9b4729f86193e8c8fa87694a3bf9395c936;hb=7492344e64491cea6bbb5c9354dceb804bb908ac;hp=0efad66b46c521ad9ceb314927a4b442544d8f7d;hpb=e0412d5161891c04faf2050cc02e8a9cffdda8a4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 0efad66b4..1966c9b47 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -24,6 +24,30 @@ #include "xline.h" #include "iohook.h" +namespace +{ + class WriteCommonQuit : public User::ForEachNeighborHandler + { + std::string line; + std::string operline; + + void Execute(LocalUser* user) CXX11_OVERRIDE + { + user->Write(user->IsOper() ? operline : line); + } + + public: + WriteCommonQuit(User* user, const std::string& msg, const std::string& opermsg) + : line(":" + user->GetFullHost() + " QUIT :") + , operline(line) + { + line += msg; + operline += opermsg; + user->ForEachNeighbor(*this, false); + } + }; +} + UserManager::UserManager() : unregistered_count(0) { @@ -180,7 +204,7 @@ void UserManager::QuitUser(User* user, const std::string& quitreason, const std: if (user->registered == REG_ALL) { FOREACH_MOD(OnUserQuit, (user, reason, *operreason)); - user->WriteCommonQuit(reason, *operreason); + WriteCommonQuit(user, reason, *operreason); } else unregistered_count--;