Skip to content

Commit

Permalink
'- Antichetos Necesita una revision a fondo...'
Browse files Browse the repository at this point in the history
Signed-off-by: DarkTerror <DarkTerror@LaPosadaDelOcio.com>
  • Loading branch information
DarkTerror2 committed Nov 22, 2010
1 parent 7eeb1f7 commit b49b258
Show file tree
Hide file tree
Showing 10 changed files with 558 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/game/Language.h
Expand Up @@ -913,6 +913,7 @@ enum MangosStrings
// 10000-10999

// Use for custom patches 11000-11999
LANG_ANNOUNCE_CHEAT = 11000,

// NOT RESERVED IDS 12000-1999999999
// `db_script_string` table index 2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID)
Expand Down
347 changes: 347 additions & 0 deletions src/game/MovementHandler.cpp

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion src/game/Player.cpp
Expand Up @@ -531,6 +531,17 @@ Player::Player (WorldSession *session): Unit(), m_mover(this), m_camera(this), m
rest_type=REST_TYPE_NO;
////////////////////Rest System/////////////////////

//movement anticheat
m_anti_lastmovetime = 0; //last movement time
m_anti_NextLenCheck = 0;
m_anti_MovedLen = 0.0f;
m_anti_BeginFallZ = INVALID_HEIGHT;
m_anti_lastalarmtime = 0; //last time when alarm generated
m_anti_alarmcount = 0; //alarm counter
m_anti_TeleTime = 0;
m_CanFly=false;
/////////////////////////////////

m_mailsUpdated = false;
unReadMails = 0;
m_nextMailDelivereTime = 0;
Expand Down Expand Up @@ -21597,7 +21608,9 @@ uint8 Player::CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_s
void Player::HandleFall(MovementInfo const& movementInfo)
{
// calculate total z distance of the fall
float z_diff = m_lastFallZ - movementInfo.GetPos()->z;
float z_diff = (m_lastFallZ >= m_anti_BeginFallZ ? m_lastFallZ : m_anti_BeginFallZ) - movementInfo.GetPos()->z;

m_anti_BeginFallZ=INVALID_HEIGHT;
DEBUG_LOG("zDiff = %f", z_diff);

//Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored
Expand Down
16 changes: 15 additions & 1 deletion src/game/Player.h
Expand Up @@ -2260,7 +2260,11 @@ class MANGOS_DLL_SPEC Player : public Unit
bool isMoving() const { return m_movementInfo.HasMovementFlag(movementFlagsMask); }
bool isMovingOrTurning() const { return m_movementInfo.HasMovementFlag(movementOrTurningFlagsMask); }

bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_CAN_FLY); }
uint32 Anti__GetLastTeleTime() const { return m_anti_TeleTime; }
void Anti__SetLastTeleTime(uint32 TeleTime) { m_anti_TeleTime=TeleTime; }
//bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_CAN_FLY); }
bool CanFly() const { return m_CanFly; }
void SetCanFly(bool CanFly) { m_CanFly=CanFly; }
bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_FLYING); }
bool IsFreeFlying() const { return HasAuraType(SPELL_AURA_MOD_FLIGHT_SPEED_MOUNTED) || HasAuraType(SPELL_AURA_FLY); }
bool CanStartFlyInArea(uint32 mapid, uint32 zone, uint32 area) const;
Expand Down Expand Up @@ -2626,6 +2630,16 @@ class MANGOS_DLL_SPEC Player : public Unit
RestType rest_type;
////////////////////Rest System/////////////////////

//movement anticheat
uint32 m_anti_lastmovetime; //last movement time
float m_anti_MovedLen; //Length of traveled way
uint32 m_anti_NextLenCheck;
float m_anti_BeginFallZ; //alternative falling begin
uint32 m_anti_lastalarmtime; //last time when alarm generated
uint32 m_anti_alarmcount; //alarm counter
uint32 m_anti_TeleTime;
bool m_CanFly;

// Transports
// Transport * m_transport;

