mirror of
https://github.com/azerothcore/mod-anticheat.git
synced 2026-01-13 00:58:35 +00:00
tracks last map id (#123)
This commit is contained in:
@@ -45,10 +45,11 @@ AnticheatData::~AnticheatData()
|
||||
{
|
||||
}
|
||||
|
||||
void AnticheatData::SetLastInformations(MovementInfo movementInfo, uint32 opcode, float speedRate)
|
||||
void AnticheatData::SetLastInformations(MovementInfo movementInfo, uint32 opcode, uint32 mapId, float speedRate)
|
||||
{
|
||||
SetLastMovementInfo(movementInfo);
|
||||
SetLastOpcode(opcode);
|
||||
SetLastMapId(mapId);
|
||||
SetLastSpeedRate(speedRate);
|
||||
}
|
||||
|
||||
@@ -67,9 +68,10 @@ void AnticheatData::SetLastOpcode(uint32 opcode)
|
||||
lastOpcode = opcode;
|
||||
}
|
||||
|
||||
void AnticheatData::SetPosition(float x, float y, float z, float o)
|
||||
void AnticheatData::SetPosition(float x, float y, float z, float o, uint32 mapId)
|
||||
{
|
||||
lastMovementInfo.pos = { x, y, z, o };
|
||||
SetLastMapId(mapId);
|
||||
}
|
||||
|
||||
uint32 AnticheatData::GetLastOpcode() const
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
AnticheatData();
|
||||
~AnticheatData();
|
||||
|
||||
void SetLastInformations(MovementInfo movementInfo, uint32 opcode, float speedRate);
|
||||
void SetLastInformations(MovementInfo movementInfo, uint32 opcode, uint32 mapId, float speedRate);
|
||||
|
||||
void SetLastOpcode(uint32 opcode);
|
||||
uint32 GetLastOpcode() const;
|
||||
@@ -43,10 +43,13 @@ public:
|
||||
const MovementInfo& GetLastMovementInfo() const;
|
||||
void SetLastMovementInfo(MovementInfo& moveInfo);
|
||||
|
||||
[[nodiscard]] uint32 GetLastMapId() const { return lastMapId; }
|
||||
void SetLastMapId(float mapId) { lastMapId = mapId; }
|
||||
|
||||
[[nodiscard]] float GetLastSpeedRate() const { return lastSpeedRate; }
|
||||
void SetLastSpeedRate(float speedRate) { lastSpeedRate = speedRate; }
|
||||
|
||||
void SetPosition(float x, float y, float z, float o);
|
||||
void SetPosition(float x, float y, float z, float o, uint32 mapId);
|
||||
|
||||
uint32 GetTotalReports() const;
|
||||
void SetTotalReports(uint32 _totalReports);
|
||||
@@ -74,6 +77,7 @@ public:
|
||||
private:
|
||||
uint32 lastOpcode;
|
||||
MovementInfo lastMovementInfo;
|
||||
uint32 lastMapId;
|
||||
float lastSpeedRate;
|
||||
uint32 totalReports;
|
||||
uint32 typeReports[MAX_REPORT_TYPES];
|
||||
|
||||
@@ -100,7 +100,7 @@ void AnticheatMgr::StartHackDetection(Player* player, MovementInfo movementInfo,
|
||||
|
||||
if (player->IsInFlight() || player->GetTransport() || player->GetVehicle())
|
||||
{
|
||||
m_Players[key].SetLastInformations(movementInfo, opcode, GetPlayerCurrentSpeedRate(player));
|
||||
m_Players[key].SetLastInformations(movementInfo, opcode, player->GetMapId(), GetPlayerCurrentSpeedRate(player));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ void AnticheatMgr::StartHackDetection(Player* player, MovementInfo movementInfo,
|
||||
BGStartExploit(player, movementInfo);
|
||||
}
|
||||
}
|
||||
m_Players[key].SetLastInformations(movementInfo, opcode, GetPlayerCurrentSpeedRate(player));
|
||||
m_Players[key].SetLastInformations(movementInfo, opcode, player->GetMapId(), GetPlayerCurrentSpeedRate(player));
|
||||
}
|
||||
|
||||
void AnticheatMgr::SendMiddleScreenGMMessage(std::string str)
|
||||
@@ -376,10 +376,13 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo)
|
||||
|
||||
ObjectGuid key = player->GetGUID();
|
||||
|
||||
if (m_Players[key].GetLastMapId() != player->GetMapId())
|
||||
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) && player->GetMapId())
|
||||
if (m_Players[key].GetLastMovementInfo().HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
|
||||
{
|
||||
switch (player->GetMapId())
|
||||
{
|
||||
@@ -829,9 +832,6 @@ void AnticheatMgr::TeleportHackDetection(Player* player, MovementInfo movementIn
|
||||
|
||||
ObjectGuid key = player->GetGUID();
|
||||
|
||||
if (m_Players[key].GetLastMovementInfo().pos.GetPositionX() == movementInfo.pos.GetPositionX())
|
||||
return;
|
||||
|
||||
if (m_Players[key].GetLastOpcode() == MSG_DELAY_GHOST_TELEPORT)
|
||||
return;
|
||||
|
||||
@@ -851,7 +851,7 @@ void AnticheatMgr::TeleportHackDetection(Player* player, MovementInfo movementIn
|
||||
if (player->IsFalling() || (player->IsFalling() && player->IsMounted()))
|
||||
return;
|
||||
|
||||
if (m_Players[key].GetLastMovementInfo().HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT) && player->GetMapId())
|
||||
if (m_Players[key].GetLastMovementInfo().HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
|
||||
{
|
||||
switch (player->GetMapId())
|
||||
{
|
||||
@@ -1496,7 +1496,7 @@ void AnticheatMgr::HandlePlayerLogin(Player* player)
|
||||
// we must delete this to prevent errors in case of crash
|
||||
CharacterDatabase.Execute("DELETE FROM `players_reports_status` WHERE `guid` = {}", player->GetGUID().GetCounter());
|
||||
// we initialize the pos of lastMovementPosition var.
|
||||
m_Players[player->GetGUID()].SetPosition(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
|
||||
m_Players[player->GetGUID()].SetPosition(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation(), player->GetMapId());
|
||||
|
||||
if (CharacterDatabase.Query("SELECT 0 FROM `daily_players_reports` WHERE `guid` = {};", player->GetGUID().GetCounter()))
|
||||
m_Players[player->GetGUID()].SetDailyReportState(true);
|
||||
|
||||
@@ -111,8 +111,6 @@ class AnticheatMgr
|
||||
void AnticheatDeleteCommand(ObjectGuid guid);
|
||||
void AnticheatPurgeCommand(ChatHandler* handler);
|
||||
void ResetDailyReportStates();
|
||||
void SetMapId(uint32 MapID) { m_MapId = MapID; }
|
||||
[[nodiscard]] uint32 GetMapId() const { return m_MapId; }
|
||||
|
||||
private:
|
||||
void SpeedHackDetection(Player* player, MovementInfo movementInfo);
|
||||
@@ -144,7 +142,6 @@ class AnticheatMgr
|
||||
[[nodiscard]] float GetTeleportSkillDistanceInYards(Player* player) const;
|
||||
[[nodiscard]] float GetPlayerCurrentSpeedRate(Player* player) const;
|
||||
uint32 _updateCheckTimer = 4000;
|
||||
uint32 m_MapId;
|
||||
std::array<Position, PVP_TEAMS_COUNT> _startPosition;
|
||||
Position const* GetTeamStartPosition(TeamId teamId) const;
|
||||
AnticheatPlayersDataMap m_Players; ///< Player data
|
||||
|
||||
Reference in New Issue
Block a user