refactor(Core/World): Create WorldSessionMgr to split session logic out of World (#21400)

This commit is contained in:
Takenbacon
2025-02-12 22:04:38 -08:00
committed by GitHub
parent 0f0b341d9d
commit edcfaeb845
32 changed files with 713 additions and 686 deletions

View File

@@ -30,6 +30,7 @@
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "WorldSessionMgr.h"
#include <boost/algorithm/string/replace.hpp>
Player* ChatHandler::GetPlayer() const
@@ -188,7 +189,7 @@ void ChatHandler::SendGlobalSysMessage(const char* str)
for (std::string_view line : Acore::Tokenize(str, '\n', true))
{
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
sWorld->SendGlobalMessage(&data);
sWorldSessionMgr->SendGlobalMessage(&data);
}
}
@@ -198,7 +199,7 @@ void ChatHandler::SendGlobalGMSysMessage(const char* str)
for (std::string_view line : Acore::Tokenize(str, '\n', true))
{
BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
sWorld->SendGlobalGMMessage(&data);
sWorldSessionMgr->SendGlobalGMMessage(&data);
}
}
@@ -442,8 +443,8 @@ bool ChatHandler::HasSession() const
void ChatHandler::DoForAllValidSessions(std::function<void(Player*)> exec)
{
SessionMap::const_iterator itr;
for (itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
WorldSessionMgr::SessionMap const& sessionMap = sWorldSessionMgr->GetAllSessions();
for (WorldSessionMgr::SessionMap::const_iterator itr = sessionMap.begin(); itr != sessionMap.end(); ++itr)
if (Player* player = itr->second->GetPlayer())
if (player->IsInWorld())
exec(player);