Skip to content

Commit

Permalink
进一步简化和优化
Browse files Browse the repository at this point in the history
  • Loading branch information
kissingers committed Aug 25, 2024
1 parent aca650c commit e8fa2fe
Showing 1 changed file with 4 additions and 118 deletions.
122 changes: 4 additions & 118 deletions src/AnticheatMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,50 +367,15 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
if (m_Players[key].GetLastMapId() != player->GetMapId())
return;

//例外部分光环,111为LUA传送和特定技能后用,8326为死亡释放后自带,1953为闪现,36554为暗影步,51690为杀戮盛宴
if (player->HasAura(111) || player->HasAura(8326) || player->HasAura(1953) || player->HasAura(36554) || player->HasAura(51690))
//例外部分光环,111为LUA传送和特定技能后用,8326为死亡释放后自带
if (player->HasAura(111) || player->HasAura(8326))
return;

// We also must check the map because the movementFlag can be modified by the client.
// If we just check the flag, they could always add that flag and always skip the speed hacking detection.

if (m_Players[key].GetLastMovementInfo().HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
{
switch (player->GetMapId())
{
case 369: //Transport: DEEPRUN TRAM
case 607: //Transport: Strands of the Ancients
case 582: //Transport: Rut'theran to Auberdine
case 584: //Transport: Menethil to Theramore
case 586: //Transport: Exodar to Auberdine
case 587: //Transport: Feathermoon Ferry
case 588: //Transport: Menethil to Auberdine
case 589: //Transport: Orgrimmar to Grom'Gol
case 590: //Transport: Grom'Gol to Undercity
case 591: //Transport: Undercity to Orgrimmar
case 592: //Transport: Borean Tundra Test
case 593: //Transport: Booty Bay to Ratchet
case 594: //Transport: Howling Fjord Sister Mercy (Quest)
case 596: //Transport: Naglfar
case 610: //Transport: Tirisfal to Vengeance Landing
case 612: //Transport: Menethil to Valgarde
case 613: //Transport: Orgrimmar to Warsong Hold
case 614: //Transport: Stormwind to Valiance Keep
case 620: //Transport: Moa'ki to Unu'pe
case 621: //Transport: Moa'ki to Kamagua
case 622: //Transport: Orgrim's Hammer
case 623: //Transport: The Skybreaker
case 641: //Transport: Alliance Airship BG
case 642: //Transport: Horde Airship BG
case 647: //Transport: Orgrimmar to Thunder Bluff
case 672: //Transport: The Skybreaker (Icecrown Citadel Raid)
case 673: //Transport: Orgrim's Hammer (Icecrown Citadel Raid)
case 712: //Transport: The Skybreaker (IC Dungeon)
case 713: //Transport: Orgrim's Hammer (IC Dungeon)
case 718: //Transport: The Mighty Wind (Icecrown Citadel Raid)
return;
}
}
return;

float distance2D = movementInfo.pos.GetExactDist2d(&m_Players[key].GetLastMovementInfo().pos);

Expand All @@ -422,61 +387,7 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
// how long the player took to move to here.
uint32 timeDiff = getMSTimeDiff(m_Players[key].GetLastMovementInfo().time, movementInfo.time);

float speedRate = GetPlayerCurrentSpeedRate(player);
if (timeDiff <= ALLOWED_ACK_LAG)
speedRate = std::max(speedRate, m_Players[key].GetLastSpeedRate()); // The player might have been moving with a previously faster speed. This should help mitigate a false positive from loosing a speed increase buff.

if (int32(timeDiff) < 0 && sConfigMgr->GetOption<bool>("Anticheat.CM.TIMEMANIPULATION", true))
{
if (sConfigMgr->GetOption<bool>("Anticheat.CM.WriteLog", true))
{
uint32 latency = player->GetSession()->GetLatency();
std::string goXYZ = ".go xyz " + std::to_string(player->GetPositionX()) + " " + std::to_string(player->GetPositionY()) + " " + std::to_string(player->GetPositionZ() + 1.0f) + " " + std::to_string(player->GetMap()->GetId()) + " " + std::to_string(player->GetOrientation());
LOG_INFO("anticheat.module", "AnticheatMgr:: Time Manipulation - Hack detected player {} ({}) - Latency: {} ms - IP: {} - Cheat Flagged At: {}", player->GetName(), player->GetGUID().ToString(), latency, player->GetSession()->GetRemoteAddress().c_str(), goXYZ);
}
if (sConfigMgr->GetOption<bool>("Anticheat.CM.WriteLog", true))
{
std::string goXYZ = ".go xyz " + std::to_string(player->GetPositionX()) + " " + std::to_string(player->GetPositionY()) + " " + std::to_string(player->GetPositionZ() + 1.0f) + " " + std::to_string(player->GetMap()->GetId()) + " " + std::to_string(player->GetOrientation());
LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} Time Diff Corrected (Map: {}) (possible Out of Order Time Manipulation) - Flagged at: {}", player->GetName(), player->GetMapId(), goXYZ);
}
if (sConfigMgr->GetOption<bool>("Anticheat.CM.ALERTSCREEN", true))
{
SendMiddleScreenGMMessage("|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] TIME MANIPULATION COUNTER MEASURE ALERT");
}
if (sConfigMgr->GetOption<bool>("Anticheat.CM.ALERTCHAT", true))
{
const char* str = "|cFFFFFC00 TIME MANIPULATION COUNTER MEASURE ALERT";
DoToAllGMs([&](Player* p)
{
ChatHandler(p->GetSession()).PSendModuleSysMessage(modulestring, LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName(), player->GetName());
});
}
timeDiff = 1;
BuildReport(player, COUNTER_MEASURES_REPORT, movementInfo);
}

