]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add UserManager::NextAlreadySentId() and convert all code to use it
authorAttila Molnar <attilamolnar@hush.com>
Tue, 3 Nov 2015 12:08:21 +0000 (13:08 +0100)
committerAttila Molnar <attilamolnar@hush.com>
Tue, 3 Nov 2015 12:08:21 +0000 (13:08 +0100)
include/usermanager.h
src/modules/m_hostcycle.cpp
src/usermanager.cpp
src/users.cpp

index eee076802f866927f11ee1aca287e77140cfdf57..605b841bb053022c65a9cc6355b395f9efd82970 100644 (file)
@@ -186,4 +186,9 @@ class CoreExport UserManager : public fakederef<UserManager>
         * @param ... The format arguments
         */
        void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
+
+       /** Retrieves the next already sent id, guaranteed to be not equal to any user's already_sent field
+        * @return Next already_sent id
+        */
+       already_sent_t NextAlreadySentId();
 };
index e8a0abbf15800d1f6871483a2ad80e55c07a28b4..d4def647347e9e3fa0fbf4366cc85390661afa54 100644 (file)
@@ -29,8 +29,8 @@ class ModuleHostCycle : public Module
                // GetFullHost() returns the original data at the time this function is called
                const std::string quitline = ":" + user->GetFullHost() + " QUIT :" + quitmsg;
 
-               already_sent_t silent_id = ++LocalUser::already_sent_id;
-               already_sent_t seen_id = ++LocalUser::already_sent_id;
+               already_sent_t silent_id = ServerInstance->Users.NextAlreadySentId();
+               already_sent_t seen_id = ServerInstance->Users.NextAlreadySentId();
 
                IncludeChanList include_chans(user->chans.begin(), user->chans.end());
                std::map<User*,bool> exceptions;
index 41061f6d1d82decc109b3eb1fb3b6d4b34378ce3..c593e149f8ebef01da9a1c511b0a3e38b5153e7f 100644 (file)
@@ -368,3 +368,8 @@ void UserManager::DoBackgroundUserStuff()
                }
        }
 }
+
+already_sent_t UserManager::NextAlreadySentId()
+{
+       return ++LocalUser::already_sent_id;
+}
index d503844e794c76641187828a43ff395f30180a5d..2585443126c8f85a40cc5617d23679e2a3c72eb9 100644 (file)
@@ -873,7 +873,7 @@ void User::ForEachNeighbor(ForEachNeighborHandler& handler, bool include_self)
        FOREACH_MOD(OnBuildNeighborList, (this, include_chans, exceptions));
 
        // Get next id, guaranteed to differ from the already_sent field of all users
-       const already_sent_t newid = ++LocalUser::already_sent_id;
+       const already_sent_t newid = ServerInstance->Users.NextAlreadySentId();
 
        // Handle exceptions first
        for (std::map<User*, bool>::const_iterator i = exceptions.begin(); i != exceptions.end(); ++i)