From de22e25cb25b91e02e507d0d314fde709ef3e78e Mon Sep 17 00:00:00 2001 From: MDIC Date: Tue, 10 May 2022 14:17:07 -0400 Subject: [PATCH] fix (module): Fix Ignore Control False positives --- src/AnticheatMgr.cpp | 84 ++++++++++++++++++++++++++------------------ src/AnticheatMgr.h | 2 +- 2 files changed, 50 insertions(+), 36 deletions(-) diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index 18573bc..7cae130 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -169,6 +169,10 @@ void AnticheatMgr::TeleportPlaneHackDetection(Player* player, MovementInfo movem if (movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_SWIMMING)) return; + // If he is flying we dont need to check + if (movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_FLYING)) + return; + float pos_z = player->GetPositionZ(); float ground_Z = player->GetFloorZ(); float z_diff = fabs(ground_Z - pos_z); @@ -187,55 +191,65 @@ void AnticheatMgr::TeleportPlaneHackDetection(Player* player, MovementInfo movem } } -void AnticheatMgr::IgnoreControlHackDetection(Player* player, MovementInfo movementInfo) +void AnticheatMgr::IgnoreControlHackDetection(Player* player, MovementInfo movementInfo, uint32 opcode) { float x, y; player->GetPosition(x, y); ObjectGuid key = player->GetGUID(); - if (sConfigMgr->GetOption("Anticheat.IgnoreControlHack", true)) + if (!sConfigMgr->GetOption("Anticheat.IgnoreControlHack", true)) + return; + + if (m_Players[key].GetLastOpcode() == MSG_MOVE_JUMP) + return; + + if (opcode == (MSG_MOVE_FALL_LAND)) + return; + + if (movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_SWIMMING)) + return; + + uint32 latency = 0; + latency = player->GetSession()->GetLatency() >= 400; + if (player->HasUnitState(UNIT_STATE_ROOT) && !player->GetVehicle() && !latency) { - uint32 latency = 0; - latency = player->GetSession()->GetLatency() >= 400; - if (player->HasUnitState(UNIT_STATE_ROOT) && !player->GetVehicle() && !latency) + bool unrestricted = movementInfo.pos.GetPositionX() != x || movementInfo.pos.GetPositionY() != y; + if (unrestricted) { - bool unrestricted = movementInfo.pos.GetPositionX() != x || movementInfo.pos.GetPositionY() != y; - if (unrestricted) + if (m_Players[key].GetTotalReports() > sConfigMgr->GetOption("Anticheat.ReportsForIngameWarnings", 70)) { - if (m_Players[key].GetTotalReports() > sConfigMgr->GetOption("Anticheat.ReportsForIngameWarnings", 70)) - { - _alertFrequency = sConfigMgr->GetOption("Anticheat.AlertFrequency", 5); - // So we dont divide by 0 by accident - if (_alertFrequency < 1) - _alertFrequency = 1; - if (++_counter % _alertFrequency == 0) - { - // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + std::string(player->GetName().c_str()) + "|cFF00FFFF] Possible Ignore Control Hack Detected!"; - WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); - data << str; - sWorld->SendGlobalGMMessage(&data); - uint32 latency = 0; - latency = player->GetSession()->GetLatency(); - // need better way to limit chat spam - if (m_Players[key].GetTotalReports() >= sConfigMgr->GetOption("Anticheat.ReportinChat.Min", 70) && m_Players[key].GetTotalReports() <= sConfigMgr->GetOption("Anticheat.ReportinChat.Max", 80)) - { - sWorld->SendGMText(LANG_ANTICHEAT_IGNORECONTROL, player->GetName().c_str(), latency); - } - _counter = 0; - } - } - if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) + _alertFrequency = sConfigMgr->GetOption("Anticheat.AlertFrequency", 5); + // So we dont divide by 0 by accident + if (_alertFrequency < 1) + _alertFrequency = 1; + if (++_counter % _alertFrequency == 0) { + // display warning at the center of the screen, hacky way? + std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + std::string(player->GetName().c_str()) + "|cFF00FFFF] Possible Ignore Control Hack Detected!"; + WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); + data << str; + sWorld->SendGlobalGMMessage(&data); uint32 latency = 0; latency = player->GetSession()->GetLatency(); - LOG_INFO("module", "AnticheatMgr:: Ignore Control - Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); + // need better way to limit chat spam + if (m_Players[key].GetTotalReports() >= sConfigMgr->GetOption("Anticheat.ReportinChat.Min", 70) && m_Players[key].GetTotalReports() <= sConfigMgr->GetOption("Anticheat.ReportinChat.Max", 80)) + { + sWorld->SendGMText(LANG_ANTICHEAT_IGNORECONTROL, player->GetName().c_str(), latency); + } + _counter = 0; } - - BuildReport(player, IGNORE_CONTROL_REPORT); } + if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) + { + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Ignore Control - Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); + } + + BuildReport(player, IGNORE_CONTROL_REPORT); } } + } void AnticheatMgr::ZAxisHackDetection(Player* player, MovementInfo movementInfo) @@ -413,7 +427,7 @@ void AnticheatMgr::StartHackDetection(Player* player, MovementInfo movementInfo, TeleportPlaneHackDetection(player, movementInfo, opcode); ClimbHackDetection(player, movementInfo, opcode); TeleportHackDetection(player, movementInfo); - IgnoreControlHackDetection(player, movementInfo); + IgnoreControlHackDetection(player, movementInfo, opcode); GravityHackDetection(player, movementInfo); if (player->GetLiquidData().Status == LIQUID_MAP_WATER_WALK) { diff --git a/src/AnticheatMgr.h b/src/AnticheatMgr.h index 534280b..0821a13 100644 --- a/src/AnticheatMgr.h +++ b/src/AnticheatMgr.h @@ -80,7 +80,7 @@ class AnticheatMgr void ClimbHackDetection(Player* player,MovementInfo movementInfo, uint32 opcode); void AntiSwimHackDetection(Player* player, MovementInfo movementInfo, uint32 opcode); void TeleportHackDetection(Player* player, MovementInfo movementInfo); - void IgnoreControlHackDetection(Player* player, MovementInfo movementInfo); + void IgnoreControlHackDetection(Player* player, MovementInfo movementInfo, uint32 opcode); void ZAxisHackDetection(Player* player, MovementInfo movementInfo); void GravityHackDetection(Player* player, MovementInfo movementInfo); void BuildReport(Player* player,uint16 reportType);