if (!timeDiff && sConfigMgr->GetOption<bool>("Anticheat.CM.TIMEMANIPULATION", true))
{
if (sConfigMgr->GetOption<bool>("Anticheat.WriteLog", true))
{
std::string goXYZ = ".go xyz " + std::to_string(player->GetPositionX()) + " " + std::to_string(player->GetPositionY()) + " " + std::to_string(player->GetPositionZ() + 1.0f) + " " + std::to_string(player->GetMap()->GetId()) + " " + std::to_string(player->GetOrientation());
LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} Time Diff Corrected (Map: {}) (possible Zero Time Manipulation) - Flagged at: {}", player->GetName(), player->GetMapId(), goXYZ);
}
if (sConfigMgr->GetOption<bool>("Anticheat.CM.ALERTSCREEN", true))
{
SendMiddleScreenGMMessage("|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] TIME MANIPULATION COUNTER MEASURE ALERT");
}
if (sConfigMgr->GetOption<bool>("Anticheat.CM.ALERTCHAT", true))
{
const char* str = "|cFFFFFC00 TIME MANIPULATION COUNTER MEASURE ALERT";
DoToAllGMs([&](Player* p)
{
ChatHandler(p->GetSession()).PSendModuleSysMessage(modulestring, LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName(), player->GetName());
});
}
timeDiff = 1;
BuildReport(player, COUNTER_MEASURES_REPORT, movementInfo);
}
float speedRate = std::max(GetPlayerCurrentSpeedRate(player), m_Players[key].GetLastSpeedRate()); // The player might have been moving with a previously faster speed. This should help mitigate a false positive from loosing a speed increase buff.

// this is the distance doable by the player in 1 sec, using the time done to move to this point.
float clientSpeedRate = 0.0f;
Expand Down Expand Up @@ -504,31 +415,6 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
std::string goXYZ = ".go xyz " + std::to_string(player->GetPositionX()) + " " + std::to_string(player->GetPositionY()) + " " + std::to_string(player->GetPositionZ() + 1.0f) + " " + std::to_string(player->GetMap()->GetId()) + " " + std::to_string(player->GetOrientation());
LOG_INFO("anticheat.module", "AnticheatMgr:: Speed-Hack (Speed Movement at {}% above allowed Server Set rate {}%.) detected player {} ({}) - Latency: {} ms - IP: {} - Cheat Flagged At: {}", clientSpeedRate, speedRate, player->GetName(), player->GetGUID().ToString(), latency, player->GetSession()->GetRemoteAddress().c_str(), goXYZ);
}
if (sConfigMgr->GetOption<bool>("Anticheat.CM.SPEEDHACK", true))
{
if (Aura* slowcheater = player->AddAura(SLOWDOWN, player))
{
slowcheater->SetDuration(1000);
}
if (sConfigMgr->GetOption<bool>("Anticheat.CM.WriteLog", true))
{
std::string goXYZ = ".go xyz " + std::to_string(player->GetPositionX()) + " " + std::to_string(player->GetPositionY()) + " " + std::to_string(player->GetPositionZ() + 1.0f) + " " + std::to_string(player->GetMap()->GetId()) + " " + std::to_string(player->GetOrientation());
LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} Speed Hack Countered and has been set to Server Rate - Flagged at: {}", player->GetName(), goXYZ);
}
if (sConfigMgr->GetOption<bool>("Anticheat.CM.ALERTSCREEN", true))
{
SendMiddleScreenGMMessage("|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] SPEED COUNTER MEASURE ALERT");
}
if (sConfigMgr->GetOption<bool>("Anticheat.CM.ALERTCHAT", true))
{
const char* str = "|cFFFFFC00 SPEED HACK COUNTER MEASURE ALERT";
DoToAllGMs([&](Player* p)
{
ChatHandler(p->GetSession()).PSendModuleSysMessage(modulestring, LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName(), player->GetName());
});
}
BuildReport(player, COUNTER_MEASURES_REPORT, movementInfo);
}
std::string str = "|cFFFFFC00 SPEED HACK Speed " + std::to_string(clientSpeedRate) + ", and current allow Speed " + std::to_string(speedRate) + ", and time " + std::to_string(timeDiff);
DoToAllGMs([&](Player* p)
{
Expand Down

0 comments on commit e8fa2fe

Please sign in to comment.