X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=12243c64b074df57ab7442f4b5e8a782d79c5858;hb=7492344e64491cea6bbb5c9354dceb804bb908ac;hp=5be3963b45b9ffcc66ec00b6eb62d03ac61b8f9a;hpb=cf728bd8a3de0942c2294ca5b49745092565d87c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index 5be3963b4..12243c64b 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -845,11 +845,27 @@ void User::WriteFrom(User *user, const char* text, ...) this->WriteFrom(user, textbuffer); } -void User::WriteCommon(const char* text, ...) +namespace { - if (this->registered != REG_ALL || quitting) - return; + class WriteCommonRawHandler : public User::ForEachNeighborHandler + { + const std::string& msg; + + void Execute(LocalUser* user) CXX11_OVERRIDE + { + user->Write(msg); + } + public: + WriteCommonRawHandler(const std::string& message) + : msg(message) + { + } + }; +} + +void User::WriteCommon(const char* text, ...) +{ std::string textbuffer; VAFORMAT(textbuffer, text, text); textbuffer = ":" + this->GetFullHost() + " " + textbuffer; @@ -858,42 +874,8 @@ void User::WriteCommon(const char* text, ...) void User::WriteCommonRaw(const std::string &line, bool include_self) { - if (this->registered != REG_ALL || quitting) - return; - - LocalUser::already_sent_id++; - - IncludeChanList include_c(chans.begin(), chans.end()); - std::map exceptions; - - exceptions[this] = include_self; - - FOREACH_MOD(OnBuildNeighborList, (this, include_c, exceptions)); - - for (std::map::iterator i = exceptions.begin(); i != exceptions.end(); ++i) - { - LocalUser* u = IS_LOCAL(i->first); - if (u && !u->quitting) - { - u->already_sent = LocalUser::already_sent_id; - if (i->second) - u->Write(line); - } - } - for (IncludeChanList::const_iterator v = include_c.begin(); v != include_c.end(); ++v) - { - Channel* c = (*v)->chan; - const Channel::MemberMap& ulist = c->GetUsers(); - for (Channel::MemberMap::const_iterator i = ulist.begin(); i != ulist.end(); ++i) - { - LocalUser* u = IS_LOCAL(i->first); - if (u && u->already_sent != LocalUser::already_sent_id) - { - u->already_sent = LocalUser::already_sent_id; - u->Write(line); - } - } - } + WriteCommonRawHandler handler(line); + ForEachNeighbor(handler, include_self); } void User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self)