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