diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index d20344b..fb58bc9 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -31,6 +31,7 @@ #include "Configuration/Config.h" #include "SpellAuras.h" #include "DatabaseEnv.h" +#include "WorldSessionMgr.h" std::string modulestring = "anticheat"; constexpr auto LANG_ANTICHEAT_ALERT = 1; @@ -93,8 +94,8 @@ AnticheatMgr::~AnticheatMgr() void AnticheatMgr::DoToAllGMs(std::function 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 (!AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && player->IsInWorld()) exec(player); @@ -152,7 +153,7 @@ void AnticheatMgr::SendMiddleScreenGMMessage(std::string str) { WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); data << str; - sWorld->SendGlobalGMMessage(&data); + sWorldSessionMgr->SendGlobalGMMessage(&data); } const char* AnticheatMgr::GetReportNameFromReportType(ReportTypes reportType) @@ -1730,7 +1731,7 @@ void AnticheatMgr::BuildReport(Player* player, ReportTypes reportType, Optional< stream << "|CFF" << plr_colour << "[AntiCheat]|r|CFF" << tag_colour << " Player |r|cff" << plr_colour << plr << "|r|cff" << tag_colour << " has been kicked by the Anticheat Module.|r"; - sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str()); + sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str()); } } @@ -1756,7 +1757,7 @@ void AnticheatMgr::BuildReport(Player* player, ReportTypes reportType, Optional< stream << "|CFF" << plr_colour << "[AntiCheat]|r|CFF" << tag_colour << " Player |r|cff" << plr_colour << plr << "|r|cff" << tag_colour << " has been Banned by the Anticheat Module.|r"; - sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str()); + sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str()); } } @@ -1801,7 +1802,7 @@ void AnticheatMgr::BuildReport(Player* player, ReportTypes reportType, Optional< stream << "|CFF" << plr_colour << "[AntiCheat]|r|CFF" << tag_colour << " Player |r|cff" << plr_colour << plr << "|r|cff" << tag_colour << " has been Jailed by the Anticheat Module.|r"; - sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str()); + sWorldSessionMgr->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str()); } } } @@ -1809,7 +1810,8 @@ void AnticheatMgr::BuildReport(Player* player, ReportTypes reportType, Optional< void AnticheatMgr::AnticheatGlobalCommand(ChatHandler* handler) { // save All Anticheat Player Data before displaying global stats - for (SessionMap::const_iterator 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* plr = itr->second->GetPlayer()) { diff --git a/src/AnticheatScripts.cpp b/src/AnticheatScripts.cpp index 6b21086..628d312 100644 --- a/src/AnticheatScripts.cpp +++ b/src/AnticheatScripts.cpp @@ -30,6 +30,7 @@ #include "Player.h" #include "Timer.h" #include "GameTime.h" +#include "WorldSessionMgr.h" Seconds resetTime = 0s; Seconds lastIterationPlayer = GameTime::GetUptime() + 30s; //TODO: change 30 secs static to a configurable option @@ -78,9 +79,10 @@ public: { lastIterationPlayer = GameTime::GetUptime() + Seconds(sConfigMgr->GetOption("Anticheat.SaveReportsTime", 60)); - LOG_INFO("module", "Saving reports for {} players.", sWorld->GetPlayerCount()); + LOG_INFO("module", "Saving reports for {} players.", sWorldSessionMgr->GetPlayerCount()); - for (SessionMap::const_iterator 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* plr = itr->second->GetPlayer()) sAnticheatMgr->SavePlayerData(plr); }