PageRenderTime 40ms CodeModel.GetById 10ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 1ms

/Anticheat/AC1_GmHelper_ModBy_Chaosua.patch

https://bitbucket.org/TCRC/patches/
Patch | 700 lines | 676 code | 24 blank | 0 comment | 0 complexity | 26854f7ad79eef63f4a785cb094e4da8 MD5 | raw file
  1# HG changeset patch
  2# User chaosua
  3# Date 1285943655 -10800
  4# Branch trunk
  5# Node ID 81349e70ea9699268ee27fca939c0508abb8c5a1
  6# Parent  2b5e6acda90f67094245335f8fc76e28d70d0c32
  7AC1 GM helper mod by ChaosUA
  8
  9diff -r 2b5e6acda90f -r 81349e70ea96 sql/AC1/characters_cheaters.sql
 10--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
 11+++ b/sql/AC1/characters_cheaters.sql	Fri Oct 01 17:34:15 2010 +0300
 12@@ -0,0 +1,19 @@
 13+CREATE TABLE `cheaters` (
 14+  `entry` bigint(20) NOT NULL auto_increment,
 15+  `player` varchar(30) NOT NULL,
 16+  `acctid` int(11) NOT NULL,
 17+  `reason` varchar(255) NOT NULL default 'unknown',
 18+  `speed` float NOT NULL default '0',
 19+  `Val1` float NOT NULL default '0',
 20+  `Val2` int(10) unsigned NOT NULL default '0',
 21+  `count` int(11) NOT NULL default '0',
 22+  `Map` smallint(5) NOT NULL default '-1',
 23+  `Pos` varchar(255) NOT NULL default '0',
 24+  `Level` mediumint(9) NOT NULL default '0',
 25+  `first_date` datetime NOT NULL,
 26+  `last_date` datetime NOT NULL,
 27+  `Op` varchar(255) NOT NULL default 'unknown',
 28+  PRIMARY KEY  (`entry`),
 29+  KEY `idx_Count` (`count`),
 30+  KEY `idx_Player` (`player`)
 31+) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;
 32\ No newline at end of file
 33diff -r 2b5e6acda90f -r 81349e70ea96 sql/AC1/world_trinity_string.sql
 34--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
 35+++ b/sql/AC1/world_trinity_string.sql	Fri Oct 01 17:34:15 2010 +0300
 36@@ -0,0 +1,1 @@
 37+REPLACE INTO `trinity_string` VALUES ('12000', 'Cheater DETECTED> %s  ID:( %u ) Reason> %s', null, null, null, null, null, null, null, 'ЧИТЕР обнаружен:> %s ID:( %u) Причина> %s');
 38\ No newline at end of file
 39diff -r 2b5e6acda90f -r 81349e70ea96 src/server/game/Chat/Commands/Level3.cpp
 40--- a/src/server/game/Chat/Commands/Level3.cpp	Fri Oct 01 15:13:23 2010 +0300
 41+++ b/src/server/game/Chat/Commands/Level3.cpp	Fri Oct 01 17:34:15 2010 +0300
 42@@ -6301,9 +6301,15 @@
 43 
 44     WorldPacket data(12);
 45     if (strncmp(args, "on", 3) == 0)
 46+    {
 47         data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
 48+        ((Player*)(target))->SetCanFly(true);
 49+    }
 50     else if (strncmp(args, "off", 4) == 0)
 51+    {
 52         data.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY);
 53+        ((Player*)(target))->SetCanFly(false);
 54+    }
 55     else
 56     {
 57         SendSysMessage(LANG_USE_BOL);
 58diff -r 2b5e6acda90f -r 81349e70ea96 src/server/game/Entities/Player/Player.cpp
 59--- a/src/server/game/Entities/Player/Player.cpp	Fri Oct 01 15:13:23 2010 +0300
 60+++ b/src/server/game/Entities/Player/Player.cpp	Fri Oct 01 17:34:15 2010 +0300
 61@@ -523,6 +523,17 @@
 62     rest_type=REST_TYPE_NO;
 63     ////////////////////Rest System/////////////////////
 64 
 65+    //movement anticheat
 66+    m_anti_lastmovetime = 0;   //last movement time
 67+    m_anti_NextLenCheck = 0;
 68+    m_anti_MovedLen = 0.0f;
 69+    m_anti_BeginFallZ = INVALID_HEIGHT;
 70+    m_anti_lastalarmtime = 0;    //last time when alarm generated
 71+    m_anti_alarmcount = 0;       //alarm counter
 72+    m_anti_TeleTime = 0;
 73+    m_CanFly=false;
 74+    /////////////////////////////////
 75+
 76     m_mailsLoaded = false;
 77     m_mailsUpdated = false;
 78     unReadMails = 0;
 79@@ -23100,7 +23111,9 @@
 80 void Player::HandleFall(MovementInfo const& movementInfo)
 81 {
 82     // calculate total z distance of the fall
 83-    float z_diff = m_lastFallZ - movementInfo.pos.GetPositionZ();
 84+    float z_diff = (m_lastFallZ >= m_anti_BeginFallZ ? m_lastFallZ : m_anti_BeginFallZ) - movementInfo.pos.GetPositionZ();
 85+    
 86+    m_anti_BeginFallZ=INVALID_HEIGHT;
 87     //sLog.outDebug("zDiff = %f", z_diff);
 88 
 89     //Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored
 90diff -r 2b5e6acda90f -r 81349e70ea96 src/server/game/Entities/Player/Player.h
 91--- a/src/server/game/Entities/Player/Player.h	Fri Oct 01 15:13:23 2010 +0300
 92+++ b/src/server/game/Entities/Player/Player.h	Fri Oct 01 17:34:15 2010 +0300
 93@@ -991,6 +991,21 @@
 94         explicit Player (WorldSession *session);
 95         ~Player ();
 96 
 97+        //movement anticheat
 98+        uint32 m_anti_lastmovetime;     //last movement time
 99+        float  m_anti_MovedLen;         //Length of traveled way
100+        uint32 m_anti_NextLenCheck;
101+        float  m_anti_BeginFallZ;    //alternative falling begin
102+        uint32 m_anti_lastalarmtime;    //last time when alarm generated
103+        uint32 m_anti_alarmcount;       //alarm counter
104+        uint32 m_anti_TeleTime;
105+        bool m_CanFly;
106+        uint32 Anti__GetLastTeleTime() const { return m_anti_TeleTime; }
107+        void Anti__SetLastTeleTime(uint32 TeleTime) { m_anti_TeleTime=TeleTime; }
108+        //bool CanFly() const { return HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); }
109+        bool CanFly() const { return m_CanFly;  }
110+        void SetCanFly(bool CanFly) { m_CanFly=CanFly; }
111+
112         void CleanupsBeforeDelete(bool finalCleanup = true);
113 
114         static UpdateMask updateVisualBits;
115diff -r 2b5e6acda90f -r 81349e70ea96 src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp
116--- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp	Fri Oct 01 15:13:23 2010 +0300
117+++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.cpp	Fri Oct 01 17:34:15 2010 +0300
118@@ -266,6 +266,7 @@
119     float y = 0;
120     float z = 0;
121     i_destinationHolder.GetLocationNow(player.GetBaseMap(), x, y, z);
122+    player.Anti__SetLastTeleTime(time(NULL));
123     player.SetPosition(x, y, z, player.GetOrientation());
124 
125 }
126diff -r 2b5e6acda90f -r 81349e70ea96 src/server/game/Server/Protocol/Handlers/MovementHandler.cpp
127--- a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp	Fri Oct 01 15:13:23 2010 +0300
128+++ b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp	Fri Oct 01 17:34:15 2010 +0300
129@@ -26,13 +26,194 @@
130 #include "Corpse.h"
131 #include "Player.h"
132 #include "Vehicle.h"
133-#include "SpellAuras.h"
134 #include "MapManager.h"
135 #include "Transport.h"
136 #include "Battleground.h"
137 #include "WaypointMovementGenerator.h"
138 #include "InstanceSaveMgr.h"
139 #include "ObjectMgr.h"
140+#include "World.h"
141+
142+//#define __ANTI_DEBUG__
143+
144+#ifdef __ANTI_DEBUG__
145+#include "Chat.h"
146+std::string FlagsToStr(const uint32 Flags)
147+{
148+    std::string Ret="";
149+    if(Flags==0)
150+    {
151+        Ret="None";
152+        return Ret;
153+    }
154+    
155+    if(Flags & MOVEMENTFLAG_FORWARD)
156+    {   Ret+="FW "; }
157+    if(Flags & MOVEMENTFLAG_BACKWARD)
158+    {   Ret+="BW "; }
159+    if(Flags & MOVEMENTFLAG_STRAFE_LEFT)
160+    {   Ret+="STL ";    }
161+    if(Flags & MOVEMENTFLAG_STRAFE_RIGHT)
162+    {   Ret+="STR ";    }
163+    if(Flags & MOVEMENTFLAG_LEFT)
164+    {   Ret+="LF "; }
165+    if(Flags & MOVEMENTFLAG_RIGHT)
166+    {   Ret+="RI "; }
167+    if(Flags & MOVEMENTFLAG_PITCH_UP)
168+    {   Ret+="PTUP ";   }
169+    if(Flags & MOVEMENTFLAG_PITCH_DOWN)
170+    {   Ret+="PTDW ";   }
171+    if(Flags & MOVEMENTFLAG_WALK_MODE)
172+    {   Ret+="WALK ";   }
173+    if(Flags & MOVEMENTFLAG_ONTRANSPORT)
174+    {   Ret+="TRANS ";  }
175+    if(Flags & MOVEMENTFLAG_LEVITATING)
176+    {   Ret+="LEVI ";   }
177+    if(Flags & MOVEMENTFLAG_FLY_UNK1)
178+    {   Ret+="FLYUNK1 ";    }
179+    if(Flags & MOVEMENTFLAG_JUMPING)
180+    {   Ret+="JUMP ";   }
181+    if(Flags & MOVEMENTFLAG_UNK4)
182+    {   Ret+="UNK4 ";   }
183+    if(Flags & MOVEMENTFLAG_FALLING)
184+    {   Ret+="FALL ";   }
185+    if(Flags & MOVEMENTFLAG_SWIMMING)
186+    {   Ret+="SWIM ";   }
187+    if(Flags & MOVEMENTFLAG_FLY_UP)
188+    {   Ret+="FLYUP ";  }
189+    if(Flags & MOVEMENTFLAG_CAN_FLY)
190+    {   Ret+="CFLY ";   }
191+    if(Flags & MOVEMENTFLAG_FLYING)
192+    {   Ret+="FLY ";    }
193+    if(Flags & MOVEMENTFLAG_FLYING2)
194+    {   Ret+="FLY2 ";   }
195+    if(Flags & MOVEMENTFLAG_WATERWALKING)
196+    {   Ret+="WTWALK "; }
197+    if(Flags & MOVEMENTFLAG_SAFE_FALL)
198+    {   Ret+="SAFE ";   }
199+    if(Flags & MOVEMENTFLAG_UNK3)
200+    {   Ret+="UNK3 ";   }
201+    if(Flags & MOVEMENTFLAG_SPLINE)
202+    {   Ret+="SPLINE ";     }
203+    if(Flags & MOVEMENTFLAG_SPLINE2)
204+    {   Ret+="SPLINE2 ";    }
205+    
206+    return Ret;
207+}
208+#endif // __ANTI_DEBUG__
209+
210+bool WorldSession::Anti__ReportCheat(const char* Reason,float Speed,const char* Op,float Val1,uint32 Val2,MovementInfo* MvInfo)
211+{
212+    if(!Reason)
213+    {
214+        sLog.outError("Anti__ReportCheat: Missing Reason parameter!");
215+        return false;
216+    }
217+    const char* Player=GetPlayer()->GetName();
218+    uint32 Acc=GetPlayer()->GetSession()->GetAccountId();
219+    uint32 Map=GetPlayer()->GetMapId();
220+    if(!Player)
221+    {
222+        sLog.outError("Anti__ReportCheat: Player with no name?!?");
223+        return false;
224+    }
225+
226+    QueryResult Res=CharacterDatabase.PQuery("SELECT speed,Val1 FROM cheaters WHERE player='%s' AND reason LIKE '%s' AND Map='%u' AND last_date >= NOW()-300",Player,Reason,Map);
227+    if(Res)
228+    {
229+        Field* Fields = Res->Fetch();
230+        
231+        std::stringstream Query;
232+        Query << "UPDATE cheaters SET count=count+1,last_date=NOW()";
233+        Query.precision(5);
234+        if(Speed>0.0f && Speed > Fields[0].GetFloat())
235+        {
236+            Query << ",speed='";
237+            Query << std::fixed << Speed;
238+            Query << "'";
239+        }
240+
241+        if(Val1>0.0f && Val1 > Fields[1].GetFloat())
242+        {
243+            Query << ",Val1='";
244+            Query << std::fixed << Val1;
245+            Query << "'";
246+        }
247+        
248+        Query << " WHERE player='" << Player << "' AND reason='" << Reason << "' AND Map='" << Map << "' AND last_date >= NOW()-300 ORDER BY entry DESC LIMIT 1";
249+        
250+        CharacterDatabase.Execute(Query.str().c_str());
251+        sWorld.SendGMText(12000,GetPlayer()->GetName(),GetPlayer()->GetGUIDLow(),Reason);
252+    }
253+    else
254+    {
255+        if(!Op)
256+        {   Op="";  }
257+        std::stringstream Pos;
258+        Pos << "OldPos: " << GetPlayer()->GetPositionX() << " " << GetPlayer()->GetPositionY() << " "
259+            << GetPlayer()->GetPositionZ();
260+        if(MvInfo)
261+        {
262+            Pos << "\nNew: " << MvInfo->pos.GetPositionX() << " " << MvInfo->pos.GetPositionY() << " " << MvInfo->pos.GetPositionZ() << "\n"
263+                << "Flags: " << MvInfo->flags << "\n"
264+                << "t_guid: " << MvInfo->t_guid << " falltime: " << MvInfo->fallTime;
265+        }
266+        CharacterDatabase.PExecute("INSERT INTO cheaters (player,acctid,reason,speed,count,first_date,last_date,`Op`,Val1,Val2,Map,Pos,Level) "
267+                                   "VALUES ('%s','%u','%s','%f','1',NOW(),NOW(),'%s','%f','%u','%u','%s','%u')",
268+                                   Player,Acc,Reason,Speed,Op,Val1,Val2,Map,
269+                                   Pos.str().c_str(),GetPlayer()->getLevel());
270+        sWorld.SendGMText(12000,GetPlayer()->GetName(),GetPlayer()->GetGUIDLow(),Reason);
271+    }
272+
273+    if(sWorld.GetMvAnticheatKill() && GetPlayer()->isAlive())
274+    {
275+        GetPlayer()->DealDamage(GetPlayer(), GetPlayer()->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
276+    }
277+    if(sWorld.GetMvAnticheatKick())
278+    {
279+        GetPlayer()->GetSession()->KickPlayer();
280+    }
281+    if(sWorld.GetMvAnticheatBan() & 1)
282+    {
283+        sWorld.BanAccount(BAN_CHARACTER,Player,sWorld.GetMvAnticheatBanTime(),"Cheat","Anticheat");
284+    }
285+    if(sWorld.GetMvAnticheatBan() & 2)
286+    {
287+        QueryResult result = LoginDatabase.PQuery("SELECT last_ip FROM account WHERE id=%u", Acc);
288+        if(result)
289+        {
290+
291+            Field *fields = result->Fetch();
292+            std::string LastIP = fields[0].GetCString();
293+            if(!LastIP.empty())
294+            {
295+                sWorld.BanAccount(BAN_IP,LastIP,sWorld.GetMvAnticheatBanTime(),"Cheat","Anticheat");
296+            }
297+        }
298+    }
299+    return true;
300+}
301+
302+bool WorldSession::Anti__CheatOccurred(uint32 CurTime,const char* Reason,float Speed,const char* Op,
303+                                float Val1,uint32 Val2,MovementInfo* MvInfo)
304+{
305+    if(!Reason)
306+    {
307+        sLog.outError("Anti__CheatOccurred: Missing Reason parameter!");
308+        return false;
309+    }
310+    
311+    GetPlayer()->m_anti_lastalarmtime = CurTime;
312+    GetPlayer()->m_anti_alarmcount = GetPlayer()->m_anti_alarmcount + 1;
313+
314+    if (GetPlayer()->m_anti_alarmcount > sWorld.GetMvAnticheatAlarmCount())
315+    {
316+        Anti__ReportCheat(Reason,Speed,Op,Val1,Val2,MvInfo);
317+        return true;
318+    }
319+    return false;
320+}
321+
322 
323 void WorldSession::HandleMoveWorldportAckOpcode(WorldPacket & /*recv_data*/)
324 {
325@@ -90,6 +271,8 @@
326     GetPlayer()->ResetMap();
327     GetPlayer()->SetMap(newMap);
328 
329+	GetPlayer()->m_anti_TeleTime=time(NULL);
330+	
331     GetPlayer()->SendInitialPacketsBeforeAddToMap();
332     if (!GetPlayer()->GetMap()->Add(GetPlayer()))
333     {
334@@ -186,6 +369,8 @@
335 
336     // resummon pet
337     GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();
338+    GetPlayer()->Anti__SetLastTeleTime(::time(NULL));
339+    GetPlayer()->m_anti_BeginFallZ=INVALID_HEIGHT;
340 
341     //lets process all delayed operations on successful teleport
342     GetPlayer()->ProcessDelayedOperations();
343@@ -238,6 +423,11 @@
344 
345     // resummon pet
346     GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();
347+    if(plMover)
348+    {
349+        plMover->Anti__SetLastTeleTime(::time(NULL));
350+        plMover->m_anti_BeginFallZ=INVALID_HEIGHT;
351+    }
352 
353     //lets process all delayed operations on successful teleport
354     GetPlayer()->ProcessDelayedOperations();
355@@ -303,6 +493,11 @@
356         // if we boarded a transport, add us to it
357         if (plMover && !plMover->GetTransport())
358         {
359+            float trans_rad = movementInfo.t_pos.GetPositionX()*movementInfo.t_pos.GetPositionX() + movementInfo.t_pos.GetPositionY()*movementInfo.t_pos.GetPositionY() + movementInfo.t_pos.GetPositionZ()*movementInfo.t_pos.GetPositionZ();
360+            if (trans_rad > 3600.0f) // transport radius = 60 yards //cheater with on_transport_flag
361+            {
362+	            return;
363+            }
364             // elevators also cause the client to send MOVEMENTFLAG_ONTRANSPORT - just unmount if the guid can be found in the transport list
365             for (MapManager::TransportSet::const_iterator iter = sMapMgr.m_Transports.begin(); iter != sMapMgr.m_Transports.end(); ++iter)
366             {
367@@ -339,9 +534,145 @@
368     {
369         // now client not include swimming flag in case jumping under water
370         plMover->SetInWater(!plMover->IsInWater() || plMover->GetBaseMap()->IsUnderWater(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ()));
371+        if(plMover->GetBaseMap()->IsUnderWater(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ()-7.0f))
372+        {
373+            plMover->m_anti_BeginFallZ=INVALID_HEIGHT;
374+        }
375     }
376 
377-    /*----------------------*/
378+    // ---- anti-cheat features -->>>
379+    uint32 Anti_TeleTimeDiff=plMover ? time(NULL) - plMover->Anti__GetLastTeleTime() : time(NULL);
380+    static const uint32 Anti_TeleTimeIgnoreDiff=sWorld.GetMvAnticheatIgnoreAfterTeleport();
381+    if (plMover && (plMover->m_transport == 0) && sWorld.GetMvAnticheatEnable() &&
382+        GetPlayer()->GetSession()->GetSecurity() <= sWorld.GetMvAnticheatGmLevel() &&
383+        GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()!=FLIGHT_MOTION_TYPE &&
384+        Anti_TeleTimeDiff>Anti_TeleTimeIgnoreDiff)
385+    {
386+        const uint32 CurTime=getMSTime();
387+        if(getMSTimeDiff(GetPlayer()->m_anti_lastalarmtime,CurTime) > sWorld.GetMvAnticheatAlarmPeriod())
388+        {
389+            GetPlayer()->m_anti_alarmcount = 0;
390+        }
391+        /* I really don't care about movement-type yet (todo)
392+        UnitMoveType move_type;
393+
394+        if (movementInfo.flags & MOVEMENTFLAG_FLYING) move_type = MOVE_FLY;
395+        else if (movementInfo.flags & MOVEMENTFLAG_SWIMMING) move_type = MOVE_SWIM;
396+        else if (movementInfo.flags & MOVEMENTFLAG_WALK_MODE) move_type = MOVE_WALK;
397+        else move_type = MOVE_RUN;*/
398+
399+        float delta_x = GetPlayer()->GetPositionX() - movementInfo.pos.GetPositionX();
400+        float delta_y = GetPlayer()->GetPositionY() - movementInfo.pos.GetPositionY();
401+        // float delta_z = GetPlayer()->GetPositionZ() - movementInfo.pos.GetPositionZ();
402+        float delta = sqrt(delta_x * delta_x + delta_y * delta_y); // Len of movement-vector via Pythagoras (a^2+b^2=Len^2)
403+        // float tg_z = 0.0f; //tangens
404+        float delta_t = getMSTimeDiff(GetPlayer()->m_anti_lastmovetime,CurTime);
405+        
406+		GetPlayer()->m_anti_lastmovetime = CurTime;
407+        GetPlayer()->m_anti_MovedLen += delta;
408+
409+        if(delta_t > 15000.0f)
410+        {   delta_t = 15000.0f;   }
411+
412+        // Tangens of walking angel
413+        /*if (!(movementInfo.flags & (MOVEMENTFLAG_FLYING | MOVEMENTFLAG_SWIMMING)))
414+        {
415+            //Mount hack detection currently disabled
416+            tg_z = ((delta !=0.0f) && (delta_z > 0.0f)) ? (atan((delta_z*delta_z) / delta) * 180.0f / M_PI) : 0.0f;
417+        }*/
418+
419+        //antiOFF fall-damage, MOVEMENTFLAG_FALLING seted by client if player try movement when falling and unset in this case the MOVEMENTFLAG_FALLING flag.
420+        
421+		if((GetPlayer()->m_anti_BeginFallZ == INVALID_HEIGHT) &&
422+           (movementInfo.flags & (MOVEMENTFLAG_FALLING | MOVEMENTFLAG_PENDING_STOP)) != 0)
423+        {
424+            GetPlayer()->m_anti_BeginFallZ=(float)(movementInfo.pos.GetPositionZ());
425+        }
426+
427+        if(GetPlayer()->m_anti_NextLenCheck <= CurTime)
428+        {
429+            // Check every 500ms is a lot more advisable then 1000ms, because normal movment packet arrives every 500ms
430+            uint32 OldNextLenCheck=GetPlayer()->m_anti_NextLenCheck;
431+            float delta_xyt=GetPlayer()->m_anti_MovedLen/(float)(getMSTimeDiff(OldNextLenCheck-500,CurTime));
432+            GetPlayer()->m_anti_NextLenCheck = CurTime+500;
433+            GetPlayer()->m_anti_MovedLen = 0.0f;
434+            static const float MaxDeltaXYT = sWorld.GetMvAnticheatMaxXYT();
435+
436+#ifdef __ANTI_DEBUG__
437+            SendAreaTriggerMessage("XYT: %f ; Flags: %s",delta_xyt,FlagsToStr(movementInfo.flags).c_str());
438+#endif //__ANTI_DEBUG__
439+            
440+			if(delta_xyt > MaxDeltaXYT && delta<=100.0f && GetPlayer()->GetZoneId() != 2257 && GetPlayer()->GetZoneId() != 3992 && GetPlayer()->GetZoneId() != 2618)
441+            {
442+                Anti__CheatOccurred(CurTime,"Speed hack",delta_xyt,LookupOpcodeName(opcode),
443+                                    (float)(GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType()),
444+                                    (float)(getMSTimeDiff(OldNextLenCheck-500,CurTime)),&movementInfo);
445+            }
446+        }
447+
448+        if(delta > 100.0f && GetPlayer()->GetZoneId() != 2257 && GetPlayer()->GetZoneId() != 3992 && GetPlayer()->GetZoneId() != 2618)
449+        {
450+            Anti__ReportCheat("Tele hack",delta,LookupOpcodeName(opcode));
451+        }
452+
453+        // Check for waterwalking
454+        if(((movementInfo.flags & MOVEMENTFLAG_WATERWALKING) != 0) &&
455+           ((movementInfo.flags ^ MOVEMENTFLAG_WATERWALKING) != 0) && // Client sometimes set waterwalk where it shouldn't do that...
456+           ((movementInfo.flags & MOVEMENTFLAG_JUMPING) == 0) &&
457+           GetPlayer()->GetBaseMap()->IsUnderWater(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ()-6.0f) &&
458+           !(GetPlayer()->HasAuraType(SPELL_AURA_WATER_WALK) || GetPlayer()->HasAuraType(SPELL_AURA_GHOST)))
459+        {
460+            Anti__CheatOccurred(CurTime,"Water walking",0.0f,NULL,0.0f,(uint32)(movementInfo.flags));
461+        }
462+        
463+        // Check for walking upwards a mountain while not beeing able to do that
464+        /*if ((tg_z > 85.0f))
465+        {
466+            Anti__CheatOccurred(CurTime,"Mount hack",tg_z,NULL,delta,delta_z);
467+        }
468+		*/
469+        
470+        static const float DIFF_OVERGROUND = 10.0f;
471+        float Anti__GroundZ = GetPlayer()->GetMap()->GetHeight(GetPlayer()->GetPositionX(),GetPlayer()->GetPositionY(),MAX_HEIGHT);
472+        float Anti__FloorZ  = GetPlayer()->GetMap()->GetHeight(GetPlayer()->GetPositionX(),GetPlayer()->GetPositionY(),GetPlayer()->GetPositionZ());
473+        float Anti__MapZ = ((Anti__FloorZ <= (INVALID_HEIGHT+5.0f)) ? Anti__GroundZ : Anti__FloorZ) + DIFF_OVERGROUND;
474+        
475+        if(!GetPlayer()->CanFly() &&
476+           !GetPlayer()->GetBaseMap()->IsUnderWater(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ()-7.0f) &&
477+           Anti__MapZ < GetPlayer()->GetPositionZ() && Anti__MapZ > (INVALID_HEIGHT+DIFF_OVERGROUND + 5.0f))
478+        {
479+     //       static const float DIFF_AIRJUMP=25.0f; // 25 is realy high, but to many false positives...
480+            
481+			// Air-Jump-Detection definitively needs a better way to be detected...
482+            if((movementInfo.flags & (MOVEMENTFLAG_CAN_FLY | MOVEMENTFLAG_DESCENDING | MOVEMENTFLAG_FLYING)) != 0) // Fly Hack
483+            {
484+                Anti__CheatOccurred(CurTime,"Fly hack",
485+                                    ((uint8)(GetPlayer()->HasAuraType(SPELL_AURA_FLY))) +
486+                                    ((uint8)(GetPlayer()->HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED))*2),
487+                                    NULL,GetPlayer()->GetPositionZ()-Anti__MapZ);
488+            }
489+            
490+			/* Need a better way to do that - currently a lot of fake alarms
491+            else if((Anti__MapZ+DIFF_AIRJUMP < GetPlayer()->GetPositionZ() &&
492+			         (movementInfo.flags & (MOVEMENTFLAG_FALLING | MOVEMENTFLAG_UNK4))==0) ||
493+					(Anti__MapZ < GetPlayer()->GetPositionZ() && 
494+					 opcode==MSG_MOVE_JUMP))
495+            {
496+                Anti__CheatOccurred(CurTime,"Possible Air Jump Hack",
497+                                    0.0f,LookupOpcodeName(opcode),0.0f,movementInfo.flags,&movementInfo);
498+            }*/
499+        }
500+
501+        /*
502+		if(Anti__FloorZ < -199900.0f && Anti__GroundZ >= -199900.0f &&
503+           GetPlayer()->GetPositionZ()+5.0f < Anti__GroundZ)
504+        {
505+            Anti__CheatOccurred(CurTime,"Teleport2Plane hack",
506+                                GetPlayer()->GetPositionZ(),NULL,Anti__GroundZ);
507+        }*/
508+    } 
509+	// <<---- anti-cheat features
510+
511 
512     /* process position-change */
513     WorldPacket data(opcode, recv_data.size());
514diff -r 2b5e6acda90f -r 81349e70ea96 src/server/game/Server/WorldSession.h
515--- a/src/server/game/Server/WorldSession.h	Fri Oct 01 15:13:23 2010 +0300
516+++ b/src/server/game/Server/WorldSession.h	Fri Oct 01 17:34:15 2010 +0300
517@@ -143,6 +143,10 @@
518         bool PlayerLogout() const { return m_playerLogout; }
519         bool PlayerLogoutWithSave() const { return m_playerLogout && m_playerSave; }
520 
521+        inline bool Anti__CheatOccurred(uint32 CurTime,const char* Reason,float Speed,const char* Op=NULL,
522+                                float Val1=0.0f,uint32 Val2=0,MovementInfo* MvInfo=NULL);
523+        bool Anti__ReportCheat(const char* Reason,float Speed,const char* Op=NULL,float Val1=0.0f,uint32 Val2=0,MovementInfo* MvInfo=NULL);
524+
525         void SizeError(WorldPacket const& packet, uint32 size) const;
526 
527         void ReadAddonsInfo(WorldPacket &data);
528diff -r 2b5e6acda90f -r 81349e70ea96 src/server/game/Spells/Auras/SpellAuraEffects.cpp
529--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp	Fri Oct 01 15:13:23 2010 +0300
530+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp	Fri Oct 01 17:34:15 2010 +0300
531@@ -3702,9 +3702,15 @@
532         // allow fly
533         WorldPacket data;
534         if (apply)
535+        {
536+            ((Player*)target)->SetCanFly(true);
537             data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
538+        }
539         else
540+        {
541             data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
542+            ((Player*)target)->SetCanFly(false);
543+        }
544         data.append(target->GetPackGUID());
545         data << uint32(0);                                      // unk
546         plr->SendDirectMessage(&data);
547@@ -4122,9 +4128,15 @@
548             {
549                 WorldPacket data;
550                 if (apply)
551+                {
552+                	  ((Player*)target)->SetCanFly(true);
553                     data.Initialize(SMSG_MOVE_SET_CAN_FLY, 12);
554+                }
555                 else
556+                {
557                     data.Initialize(SMSG_MOVE_UNSET_CAN_FLY, 12);
558+                    ((Player*)target)->SetCanFly(false);
559+                }
560                 data.append(plr->GetPackGUID());
561                 data << uint32(0);                                      // unknown
562                 plr->SendDirectMessage(&data);
563diff -r 2b5e6acda90f -r 81349e70ea96 src/server/game/World/World.cpp
564--- a/src/server/game/World/World.cpp	Fri Oct 01 15:13:23 2010 +0300
565+++ b/src/server/game/World/World.cpp	Fri Oct 01 17:34:15 2010 +0300
566@@ -561,6 +561,18 @@
567 
568     m_bool_configs[CONFIG_DURABILITY_LOSS_IN_PVP] = sConfig.GetBoolDefault("DurabilityLoss.InPvP", false);
569 
570+    // movement anticheat
571+    m_MvAnticheatEnable                     = sConfig.GetBoolDefault("Anticheat.Movement.Enable",false);
572+    m_MvAnticheatKick                       = sConfig.GetBoolDefault("Anticheat.Movement.Kick",false);
573+    m_MvAnticheatAlarmCount                 = (uint32)sConfig.GetIntDefault("Anticheat.Movement.AlarmCount", 5);
574+    m_MvAnticheatAlarmPeriod                = (uint32)sConfig.GetIntDefault("Anticheat.Movement.AlarmTime", 5000);
575+    m_MvAntiCheatBan                        = (unsigned char)sConfig.GetIntDefault("Anticheat.Movement.BanType",0);
576+    m_MvAnticheatBanTime                    = sConfig.GetStringDefault("Anticheat.Movement.BanTime","1m");
577+    m_MvAnticheatGmLevel                    = (unsigned char)sConfig.GetIntDefault("Anticheat.Movement.GmLevel",0);
578+    m_MvAnticheatKill                       = sConfig.GetBoolDefault("Anticheat.Movement.Kill",false);
579+    m_MvAnticheatMaxXYT                     = sConfig.GetFloatDefault("Anticheat.Movement.MaxXYT",0.04f);
580+    m_MvAnticheatIgnoreAfterTeleport        = (uint16)sConfig.GetIntDefault("Anticheat.Movement.IgnoreSecAfterTeleport",10);
581+
582     m_int_configs[CONFIG_COMPRESSION] = sConfig.GetIntDefault("Compression", 1);
583     if (m_int_configs[CONFIG_COMPRESSION] < 1 || m_int_configs[CONFIG_COMPRESSION] > 9)
584     {
585diff -r 2b5e6acda90f -r 81349e70ea96 src/server/game/World/World.h
586--- a/src/server/game/World/World.h	Fri Oct 01 15:13:23 2010 +0300
587+++ b/src/server/game/World/World.h	Fri Oct 01 17:34:15 2010 +0300
588@@ -736,6 +736,19 @@
589         uint32 m_WintergrapsTimer;
590         uint32 m_WintergrapsState;
591 
592+        //movement anticheat enable flag
593+        inline bool GetMvAnticheatEnable()             {return m_MvAnticheatEnable;}
594+        inline bool GetMvAnticheatKick()               {return m_MvAnticheatKick;}
595+        inline uint32 GetMvAnticheatAlarmCount()       {return m_MvAnticheatAlarmCount;}
596+        inline uint32 GetMvAnticheatAlarmPeriod()      {return m_MvAnticheatAlarmPeriod;}
597+        inline unsigned char GetMvAnticheatBan()       {return m_MvAntiCheatBan;}
598+        inline std::string GetMvAnticheatBanTime()     {return m_MvAnticheatBanTime;}
599+        inline unsigned char GetMvAnticheatGmLevel()   {return m_MvAnticheatGmLevel;}
600+        inline bool GetMvAnticheatKill()               {return m_MvAnticheatKill;}
601+        inline float GetMvAnticheatMaxXYT()            {return m_MvAnticheatMaxXYT;}
602+        inline uint16 GetMvAnticheatIgnoreAfterTeleport()   {return m_MvAnticheatIgnoreAfterTeleport;}
603+        
604+
605         void ProcessCliCommands();
606         void QueueCliCommand(CliCommandHolder* commandHolder) { cliCmdQueue.add(commandHolder); }
607 
608@@ -832,6 +845,19 @@
609         static int32 m_visibility_notify_periodInInstances;
610         static int32 m_visibility_notify_periodInBGArenas;
611 
612+        //movement anticheat enable flag
613+        bool m_MvAnticheatEnable;
614+        bool m_MvAnticheatKick;
615+        uint32 m_MvAnticheatAlarmCount;
616+        uint32 m_MvAnticheatAlarmPeriod;
617+        unsigned char m_MvAntiCheatBan;
618+        std::string m_MvAnticheatBanTime;
619+        unsigned char m_MvAnticheatGmLevel;
620+        bool m_MvAnticheatKill;
621+        float m_MvAnticheatMaxXYT;
622+        uint16 m_MvAnticheatIgnoreAfterTeleport;
623+
624+
625         // CLI command holder to be thread safe
626         ACE_Based::LockedQueue<CliCommandHolder*,ACE_Thread_Mutex> cliCmdQueue;
627 
628diff -r 2b5e6acda90f -r 81349e70ea96 src/server/worldserver/worldserver.conf.dist
629--- a/src/server/worldserver/worldserver.conf.dist	Fri Oct 01 15:13:23 2010 +0300
630+++ b/src/server/worldserver/worldserver.conf.dist	Fri Oct 01 17:34:15 2010 +0300
631@@ -1964,6 +1964,69 @@
632 CharDelete.KeepDays = 30
633 
634 ###############################################################################
635+# MOVEMENT ANTICHEAT
636+#
637+#    Anticheat.Movement.Enable
638+#        Enable Movement Anticheat
639+#        Default: 0 - off
640+#                 1 - on
641+#
642+#    Anticheat.Movement.AlarmCount
643+#        Count alarms. After AlarmCount is exceeded, actions are taken against
644+#        the player. (default 5)
645+#
646+#    Anticheat.Movement.AlarmTime
647+#        Reset alarm-count after this milliseconds. (default 5000)
648+#
649+#    Anticheat.Movement.Kill
650+#        Enable Kill cheater
651+#        Default: 0 - off
652+#                 1 - on
653+#
654+#    Anticheat.Movement.Kick
655+#        Enable Kick cheater
656+#        Default: 0 - off
657+#                 1 - on
658+#
659+#    Anticheat.Movement.BanType
660+#        Enable Ban cheater
661+#        Default: 0 - off
662+#                 1 - Ban Account
663+#                 2 - Ban IP
664+#                 3 - Ban Account + IP
665+#
666+#    Anticheat.Movement.BanTime
667+#        How long the ban should last.
668+#        Default: 1 Minute - 1m
669+#
670+#    Anticheat.Movement.MaxXYT
671+#        Max units a player is allowed to travel per millisecond.
672+#        Default: 0.04 (This is ~400% Speed, 0.007 is walk-speed,
673+#                 310% is 0.0287)
674+#
675+#    Anticheat.Movement.IgnoreSecAfterTeleport
676+#        After being teleported this number of seconds no cheat is reported.
677+#        Default: 10 seconds - 10
678+#
679+#    Anticheat.Movement.GmLevel
680+#        Only accounts that are below this gm-level or exact at the same,
681+#        are reported for cheating.
682+#        Default: Only normal Players - 0
683+#
684+###############################################################################
685+
686+Anticheat.Movement.Enable = 1
687+Anticheat.Movement.AlarmCount = 4
688+Anticheat.Movement.AlarmTime = 6000
689+Anticheat.Movement.Kill = 0
690+Anticheat.Movement.Kick = 0
691+Anticheat.Movement.BanType = 0
692+Anticheat.Movement.BanTime = "1m"
693+Anticheat.Movement.MaxXYT = 0.0330
694+Anticheat.Movement.IgnoreSecAfterTeleport = 10
695+Anticheat.Movement.GmLevel = 1
696+
697+###############################################################################
698 # CUSTOM SERVER OPTIONS
699 #
700 #    PlayerStart.AllReputation