From: Attila Molnar Date: Tue, 3 Nov 2015 12:08:21 +0000 (+0100) Subject: Add UserManager::NextAlreadySentId() and convert all code to use it X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=3ef3047681f0813d8f1d06939eaa2ef378d99505;p=user%2Fhenk%2Fcode%2Finspircd.git Add UserManager::NextAlreadySentId() and convert all code to use it --- diff --git a/include/usermanager.h b/include/usermanager.h index eee076802..605b841bb 100644 --- a/include/usermanager.h +++ b/include/usermanager.h @@ -186,4 +186,9 @@ class CoreExport UserManager : public fakederef * @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(); }; diff --git a/src/modules/m_hostcycle.cpp b/src/modules/m_hostcycle.cpp index e8a0abbf1..d4def6473 100644 --- a/src/modules/m_hostcycle.cpp +++ b/src/modules/m_hostcycle.cpp @@ -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 exceptions; diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 41061f6d1..c593e149f 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -368,3 +368,8 @@ void UserManager::DoBackgroundUserStuff() } } } + +already_sent_t UserManager::NextAlreadySentId() +{ + return ++LocalUser::already_sent_id; +} diff --git a/src/users.cpp b/src/users.cpp index d503844e7..258544312 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -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::const_iterator i = exceptions.begin(); i != exceptions.end(); ++i)