Skip to content

Commit

Permalink
Merge pull request #142 from Takenbacon/worldsessionmgr-fix
Browse files Browse the repository at this point in the history
Update to support WorldSessionMgr PR
  • Loading branch information
Kitzunu authored Feb 13, 2025
2 parents b7227f6 + e5348ce commit 49350ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/AnticheatMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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());
}
}

Expand All @@ -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());
}
}

Expand Down Expand Up @@ -1801,15 +1802,16 @@ 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());
}
}
}

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())
{
Expand Down
6 changes: 4 additions & 2 deletions src/AnticheatScripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,9 +79,10 @@ class AnticheatWorldScript : public WorldScript
{
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);
}
Expand Down

0 comments on commit 49350ee

Please sign in to comment.