Merge pull request #142 from Takenbacon/worldsessionmgr-fix

Update to support WorldSessionMgr PR
This commit is contained in:
Kitzunu
2025-02-13 07:04:30 +01:00
committed by GitHub
2 changed files with 13 additions and 9 deletions

View File

@@ -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<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 (!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())
{

View File

@@ -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<uint32>("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);
}