X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fusers.cpp;h=d760c713f30803be77e026a8aab06b0c56c8a861;hb=06eb88c10cb7a57ea800e0204b48277de9cb02ca;hp=5be3963b45b9ffcc66ec00b6eb62d03ac61b8f9a;hpb=cf728bd8a3de0942c2294ca5b49745092565d87c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/users.cpp b/src/users.cpp index 5be3963b4..d760c713f 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -764,7 +764,7 @@ void LocalUser::Write(const std::string& text) if (text.length() > ServerInstance->Config->Limits.MaxLine - 2) { // this should happen rarely or never. Crop the string at 512 and try again. - std::string try_again(0, ServerInstance->Config->Limits.MaxLine - 2); + std::string try_again(text, 0, ServerInstance->Config->Limits.MaxLine - 2); Write(try_again); return; } @@ -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)