mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 20:56:23 +00:00
feat(Core/World): Implement DoForAllPlayers() helper for all online p… (#18060)
* feat(Core/World): Implement DoForAllPlayers() helper for all online players * Update src/server/game/World/World.cpp Co-authored-by: Winfidonarleyan <dowlandtop@yandex.com> * Update src/server/game/World/World.cpp Co-authored-by: Winfidonarleyan <dowlandtop@yandex.com> * rename * Update WorldMock.h * Update WorldMock.h --------- Co-authored-by: Winfidonarleyan <dowlandtop@yandex.com>
This commit is contained in:
@@ -608,6 +608,7 @@ public:
|
||||
[[nodiscard]] virtual std::string const& GetRealmName() const = 0;
|
||||
virtual void SetRealmName(std::string name) = 0;
|
||||
virtual void RemoveOldCorpses() = 0;
|
||||
virtual void DoForAllOnlinePlayers(std::function<void(Player*)> exec) = 0;
|
||||
};
|
||||
|
||||
#endif //AZEROTHCORE_IWORLD_H
|
||||
|
||||
@@ -3253,6 +3253,23 @@ void World::RemoveOldCorpses()
|
||||
_timers[WUPDATE_CORPSES].SetCurrent(_timers[WUPDATE_CORPSES].GetInterval());
|
||||
}
|
||||
|
||||
void World::DoForAllOnlinePlayers(std::function<void(Player*)> exec)
|
||||
{
|
||||
std::shared_lock lock(*HashMapHolder<Player>::GetLock());
|
||||
for (auto const& it : ObjectAccessor::GetPlayers())
|
||||
{
|
||||
if (Player* player = it.second)
|
||||
{
|
||||
if (!player->IsInWorld())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
exec(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool World::IsPvPRealm() const
|
||||
{
|
||||
return getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP || getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_FFA_PVP;
|
||||
|
||||
@@ -349,6 +349,8 @@ public:
|
||||
|
||||
void RemoveOldCorpses() override;
|
||||
|
||||
void DoForAllOnlinePlayers(std::function<void(Player*)> exec) override;
|
||||
|
||||
protected:
|
||||
void _UpdateGameTime();
|
||||
// callback for UpdateRealmCharacters
|
||||
|
||||
Reference in New Issue
Block a user