Expand Down
13 changes: 13 additions & 0 deletions src/game/SpellAuras.cpp
Expand Up @@ -4572,9 +4572,16 @@ void Aura::HandleAuraModIncreaseFlightSpeed(bool apply, bool Real)
{
WorldPacket data;
if(apply)
{
((Player*)target)->SetCanFly(true);
data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
}
else
{
data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
((Player*)target)->SetCanFly(false);
}
//data.append(target->GetPackGUID());
data << target->GetPackGUID();
data << uint32(0); // unknown
target->SendMessageToSet(&data, true);
Expand Down Expand Up @@ -6494,9 +6501,15 @@ void Aura::HandleAuraAllowFlight(bool apply, bool Real)
// allow fly
WorldPacket data;
if(apply)
{
((Player*)GetTarget())->SetCanFly(true);
data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
}
else
{
data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
((Player*)GetTarget())->SetCanFly(false);
}
data << GetTarget()->GetPackGUID();
data << uint32(0); // unk
GetTarget()->SendMessageToSet(&data, true);
Expand Down
1 change: 1 addition & 0 deletions src/game/WaypointMovementGenerator.cpp
Expand Up @@ -336,6 +336,7 @@ void FlightPathMovementGenerator::Finalize(Player & player)

float x, y, z;
i_destinationHolder.GetLocationNow(player.GetMap(), x, y, z);
player.Anti__SetLastTeleTime(time(NULL));
player.SetPosition(x, y, z, player.GetOrientation());

player.Unmount();
Expand Down
22 changes: 22 additions & 0 deletions src/game/World.cpp
Expand Up @@ -517,6 +517,28 @@ void World::LoadConfigSettings(bool reload)
setConfigPos(CONFIG_FLOAT_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS, "CreatureFamilyFleeAssistanceRadius", 30.0f);

///- Read other configuration items from the config file

// movement anticheat
m_MvAnticheatEnable = sConfig.GetBoolDefault("Anticheat.Movement.Enable",false);
m_MvAnticheatKick = sConfig.GetBoolDefault("Anticheat.Movement.Kick",false);
m_MvAnticheatAnnounce = sConfig.GetBoolDefault("Anticheat.Movement.Announce",false);
m_MvAnticheatAlarmCount = (uint32)sConfig.GetIntDefault("Anticheat.Movement.AlarmCount", 5);
m_MvAnticheatAlarmPeriod = (uint32)sConfig.GetIntDefault("Anticheat.Movement.AlarmTime", 5000);
m_MvAntiCheatBan = (unsigned char)sConfig.GetIntDefault("Anticheat.Movement.BanType",0);
m_MvAnticheatBanTime = sConfig.GetStringDefault("Anticheat.Movement.BanTime","1m");
m_MvAnticheatGmLevel = (unsigned char)sConfig.GetIntDefault("Anticheat.Movement.GmLevel",0);
m_MvAnticheatKill = sConfig.GetBoolDefault("Anticheat.Movement.Kill",false);
m_MvAnticheatMaxXYT = sConfig.GetFloatDefault("Anticheat.Movement.MaxXYT",0.04f);
m_MvAnticheatIgnoreAfterTeleport = (uint16)sConfig.GetIntDefault("Anticheat.Movement.IgnoreSecAfterTeleport",10);

m_MvAnticheatSpeedCheck = sConfig.GetBoolDefault("Anticheat.Movement.DetectSpeedHack",1);
m_MvAnticheatWaterCheck = sConfig.GetBoolDefault("Anticheat.Movement.DetectWaterWalk",1);
m_MvAnticheatFlyCheck = sConfig.GetBoolDefault("Anticheat.Movement.DetectFlyHack",1);
m_MvAnticheatMountainCheck = sConfig.GetBoolDefault("Anticheat.Movement.DetectMountainHack",1);
m_MvAnticheatJumpCheck = sConfig.GetBoolDefault("Anticheat.Movement.DetectAirJumpHack",1);
m_MvAnticheatTeleportCheck = sConfig.GetBoolDefault("Anticheat.Movement.DetectTeleportHack",1);
m_MvAnticheatTeleport2PlaneCheck = sConfig.GetBoolDefault("Anticheat.Movement.DetectTeleport2PlaneHack",0);

setConfigMinMax(CONFIG_UINT32_COMPRESSION, "Compression", 1, 1, 9);
setConfig(CONFIG_BOOL_ADDON_CHANNEL, "AddonChannel", true);
setConfig(CONFIG_BOOL_CLEAN_CHARACTER_DB, "CleanCharacterDB", true);
Expand Down
42 changes: 42 additions & 0 deletions src/game/World.h
Expand Up @@ -576,6 +576,28 @@ class World
static float GetVisibleUnitGreyDistance() { return m_VisibleUnitGreyDistance; }
static float GetVisibleObjectGreyDistance() { return m_VisibleObjectGreyDistance; }

//movement anticheat enable flag
inline bool GetMvAnticheatEnable() {return m_MvAnticheatEnable;}
inline bool GetMvAnticheatKick() {return m_MvAnticheatKick;}
inline bool GetMvAnticheatAnnounce() {return m_MvAnticheatAnnounce;}
inline uint32 GetMvAnticheatAlarmCount() {return m_MvAnticheatAlarmCount;}
inline uint32 GetMvAnticheatAlarmPeriod() {return m_MvAnticheatAlarmPeriod;}
inline unsigned char GetMvAnticheatBan() {return m_MvAntiCheatBan;}
inline std::string GetMvAnticheatBanTime() {return m_MvAnticheatBanTime;}
inline unsigned char GetMvAnticheatGmLevel() {return m_MvAnticheatGmLevel;}
inline bool GetMvAnticheatKill() {return m_MvAnticheatKill;}
inline float GetMvAnticheatMaxXYT() {return m_MvAnticheatMaxXYT;}
inline uint16 GetMvAnticheatIgnoreAfterTeleport() {return m_MvAnticheatIgnoreAfterTeleport;}

inline bool GetMvAnticheatSpeedCheck() {return m_MvAnticheatSpeedCheck;}
inline bool GetMvAnticheatWaterCheck() {return m_MvAnticheatWaterCheck;}
inline bool GetMvAnticheatFlyCheck() {return m_MvAnticheatFlyCheck;}
inline bool GetMvAnticheatMountainCheck() {return m_MvAnticheatMountainCheck;}
inline bool GetMvAnticheatJumpCheck() {return m_MvAnticheatJumpCheck;}
inline bool GetMvAnticheatTeleportCheck() {return m_MvAnticheatTeleportCheck;}
inline bool GetMvAnticheatTeleport2PlaneCheck() {return m_MvAnticheatTeleport2PlaneCheck;}


void ProcessCliCommands();
void QueueCliCommand(CliCommandHolder* commandHolder) { cliCmdQueue.add(commandHolder); }

Expand Down Expand Up @@ -672,6 +694,26 @@ class World
static float m_VisibleUnitGreyDistance;
static float m_VisibleObjectGreyDistance;

//movement anticheat enable flag
bool m_MvAnticheatEnable;
bool m_MvAnticheatKick;
bool m_MvAnticheatAnnounce;
uint32 m_MvAnticheatAlarmCount;
uint32 m_MvAnticheatAlarmPeriod;
unsigned char m_MvAntiCheatBan;
std::string m_MvAnticheatBanTime;
unsigned char m_MvAnticheatGmLevel;
bool m_MvAnticheatKill;
float m_MvAnticheatMaxXYT;
uint16 m_MvAnticheatIgnoreAfterTeleport;
bool m_MvAnticheatSpeedCheck;
bool m_MvAnticheatWaterCheck;
bool m_MvAnticheatFlyCheck;
bool m_MvAnticheatMountainCheck;
bool m_MvAnticheatJumpCheck;
bool m_MvAnticheatTeleportCheck;
bool m_MvAnticheatTeleport2PlaneCheck;

// CLI command holder to be thread safe
ACE_Based::LockedQueue<CliCommandHolder*,ACE_Thread_Mutex> cliCmdQueue;
SqlResultQueue *m_resultQueue;
Expand Down
3 changes: 3 additions & 0 deletions src/game/WorldSession.h
Expand Up @@ -155,6 +155,9 @@ class MANGOS_DLL_SPEC WorldSession
bool PlayerLogout() const { return m_playerLogout; }
bool PlayerLogoutWithSave() const { return m_playerLogout && m_playerSave; }

inline bool Anti__CheatOccurred(uint32 CurTime,const char* Reason,float Speed,const char* Op=NULL,float Val1=0.0f,uint32 Val2=0);
bool Anti__ReportCheat(const char* Reason,float Speed,const char* Op=NULL,float Val1=0.0f,uint32 Val2=0);

void SizeError(WorldPacket const& packet, uint32 size) const;

void ReadAddonsInfo(WorldPacket &data);
Expand Down
100 changes: 100 additions & 0 deletions src/mangosd/mangosd.conf.dist.in
Expand Up @@ -1645,6 +1645,106 @@ SOAP.Enabled = 0
SOAP.IP = 127.0.0.1
SOAP.Port = 7878

###################################################################################################################
# MOVEMENT ANTICHEAT
#
# Anticheat.Movement.Enable
# Enable Movement Anticheat
# Default: 0 - off
# 1 - on
#
# Anticheat.Movement.AlarmCount
# Count alarms. After AlarmCount is exceeded, actions are taken against the player. (default 5)
#
# Anticheat.Movement.AlarmTime
# Reset alarm-count after this milliseconds. (default 5000)
#
# Anticheat.Movement.Kill
# Enable Kill cheater
# Default: 0 - off
# 1 - on
#
# Anticheat.Movement.Kick
# Enable Kick cheater
# Default: 0 - off
# 1 - on
#
# Anticheat.Movement.BanType
# Enable Ban cheater
# Default: 0 - off
# 1 - Ban Account
# 2 - Ban IP
# 3 - Ban Account + IP
#
# Anticheat.Movement.Announce
# Enable Announce cheater
# Default: 0 - off
# 1 - on
#
# Anticheat.Movement.DetectSpeedHack
# Turn Speed Check on/off
# Default: 1 (on)
#
# Anticheat.Movement.DetectWaterWalk
# Turn WaterWalk Check on/off
# Default: 1 (on)
#
# Anticheat.Movement.DetectFlyHack
# Turn Fly Hack Check on/off
# Default: 1 (on)
#
# Anticheat.Movement.DetectMountainHack
# Turn Speed Check on/off
# Default: 1 (on)
# Anticheat.Movement.DetectAirJumpHack
# Turn Air/Graviti Jump Check on/off
# Default: 1 (on)
#
# Anticheat.Movement.DetectTeleportHack
# Turn Teleport Check on/off
# Default: 1 (on)
#
# Anticheat.Movement.DetectTeleport2PlaneHack
# Turn Teleport2Plane Check on/off
# Default: 1 (on)
#
# Anticheat.Movement.BanTime
# How long the ban should last.
# Default: 1 Minute - 1m
#
# Anticheat.Movement.MaxXYT
# Max units a player is allowed to travel per millisecond.
# Default: 0.04 (This is ~400% Speed, 0.007 is walk-speed, 310% is 0.0287)
#
# Anticheat.Movement.IgnoreSecAfterTeleport
# After being teleported this number of seconds no cheat is reported.
# Default: 10 seconds - 10
#
# Anticheat.Movement.GmLevel
# Only accounts that are below this gm-level or exact at the same, are reported for cheating.
# Default: Only normal Players - 0
#
###################################################################################################################

Anticheat.Movement.Enable = 1
Anticheat.Movement.AlarmCount = 5
Anticheat.Movement.AlarmTime = 5000
Anticheat.Movement.Kill = 0
Anticheat.Movement.Kick = 0
Anticheat.Movement.Announce = 0
Anticheat.Movement.DetectSpeedHack = 1
Anticheat.Movement.DetectWaterWalk = 1
Anticheat.Movement.DetectFlyHack = 1
Anticheat.Movement.DetectMountainHack = 1
Anticheat.Movement.DetectAirJumpHack = 1
Anticheat.Movement.DetectTeleportHack = 1
Anticheat.Movement.DetectTeleport2PlaneHack = 0
Anticheat.Movement.BanType = 0
Anticheat.Movement.BanTime = "1m"
Anticheat.Movement.MaxXYT = 0.04
Anticheat.Movement.IgnoreSecAfterTeleport = 10
Anticheat.Movement.GmLevel = 0

###################################################################################################################
# CharDelete.Method
# Character deletion behavior
Expand Down

0 comments on commit b49b258

Please sign in to comment.