mirror of
https://github.com/azerothcore/mod-anticheat.git
synced 2026-01-13 00:58:35 +00:00
feat(Config): update to new API (#40)
This commit is contained in:
@@ -31,7 +31,7 @@ AnticheatMgr::~AnticheatMgr()
|
|||||||
|
|
||||||
void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo /* movementInfo */, uint32 opcode)
|
void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo /* movementInfo */, uint32 opcode)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.DetectJumpHack", true))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.DetectJumpHack", true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ObjectGuid key = player->GetGUID();
|
ObjectGuid key = player->GetGUID();
|
||||||
@@ -45,7 +45,7 @@ void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo /* movementInf
|
|||||||
|
|
||||||
void AnticheatMgr::WalkOnWaterHackDetection(Player* player, MovementInfo movementInfo)
|
void AnticheatMgr::WalkOnWaterHackDetection(Player* player, MovementInfo movementInfo)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.DetectWaterWalkHack", true))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.DetectWaterWalkHack", true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ObjectGuid key = player->GetGUID();
|
ObjectGuid key = player->GetGUID();
|
||||||
@@ -61,13 +61,13 @@ void AnticheatMgr::WalkOnWaterHackDetection(Player* player, MovementInfo moveme
|
|||||||
player->HasAuraType(SPELL_AURA_SAFE_FALL) ||
|
player->HasAuraType(SPELL_AURA_SAFE_FALL) ||
|
||||||
player->HasAuraType(SPELL_AURA_WATER_WALK))
|
player->HasAuraType(SPELL_AURA_WATER_WALK))
|
||||||
return;
|
return;
|
||||||
if (sConfigMgr->GetBoolDefault("Anticheat.KickPlayerWaterWalkHack", false))
|
if (sConfigMgr->GetOption<bool>("Anticheat.KickPlayerWaterWalkHack", false))
|
||||||
{
|
{
|
||||||
if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false))
|
if (sConfigMgr->GetOption<bool>("Anticheat.WriteLog", false))
|
||||||
sLog->outString("AnticheatMgr:: Walk on Water - Hack detected and counteracted by kicking player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
sLog->outString("AnticheatMgr:: Walk on Water - Hack detected and counteracted by kicking player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
||||||
|
|
||||||
player->GetSession()->KickPlayer(true);
|
player->GetSession()->KickPlayer(true);
|
||||||
if(sConfigMgr->GetBoolDefault("Anticheat.AnnounceKick", true))
|
if(sConfigMgr->GetOption<bool>("Anticheat.AnnounceKick", true))
|
||||||
{
|
{
|
||||||
std::string plr = player->GetName();
|
std::string plr = player->GetName();
|
||||||
std::string tag_colour = "7bbef7";
|
std::string tag_colour = "7bbef7";
|
||||||
@@ -79,7 +79,7 @@ void AnticheatMgr::WalkOnWaterHackDetection(Player* player, MovementInfo moveme
|
|||||||
sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str());
|
sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false)) {
|
else if (sConfigMgr->GetOption<bool>("Anticheat.WriteLog", false)) {
|
||||||
sLog->outString("AnticheatMgr:: Walk on Water - Hack detected player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
sLog->outString("AnticheatMgr:: Walk on Water - Hack detected player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
||||||
}
|
}
|
||||||
BuildReport(player, WALK_WATER_HACK_REPORT);
|
BuildReport(player, WALK_WATER_HACK_REPORT);
|
||||||
@@ -88,7 +88,7 @@ void AnticheatMgr::WalkOnWaterHackDetection(Player* player, MovementInfo moveme
|
|||||||
|
|
||||||
void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo)
|
void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.DetectFlyHack", true))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.DetectFlyHack", true))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo)
|
|||||||
|
|
||||||
/*Thanks to @LilleCarl for info to check extra flag*/
|
/*Thanks to @LilleCarl for info to check extra flag*/
|
||||||
bool stricterChecks = true;
|
bool stricterChecks = true;
|
||||||
if (sConfigMgr->GetBoolDefault("Anticheat.StricterFlyHackCheck", false))
|
if (sConfigMgr->GetOption<bool>("Anticheat.StricterFlyHackCheck", false))
|
||||||
{
|
{
|
||||||
stricterChecks = !(movementInfo.HasMovementFlag(MOVEMENTFLAG_ASCENDING) && !player->IsInWater());
|
stricterChecks = !(movementInfo.HasMovementFlag(MOVEMENTFLAG_ASCENDING) && !player->IsInWater());
|
||||||
}
|
}
|
||||||
@@ -110,15 +110,15 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sConfigMgr->GetBoolDefault("Anticheat.KickPlayerFlyHack", false))
|
if (sConfigMgr->GetOption<bool>("Anticheat.KickPlayerFlyHack", false))
|
||||||
{
|
{
|
||||||
if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false))
|
if (sConfigMgr->GetOption<bool>("Anticheat.WriteLog", false))
|
||||||
{
|
{
|
||||||
sLog->outString("AnticheatMgr:: Fly-Hack detected and counteracted by kicking player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
sLog->outString("AnticheatMgr:: Fly-Hack detected and counteracted by kicking player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
player->GetSession()->KickPlayer(true);
|
player->GetSession()->KickPlayer(true);
|
||||||
if(sConfigMgr->GetBoolDefault("Anticheat.AnnounceKick", true))
|
if(sConfigMgr->GetOption<bool>("Anticheat.AnnounceKick", true))
|
||||||
{
|
{
|
||||||
std::string plr = player->GetName();
|
std::string plr = player->GetName();
|
||||||
std::string tag_colour = "7bbef7";
|
std::string tag_colour = "7bbef7";
|
||||||
@@ -129,7 +129,7 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo)
|
|||||||
" has been kicked.|r";
|
" has been kicked.|r";
|
||||||
sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str());
|
sWorld->SendServerMessage(SERVER_MSG_STRING, stream.str().c_str());
|
||||||
}
|
}
|
||||||
} else if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false))
|
} else if (sConfigMgr->GetOption<bool>("Anticheat.WriteLog", false))
|
||||||
{
|
{
|
||||||
sLog->outString( "AnticheatMgr:: Fly-Hack detected player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
sLog->outString( "AnticheatMgr:: Fly-Hack detected player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo)
|
|||||||
|
|
||||||
void AnticheatMgr::TeleportPlaneHackDetection(Player* player, MovementInfo movementInfo)
|
void AnticheatMgr::TeleportPlaneHackDetection(Player* player, MovementInfo movementInfo)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.DetectTelePlaneHack", true))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.DetectTelePlaneHack", true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ObjectGuid key = player->GetGUID();
|
ObjectGuid key = player->GetGUID();
|
||||||
@@ -162,7 +162,7 @@ void AnticheatMgr::TeleportPlaneHackDetection(Player* player, MovementInfo movem
|
|||||||
// we are not really walking there
|
// we are not really walking there
|
||||||
if (z_diff > 1.0f)
|
if (z_diff > 1.0f)
|
||||||
{
|
{
|
||||||
if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false))
|
if (sConfigMgr->GetOption<bool>("Anticheat.WriteLog", false))
|
||||||
sLog->outString("AnticheatMgr:: Teleport To Plane - Hack detected player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
sLog->outString("AnticheatMgr:: Teleport To Plane - Hack detected player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
||||||
|
|
||||||
BuildReport(player, TELEPORT_PLANE_HACK_REPORT);
|
BuildReport(player, TELEPORT_PLANE_HACK_REPORT);
|
||||||
@@ -171,7 +171,7 @@ void AnticheatMgr::TeleportPlaneHackDetection(Player* player, MovementInfo movem
|
|||||||
|
|
||||||
void AnticheatMgr::StartHackDetection(Player* player, MovementInfo movementInfo, uint32 opcode)
|
void AnticheatMgr::StartHackDetection(Player* player, MovementInfo movementInfo, uint32 opcode)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.Enabled", 0))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.Enabled", 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (player->IsGameMaster())
|
if (player->IsGameMaster())
|
||||||
@@ -200,7 +200,7 @@ void AnticheatMgr::StartHackDetection(Player* player, MovementInfo movementInfo,
|
|||||||
// basic detection
|
// basic detection
|
||||||
void AnticheatMgr::ClimbHackDetection(Player *player, MovementInfo movementInfo, uint32 opcode)
|
void AnticheatMgr::ClimbHackDetection(Player *player, MovementInfo movementInfo, uint32 opcode)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.DetectClimbHack", false))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.DetectClimbHack", false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ObjectGuid key = player->GetGUID();
|
ObjectGuid key = player->GetGUID();
|
||||||
@@ -225,7 +225,7 @@ void AnticheatMgr::ClimbHackDetection(Player *player, MovementInfo movementInfo,
|
|||||||
|
|
||||||
if (angle > CLIMB_ANGLE)
|
if (angle > CLIMB_ANGLE)
|
||||||
{
|
{
|
||||||
if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false))
|
if (sConfigMgr->GetOption<bool>("Anticheat.WriteLog", false))
|
||||||
sLog->outString("AnticheatMgr:: Climb-Hack detected player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
sLog->outString("AnticheatMgr:: Climb-Hack detected player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
||||||
|
|
||||||
BuildReport(player, CLIMB_HACK_REPORT);
|
BuildReport(player, CLIMB_HACK_REPORT);
|
||||||
@@ -234,7 +234,7 @@ void AnticheatMgr::ClimbHackDetection(Player *player, MovementInfo movementInfo,
|
|||||||
|
|
||||||
void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
|
void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.DetectSpeedHack", true))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.DetectSpeedHack", true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ObjectGuid key = player->GetGUID();
|
ObjectGuid key = player->GetGUID();
|
||||||
@@ -274,7 +274,7 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
|
|||||||
// we did the (uint32) cast to accept a margin of tolerance
|
// we did the (uint32) cast to accept a margin of tolerance
|
||||||
if (clientSpeedRate > speedRate)
|
if (clientSpeedRate > speedRate)
|
||||||
{
|
{
|
||||||
if (sConfigMgr->GetBoolDefault("Anticheat.WriteLog", false))
|
if (sConfigMgr->GetOption<bool>("Anticheat.WriteLog", false))
|
||||||
sLog->outString("AnticheatMgr:: Speed-Hack detected player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
sLog->outString("AnticheatMgr:: Speed-Hack detected player %s (%s)", player->GetName().c_str(), player->GetGUID().ToString().c_str());
|
||||||
|
|
||||||
BuildReport(player, SPEED_HACK_REPORT);
|
BuildReport(player, SPEED_HACK_REPORT);
|
||||||
@@ -377,7 +377,7 @@ void AnticheatMgr::BuildReport(Player* player, uint8 reportType)
|
|||||||
m_Players[key].SetAverage(average);
|
m_Players[key].SetAverage(average);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((uint32)sConfigMgr->GetIntDefault("Anticheat.MaxReportsForDailyReport", 70) < m_Players[key].GetTotalReports())
|
if (sConfigMgr->GetOption<uint32>("Anticheat.MaxReportsForDailyReport", 70) < m_Players[key].GetTotalReports())
|
||||||
{
|
{
|
||||||
if (!m_Players[key].GetDailyReportState())
|
if (!m_Players[key].GetDailyReportState())
|
||||||
{
|
{
|
||||||
@@ -386,7 +386,7 @@ void AnticheatMgr::BuildReport(Player* player, uint8 reportType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Players[key].GetTotalReports() > (uint32)sConfigMgr->GetIntDefault("Anticheat.ReportsForIngameWarnings", 70))
|
if (m_Players[key].GetTotalReports() > sConfigMgr->GetOption<uint32>("Anticheat.ReportsForIngameWarnings", 70))
|
||||||
{
|
{
|
||||||
// display warning at the center of the screen, hacky way?
|
// display warning at the center of the screen, hacky way?
|
||||||
std::string str = "";
|
std::string str = "";
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
void OnLogin(Player* player) override
|
void OnLogin(Player* player) override
|
||||||
{
|
{
|
||||||
sAnticheatMgr->HandlePlayerLogin(player);
|
sAnticheatMgr->HandlePlayerLogin(player);
|
||||||
if(sConfigMgr->GetBoolDefault("Anticheat.LoginMessage", true))
|
if(sConfigMgr->GetOption<bool>("Anticheat.LoginMessage", true))
|
||||||
ChatHandler(player->GetSession()).PSendSysMessage("This server is running an Anticheat Module.");
|
ChatHandler(player->GetSession()).PSendSysMessage("This server is running an Anticheat Module.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
}
|
}
|
||||||
if (sWorld->GetUptime() > lastIterationPlayer)
|
if (sWorld->GetUptime() > lastIterationPlayer)
|
||||||
{
|
{
|
||||||
lastIterationPlayer = sWorld->GetUptime() + sConfigMgr->GetIntDefault("Anticheat.SaveReportsTime", 60);
|
lastIterationPlayer = sWorld->GetUptime() + sConfigMgr->GetOption<uint32>("Anticheat.SaveReportsTime", 60);
|
||||||
sLog->outString( "Saving reports for %u players.", sWorld->GetPlayerCount());
|
sLog->outString( "Saving reports for %u players.", sWorld->GetPlayerCount());
|
||||||
|
|
||||||
for (SessionMap::const_iterator itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
|
for (SessionMap::const_iterator itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
|
||||||
@@ -71,7 +71,7 @@ class AnticheatMovementHandlerScript : public MovementHandlerScript
|
|||||||
}
|
}
|
||||||
void OnPlayerMove(Player* player, MovementInfo mi, uint32 opcode) override
|
void OnPlayerMove(Player* player, MovementInfo mi, uint32 opcode) override
|
||||||
{
|
{
|
||||||
if (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || sConfigMgr->GetBoolDefault("Anticheat.EnabledOnGmAccounts", false))
|
if (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) || sConfigMgr->GetOption<bool>("Anticheat.EnabledOnGmAccounts", false))
|
||||||
sAnticheatMgr->StartHackDetection(player, mi, opcode);
|
sAnticheatMgr->StartHackDetection(player, mi, opcode);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public:
|
|||||||
|
|
||||||
static bool HandleAnticheatWarnCommand(ChatHandler* handler, const char* args)
|
static bool HandleAnticheatWarnCommand(ChatHandler* handler, const char* args)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.Enabled", 0))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.Enabled", 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player* pTarget = NULL;
|
Player* pTarget = NULL;
|
||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
static bool HandleAnticheatJailCommand(ChatHandler* handler, const char* args)
|
static bool HandleAnticheatJailCommand(ChatHandler* handler, const char* args)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.Enabled", 0))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.Enabled", 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player* pTarget = NULL;
|
Player* pTarget = NULL;
|
||||||
@@ -140,7 +140,7 @@ public:
|
|||||||
|
|
||||||
static bool HandleAntiCheatDeleteCommand(ChatHandler* handler, const char* args)
|
static bool HandleAntiCheatDeleteCommand(ChatHandler* handler, const char* args)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.Enabled", 0))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.Enabled", 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string strCommand;
|
std::string strCommand;
|
||||||
@@ -169,7 +169,7 @@ public:
|
|||||||
|
|
||||||
static bool HandleAntiCheatPlayerCommand(ChatHandler* handler, const char* args)
|
static bool HandleAntiCheatPlayerCommand(ChatHandler* handler, const char* args)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.Enabled", 0))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.Enabled", 0))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::string strCommand;
|
std::string strCommand;
|
||||||
@@ -221,7 +221,7 @@ public:
|
|||||||
|
|
||||||
static bool HandleAntiCheatGlobalCommand(ChatHandler* handler, const char* /* args */)
|
static bool HandleAntiCheatGlobalCommand(ChatHandler* handler, const char* /* args */)
|
||||||
{
|
{
|
||||||
if (!sConfigMgr->GetBoolDefault("Anticheat.Enabled", 0))
|
if (!sConfigMgr->GetOption<bool>("Anticheat.Enabled", 0))
|
||||||
{
|
{
|
||||||
handler->PSendSysMessage("The Anticheat System is disabled.");
|
handler->PSendSysMessage("The Anticheat System is disabled.");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user