+void User::DoHostCycle(const std::string &quitline)
+{
+ char buffer[MAXBUF];
+
+ ModResult result = MOD_RES_PASSTHRU;
+ FIRST_MOD_RESULT(ServerInstance, OnHostCycle, result, (this));
+
+ if (result == MOD_RES_DENY)
+ return;
+ if (result == MOD_RES_PASSTHRU && !ServerInstance->Config->CycleHosts)
+ return;
+
+ uniq_id++;
+
+ if (!already_sent)
+ InitializeAlreadySent(ServerInstance->SE);
+
+ for (UCListIter v = this->chans.begin(); v != this->chans.end(); v++)
+ {
+ Channel* c = *v;
+ snprintf(buffer, MAXBUF, ":%s JOIN %s", GetFullHost().c_str(), c->name.c_str());
+ std::string joinline(buffer);
+ std::string modeline = ServerInstance->Modes->ModeString(this, c);
+ if (modeline.length() > 0)
+ {
+ snprintf(buffer, MAXBUF, ":%s MODE %s +%s", GetFullHost().c_str(), c->name.c_str(), modeline.c_str());
+ modeline = buffer;
+ }
+
+ const UserMembList *ulist = c->GetUsers();
+ for (UserMembList::const_iterator i = ulist->begin(); i != ulist->end(); i++)
+ {
+ User* u = i->first;
+ if (u == this || !IS_LOCAL(u))
+ continue;
+
+ if (already_sent[i->first->fd] != uniq_id)
+ {
+ u->Write(quitline);
+ already_sent[i->first->fd] = uniq_id;
+ }
+ u->Write(joinline);
+ if (modeline.length() > 0)
+ u->Write(modeline);
+ }
+ }
+}
+