]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_hostcycle.cpp
Merge pull request #1337 from SaberUK/master+merge
[user/henk/code/inspircd.git] / src / modules / m_hostcycle.cpp
index d4def647347e9e3fa0fbf4366cc85390661afa54..621f06a279e53e715feaa36c58a053603fd0e93c 100644 (file)
 
 
 #include "inspircd.h"
+#include "modules/cap.h"
 
 class ModuleHostCycle : public Module
 {
+       Cap::Reference chghostcap;
+
        /** Send fake quit/join/mode messages for host or ident cycle.
         */
-       static void DoHostCycle(User* user, const std::string& newident, const std::string& newhost, const char* quitmsg)
+       void DoHostCycle(User* user, const std::string& newident, const std::string& newhost, const char* quitmsg)
        {
                // GetFullHost() returns the original data at the time this function is called
                const std::string quitline = ":" + user->GetFullHost() + " QUIT :" + quitmsg;
@@ -37,10 +40,12 @@ class ModuleHostCycle : public Module
 
                FOREACH_MOD(OnBuildNeighborList, (user, include_chans, exceptions));
 
+               // Users shouldn't see themselves quitting when host cycling
+               exceptions.erase(user);
                for (std::map<User*,bool>::iterator i = exceptions.begin(); i != exceptions.end(); ++i)
                {
                        LocalUser* u = IS_LOCAL(i->first);
-                       if (u && !u->quitting)
+                       if ((u) && (!u->quitting) && (!chghostcap.get(u)))
                        {
                                if (i->second)
                                {
@@ -80,6 +85,8 @@ class ModuleHostCycle : public Module
                                        continue;
                                if (u->already_sent == silent_id)
                                        continue;
+                               if (chghostcap.get(u))
+                                       continue;
 
                                if (u->already_sent != seen_id)
                                {
@@ -95,6 +102,11 @@ class ModuleHostCycle : public Module
        }
 
  public:
+       ModuleHostCycle()
+               : chghostcap(this, "chghost")
+       {
+       }
+
        void OnChangeIdent(User* user, const std::string& newident) CXX11_OVERRIDE
        {
                DoHostCycle(user, newident, user->dhost, "Changing ident");