Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 22.15 KB | None | 0 0
  1. diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp
  2. --- a/src/server/game/Chat/Chat.cpp
  3. +++ b/src/server/game/Chat/Chat.cpp
  4. @@ -690,6 +690,15 @@
  5.          { NULL,             0,                  false, NULL,                                                "", NULL }
  6.      };
  7.  
  8. +    static ChatCommand anticheatCommandTable[] =
  9. +    {
  10. +        { "global",         SEC_ADMINISTRATOR,     false,  &ChatHandler::HandleAntiCheatGlobalCommand,         "", NULL },
  11. +        { "player",         SEC_ADMINISTRATOR,     false,  &ChatHandler::HandleAntiCheatPlayerCommand,         "", NULL },
  12. +        { "delete",         SEC_ADMINISTRATOR,     false,  &ChatHandler::HandleAntiCheatDeleteCommand,         "", NULL },
  13. +        { "handle",         SEC_ADMINISTRATOR,     false,  &ChatHandler::HandleAntiCheatHandleCommand,         "", NULL },
  14. +        { NULL,             0,                     false, NULL,                                           "", NULL }
  15. +    };
  16. +
  17.      static ChatCommand commandTable[] =
  18.      {
  19.          { "account",        SEC_PLAYER,         true,  NULL,                                           "", accountCommandTable  },
  20. diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h
  21. --- a/src/server/game/Chat/Chat.h
  22. +++ b/src/server/game/Chat/Chat.h
  23. @@ -601,6 +601,12 @@
  24.          bool HandleTempGameObjectCommand(const char* args);
  25.          bool HandleTempAddSpwCommand(const char* args);
  26.  
  27. +        // ANTICHEAT
  28. +        bool HandleAntiCheatGlobalCommand(const char* args); // top3 : Amount || Average || (Amount && Average)
  29. +        bool HandleAntiCheatPlayerCommand(const char* args); // returns especific player's average and amount
  30. +        bool HandleAntiCheatDeleteCommand(const char* args); // if no player name as parameter, deletes all logs else deletes specific player's log
  31. +        bool HandleAntiCheatHandleCommand(const char* args); // turn it on, turn it off
  32. +
  33.          //! Development Commands
  34.  
  35. diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp
  36. --- a/src/server/game/Chat/Commands/Level3.cpp
  37. +++ b/src/server/game/Chat/Commands/Level3.cpp
  38. @@ -7195,6 +7195,180 @@
  39.      return true;
  40.  }
  41.  
  42. +bool ChatHandler::HandleAntiCheatDeleteCommand(const char *args)
  43. +{
  44. +    std::string strCommand;
  45. +
  46. +    char* command = strtok((char*)args, " "); //get entered name
  47. +
  48. +    if (!command)
  49. +        return true;
  50. +    
  51. +    strCommand = command;
  52. +    
  53. +    if (strCommand.compare("deleteall") == 0)
  54. +    {
  55. +        uint8 uiStmt[3] = {"DELETE FROM cheat_first_report","DELETE FROM cheat_temp_reports", "DELETE FROM cheat_reports" };
  56. +        for (uint8 uiI = 0; uiI < 3; uiI++)
  57. +        {
  58. +             stmt = CharacterDatabase.Execute(uiStmt[uiI]);
  59. +            CharacterDatabase.Execute(stmt);
  60. +        }
  61. +
  62. +    } else
  63. +    {
  64. +        normalizePlayerName(strCommand);
  65. +        Player* pPlayer = sObjectMgr.GetPlayer(strCommand.c_str()); //get player by name
  66. +
  67. +        if (!pPlayer)
  68. +            PSendSysMessage("Player doesn't exist");
  69. +        else
  70. +        {
  71. +            uint8 uiStmt[3] = {"DELETE FROM cheat_reports WHERE guid=?", "DELETE FROM cheat_temp_reports WHERE guid=?","DELETE FROM cheat_first_report WHERE guid=?"};
  72. +
  73. +            for (uint8 uiI = 0; uiI < 3; uiI++)
  74. +            {
  75. +                 stmt = CharacterDatabase.Execute(uiStmt[uiI]);
  76. +                stmt->setUInt64(0, pPlayer->GetGUIDLow());
  77. +                CharacterDatabase.Execute(stmt);
  78. +            }
  79. +        }
  80. +    }
  81. +
  82. +    return true;
  83. +}
  84. +
  85. +bool ChatHandler::HandleAntiCheatPlayerCommand(const char *args)
  86. +{
  87. +    std::string strCommand;
  88. +
  89. +    char* command = strtok((char*)args, " ");
  90. +
  91. +    uint32 uiGUID = 0;
  92. +    Player* pPlayer = NULL;
  93. +    
  94. +    if (command)
  95. +    {
  96. +        strCommand = command;
  97. +
  98. +        normalizePlayerName(strCommand);
  99. +
  100. +        pPlayer = sObjectMgr.GetPlayer(strCommand.c_str()); //get player by name
  101. +
  102. +        if (pPlayer)
  103. +            uiGUID = pPlayer->GetGUIDLow();
  104. +    }else
  105. +    {
  106. +        pPlayer = getSelectedPlayer();
  107. +        if (pPlayer)
  108. +            uiGUID = pPlayer->GetGUIDLow();  
  109. +    }
  110. +
  111. +    if (uiGUID == 0)
  112. +    {
  113. +        PSendSysMessage("There is no player.");
  114. +        return true;
  115. +    }
  116. +    
  117. +    stmt = CharacterDatabase.Execute("SELECT count( * ) AS 'Repeticiones' FROM `characters` AS A, `cheat_reports` AS B WHERE A.`online` =1 AND A.`guid` = B.`guid` AND A.`guid`=? GROUP BY B.`guid` ORDER BY Repeticiones DESC LIMIT 0 , 1");
  118. +    stmt->setUInt32(0,uiGUID);
  119. +    QueryResult result = CharacterDatabase.Query(stmt);
  120. +
  121. +    if (result)
  122. +    {
  123. +        do
  124. +        {
  125. +            Field* fields=result->Fetch();
  126. +            uint32 warnings = fields[0].GetUInt32();
  127. +            PSendSysMessage("Amount: %u", warnings);
  128. +        }
  129. +        while (result->NextRow());
  130. +    } else
  131. +        PSendSysMessage("Player's amount log is empty!.");
  132. +
  133. +    stmt = CharacterDatabase.Execute("SELECT CAST((SUM(B.time ) / count( * ) ) - C.time AS UNSIGNED) AS 'promedio' , CAST(count( * ) AS UNSIGNED) AS 'Repeticiones' FROM `characters` AS A, `cheat_temp_reports` AS B, cheat_first_report AS C WHERE A.`online` =1 AND A.`guid` = B.`guid` AND A.guid = C.guid AND A.`guid`=? GROUP BY B.`guid` ORDER BY Repeticiones  DESC LIMIT 0 , 1;");
  134. +    stmt->setUInt32(0,uiGUID);
  135. +    result = CharacterDatabase.Query(stmt);
  136. +
  137. +    if (result)
  138. +    {
  139. +        do
  140. +        {
  141. +            Field* fields=result->Fetch();
  142. +            uint32 average = fields[0].GetUInt32();
  143. +            uint32 warnings = fields[1].GetUInt32();
  144. +
  145. +            PSendSysMessage("Average: %u Warnings: %u", average, warnings);
  146. +        }
  147. +        while (result->NextRow());
  148. +    } else
  149. +        PSendSysMessage("Player's average log is empty!.");
  150. +
  151. +    return true;
  152. +}
  153. +
  154. +bool ChatHandler::HandleAntiCheatHandleCommand(const char *args)
  155. +{
  156. +    std::string strCommand;
  157. +
  158. +    char* command = strtok((char*)args, " ");
  159. +    
  160. +    if (!command)
  161. +        return true;
  162. +
  163. +    strCommand = command;
  164. +
  165. +    if (strCommand.compare("on") == 0)
  166. +        sWorld.setBoolConfig(CONFIG_ANTICHEAT_ENABLE,true);
  167. +    else if (strCommand.compare("off") == 0)
  168. +        sWorld.setBoolConfig(CONFIG_ANTICHEAT_ENABLE,false);
  169. +
  170. +    return true;
  171. +}
  172. +
  173. +bool ChatHandler::HandleAntiCheatGlobalCommand(const char *args)
  174. +{
  175. +     stmt = CharacterDatabase.Execute("SELECT A.`name` , count( * ) AS 'Repeticiones' FROM `characters` AS A, `cheat_reports` AS B WHERE A.`online` =1 AND A.`guid` = B.`guid` GROUP BY B.`guid` ORDER BY Repeticiones DESC LIMIT 0 , 3");
  176. +    QueryResult result = CharacterDatabase.Query(stmt);
  177. +
  178. +    PSendSysMessage("Cheaters by Amount: -------------");
  179. +    if (result)
  180. +    {
  181. +        do
  182. +        {
  183. +            Field* fields=result->Fetch();
  184. +            std::string name = fields[0].GetCString();
  185. +            uint32 warnings = fields[1].GetUInt32();
  186. +
  187. +            PSendSysMessage("Name: %s Warnings: %u", name.c_str(), warnings);
  188. +        }
  189. +        while (result->NextRow());
  190. +    } else
  191. +        PSendSysMessage("Cheaters amount log empty!.");
  192. +
  193. +    PSendSysMessage("Cheaters by Average: -------------");
  194. +
  195. +    stmt = CharacterDatabase.Execute("SELECT A.`name` , CAST((SUM(B.time ) / count( * ) ) - C.time AS UNSIGNED) AS 'promedio' , CAST(count( * ) AS UNSIGNED) AS 'Repeticiones' FROM `characters` AS A, `cheat_temp_reports` AS B, cheat_first_report AS C WHERE A.`online` =1 AND A.`guid` = B.`guid` AND A.guid = C.guid GROUP BY B.`guid` ORDER BY Repeticiones  DESC LIMIT 0 , 3;");
  196. +    result = CharacterDatabase.Query(stmt);
  197. +
  198. +    if (result)
  199. +    {
  200. +        do
  201. +        {
  202. +            Field* fields=result->Fetch();
  203. +            std::string name = fields[0].GetCString();
  204. +            uint32 average = fields[1].GetUInt32();
  205. +            uint32 warnings = fields[2].GetUInt32();
  206. +
  207. +            PSendSysMessage("Name: %s  Average: %u Warnings: %u", name.c_str(), average, warnings);
  208. +        }
  209. +        while (result->NextRow());
  210. +    } else
  211. +        PSendSysMessage("Cheaters average log empty!.");
  212. +
  213. +    return true;
  214. +}
  215. +
  216.  bool ChatHandler::HandleFreezeCommand(const char *args)
  217.  {
  218.      std::string name;
  219. diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
  220. --- a/src/server/game/Entities/Player/Player.cpp
  221. +++ b/src/server/game/Entities/Player/Player.cpp
  222. @@ -619,6 +619,10 @@
  223.  
  224.  Player::~Player ()
  225.  {
  226. +    // anticheat
  227. +    if (sWorld.getBoolConfig(CONFIG_ANTICHEAT_ENABLE))
  228. +        CleanTempCheatReports();
  229. +
  230.      // it must be unloaded already in PlayerLogout and accessed only for loggined player
  231.      //m_social = NULL;
  232.  
  233. @@ -654,6 +658,89 @@
  234.      sWorld.DecreasePlayerCount();
  235.  }
  236.  
  237. +bool Player::HasFirstReport()
  238. +{
  239. +     stmt = CharacterDatabase.Execute("SELECT * FROM cheat_first_report WHERE guid=?;");
  240. +    stmt->setUInt64(0,GetGUIDLow());
  241. +
  242. +    QueryResult result = CharacterDatabase.Query(stmt);
  243. +
  244. +    if (result)
  245. +        return true;
  246. +    else
  247. +        return false;
  248. +}
  249. +
  250. +void Player::CleanTempCheatReports()
  251. +{
  252. +    for (uint8 uiI = 0; uiI < 2; uiI++)
  253. +    {
  254. +         stmt;
  255. +
  256. +        if (uiI == 0)
  257. +            stmt = CharacterDatabase.Execute( "DELETE FROM cheat_first_report WHERE guid=?");
  258. +        else
  259. +            stmt = CharacterDatabase.Execute("DELETE FROM cheat_temp_reports WHERE guid=?");
  260. +
  261. +        stmt->setUInt64(0,GetGUIDLow());
  262. +        CharacterDatabase.Execute(stmt);
  263. +    }
  264. +}
  265. +
  266. +void Player::ElaborateCheatReport(Player* pPlayer, uint8 uiCheatType)
  267. +{
  268. +    if (!pPlayer)
  269. +        return;
  270. +
  271. +    // cheatType 1 == SpeedHack
  272. +    // cheatType 2 == FlyHack
  273. +
  274. +    std::string strReportType;
  275. +
  276. +    switch(uiCheatType)
  277. +    {
  278. +    case 1:
  279. +        strReportType = "Speed-Hack";
  280. +        break;
  281. +    case 2:
  282. +        strReportType = "Fly-Hack";
  283. +        break;
  284. +    default:
  285. +        strReportType = "";
  286. +        break;
  287. +    }
  288. +
  289. +    if (!HasFirstReport())
  290. +    {
  291. +        stmt = CharacterDatabase.Execute("INSERT INTO cheat_first_report (`guid`,`name`,`time`) VALUES (?,?,?);");
  292. +        stmt->setUInt64(0,GetGUIDLow());
  293. +        stmt->setString(1,GetName());
  294. +        stmt->setUInt64(2, uint64(time(NULL)));
  295. +        CharacterDatabase.Execute(stmt);
  296. +    }
  297. +    
  298. +    for (uint8 uiI = 0; uiI < 2; uiI++)
  299. +    {
  300. +         stmt;
  301. +
  302. +        if (uiI == 0)
  303. +            stmt = CharacterDatabase.Execute("INSERT INTO cheat_reports (`guid`,`name`,`mapid`,`position_x`,`position_y`,`position_z`,`report`,`time`) VALUES (?,?,?,?,?,?,?,?);");
  304. +        else
  305. +            stmt = CharacterDatabase.Execute("INSERT INTO cheat_temp_reports (`guid`,`name`,`mapid`,`position_x`,`position_y`,`position_z`,`report`,`time`) VALUES (?,?,?,?,?,?,?,?);");
  306. +
  307. +        stmt->setUInt64(0,GetGUIDLow());
  308. +        stmt->setString(1,GetName());
  309. +        stmt->setUInt32(2,GetMapId());
  310. +        stmt->setFloat(3,GetPositionX());
  311. +        stmt->setFloat(4,GetPositionY());
  312. +        stmt->setFloat(5,GetPositionZ());
  313. +        stmt->setString(6,strReportType);
  314. +        stmt->setUInt64(7, uint64(time(NULL)));
  315. +        CharacterDatabase.Execute(stmt);
  316. +    }
  317. +
  318. +}
  319. +
  320.  void Player::CleanupsBeforeDelete(bool finalCleanup)
  321.  {
  322.      TradeCancel(false);
  323. @@ -19862,6 +19949,24 @@
  324.      }
  325.  }
  326.  
  327. +bool Player::CanFlyAnticheat(MovementInfo& pMovementInfo)
  328. +{
  329. +    if (IsUnderWater())
  330. +        return false;
  331. +
  332. +    if (HasAuraType(SPELL_AURA_FLY) || HasAuraType(SPELL_AURA_WATER_WALK) || HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) || HasAuraType(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED))
  333. +        return false;
  334. +
  335. +    if (Creature* pCreature = GetVehicleCreatureBase())
  336. +        if (pCreature->GetCreatureInfo()->InhabitType & INHABIT_AIR)
  337. +            return false;
  338. +
  339. +    if (HasUnitMovementFlag(MOVEMENTFLAG_JUMPING) ||  pMovementInfo.HasMovementFlag(MOVEMENTFLAG_JUMPING) || GetMap()->GetGameObject(pMovementInfo.t_guid))
  340. +        return false;
  341. +
  342. +    return true;
  343. +}
  344. +
  345.  void Player::UpdatePvPState(bool onlyFFA)
  346.  {
  347.      // TODO: should we always synchronize UNIT_FIELD_BYTES_2, 1 of controller and controlled?
  348. diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
  349. --- a/src/server/game/Entities/Player/Player.h
  350. +++ b/src/server/game/Entities/Player/Player.h
  351. @@ -2375,6 +2375,19 @@
  352.  
  353.          float GetAverageItemLevel();
  354.  
  355. +        /*********************************************************/
  356. +        /***                 ANTICHEAT SYSTEM                  ***/
  357. +        /*********************************************************/
  358. +        uint32 GetLastPacketTime() { return uiLastPacketTime;}
  359. +        uint32 GetLastOpcode() { return uiLastOpcode; }
  360. +        float GetLastSpeedRate() { return fLastSpeedRate; }
  361. +        void SetLastPacketTime(uint32 uiTime) { uiLastPacketTime = uiTime; }
  362. +        void SetLastSpeedRate(float fSpeedRateRate) { fLastSpeedRate = fSpeedRateRate; }
  363. +        void SetLastOpcode(uint32 uiOpcode) { uiLastOpcode = uiOpcode; }
  364. +        void ElaborateCheatReport(Player* pPlayer, uint8 uiReportType);
  365. +        bool CanFlyAnticheat(MovementInfo& pMovementInfo);
  366. +        bool HasFirstReport();
  367. +        void CleanTempCheatReports();
  368.      protected:
  369.          uint32 m_AreaID;
  370.          uint32 m_regenTimerCount;
  371. @@ -2615,6 +2628,13 @@
  372.          Runes *m_runes;
  373.          EquipmentSets m_EquipmentSets;
  374.      private:
  375. +        /*********************************************************/
  376. +        /***                    ANTICHEAT SYSTEM               ***/
  377. +        /*********************************************************/
  378. +        uint32  uiLastPacketTime;
  379. +        float fLastSpeedRate;
  380. +        uint32 uiLastOpcode;
  381. +
  382.          // internal common parts for CanStore/StoreItem functions
  383.          uint8 _CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool swap, Item *pSrcItem) const;
  384.          uint8 _CanStoreItem_InBag(uint8 bag, ItemPosCountVec& dest, ItemPrototype const *pProto, uint32& count, bool merge, bool non_specialized, Item *pSrcItem, uint8 skip_bag, uint8 skip_slot) const;
  385. diff --git a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp
  386. --- a/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp
  387. +++ b/src/server/game/Server/Protocol/Handlers/MovementHandler.cpp
  388. @@ -348,6 +348,100 @@
  389.      }
  390.  
  391.      /*----------------------*/
  392. +    
  393. +    // ANTICHEAT CHECKS
  394. +    if (sWorld.getBoolConfig(CONFIG_ANTICHEAT_ENABLE))
  395. +    {
  396. +        if (plMover &&
  397. +            !plMover->isInFlight() &&
  398. +            !plMover->GetTransport() &&
  399. +            !plMover->IsBeingTeleported() &&
  400. +            plMover->CanFreeMove() &&
  401. +            !plMover->isGameMaster())
  402. +        {
  403. +            // fly hack detection
  404. +            // PosZ is checked to see if the player is going up when it should not.
  405. +            if (plMover->CanFlyAnticheat(movementInfo))
  406. +            {
  407. +                if (movementInfo.pos.GetPositionZ() > plMover->GetPositionZ() && fabs(movementInfo.pos.GetPositionZ() - plMover->GetPositionZ()) > 1.5f)
  408. +                {
  409. +                    float ground_Z = plMover->GetMap()->GetHeight(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ());
  410. +                    if (movementInfo.pos.GetPositionZ() > ground_Z && fabs(movementInfo.pos.GetPositionZ() - ground_Z) >= 5.0f)
  411. +                        plMover->ElaborateCheatReport(plMover,2);
  412. +                }
  413. +            }
  414. +
  415. +            if (plMover->GetLastPacketTime() > 0 &&
  416. +                movementInfo.GetMovementFlags() == plMover->GetUnitMovementFlags() &&
  417. +                opcode == MSG_MOVE_HEARTBEAT &&
  418. +                plMover->GetLastOpcode() == opcode &&
  419. +                !plMover->GetVehicle() &&
  420. +                plMover->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE)
  421. +            {
  422. +                uint8 uiMoveType = 0;
  423. +
  424. +                if (plMover->IsFlying())
  425. +                    uiMoveType = MOVE_FLIGHT;
  426. +                else if (plMover->IsUnderWater())
  427. +                    uiMoveType = MOVE_SWIM;
  428. +                else
  429. +                    uiMoveType = MOVE_RUN;
  430. +
  431. +                // this is the distance doable by a player in 1000 ms.
  432. +                float fSpeedRate = plMover->GetSpeedRate(UnitMoveType(uiMoveType));
  433. +
  434. +                // in my opinion this var must be constant in each check to avoid false reports
  435. +                if (plMover->GetLastSpeedRate() == fSpeedRate)
  436. +                {
  437. +                    // Calculate Distance2D
  438. +                    float fDeltaX = pow((movementInfo.pos.GetPositionX() - plMover->GetPositionX()),2);
  439. +                    float fDeltaY = pow(movementInfo.pos.GetPositionY() - plMover->GetPositionY(),2);
  440. +                    // final distance
  441. +                    float fDistance2d = fabs(sqrt(fDeltaX + fDeltaY) - plMover->GetObjectSize() - plMover->GetObjectSize());
  442. +
  443. +                    // time between packets
  444. +                    uint32 uiDiffTime =  getMSTimeDiff(plMover->GetLastPacketTime(), movementInfo.time);
  445. +                    
  446. +                    // this is the distance doable by the player in 1 sec using the time between the packets
  447. +                    float fCoreDistance = uiDiffTime * 7.0f * fSpeedRate / 1000;
  448. +
  449. +                    /* SPEED HACK DETECTION */
  450. +                    if (uiDiffTime < sWorld.getIntConfig(CONFIG_ANTICHEAT_MAX_DIFF_TIME) && uiDiffTime > sWorld.getIntConfig(CONFIG_ANTICHEAT_MIN_DIFF_TIME))
  451. +                    {
  452. +                        // some times (i dont know why) fCoreDistance is 0
  453. +                        if (fCoreDistance > 0.0f && fDistance2d > 0)
  454. +                        {
  455. +                            if (fDistance2d > fCoreDistance)
  456. +                            {
  457. +                                if (fabs(fCoreDistance - fDistance2d) > sWorld.getFloatConfig(CONFIG_ANTICHEAT_MAX_DISTANCE_DIFF_ALLOWED))
  458. +                                {
  459. +                                    sLog.outError("Cheater! guid %u name %s fCoreDistance %f fDistance2d %f uiDiffTime %u fSpeedRate %f Latency %u",plMover->GetGUIDLow(),plMover->GetName(),fCoreDistance,fDistance2d,uiDiffTime,fSpeedRate, plMover->GetSession()->GetLatency());
  460. +                                    plMover->ElaborateCheatReport(plMover,1);
  461. +                                }
  462. +                            }
  463. +                        }
  464. +                    }
  465. +                }
  466. +            }
  467. +        }
  468. +
  469. +        // save packet time for next control.
  470. +        if (plMover)
  471. +        {
  472. +            uint8 uiMoveType = 0;
  473. +
  474. +            if (plMover->IsFlying())
  475. +                uiMoveType = MOVE_FLIGHT;
  476. +            else if (plMover->IsUnderWater())
  477. +                uiMoveType = MOVE_SWIM;
  478. +            else
  479. +                uiMoveType = MOVE_RUN;
  480. +
  481. +            plMover->SetLastPacketTime(movementInfo.time);
  482. +            plMover->SetLastSpeedRate(plMover->GetSpeedRate(UnitMoveType(uiMoveType)));
  483. +            plMover->SetLastOpcode(opcode);
  484. +        }
  485. +    }
  486.  
  487.      /* process position-change */
  488.      WorldPacket data(opcode, recv_data.size());
  489. diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
  490. --- a/src/server/game/World/World.cpp
  491. +++ b/src/server/game/World/World.cpp
  492. @@ -1222,6 +1222,12 @@
  493.      m_int_configs[CONFIG_AUTOBROADCAST_CENTER] = sConfig.GetIntDefault("AutoBroadcast.Center", 0);
  494.      m_int_configs[CONFIG_AUTOBROADCAST_INTERVAL] = sConfig.GetIntDefault("AutoBroadcast.Timer", 60000);
  495.  
  496. +    // anticheat configs
  497. +    m_bool_configs[CONFIG_ANTICHEAT_ENABLE] = sConfig.GetBoolDefault("Anticheat.Enable", false);
  498. +       m_int_configs[CONFIG_ANTICHEAT_MAX_DIFF_TIME] = sConfig.GetIntDefault("Anticheat.MaxDiffTime", 1000);
  499. +       m_int_configs[CONFIG_ANTICHEAT_MIN_DIFF_TIME] = sConfig.GetIntDefault("Anticheat.MinDiffTime", 50);
  500. +    m_float_configs[CONFIG_ANTICHEAT_MAX_DISTANCE_DIFF_ALLOWED] = sConfig.GetFloatDefault("Anticheat.MaxMaxAllowedDistance",1.0f);
  501. +
  502.      sScriptMgr.OnConfigLoad(reload);
  503.  }
  504.  
  505. @@ -2597,6 +2603,10 @@
  506.      for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
  507.          if (itr->second->GetPlayer())
  508.              itr->second->GetPlayer()->ResetDailyQuestStatus();
  509. +
  510. +    //ANTICHEAT
  511. +    CharacterDatabase.Execute("DELETE FROM cheat_reports;");
  512. +    CharacterDatabase.Execute("DELETE FROM cheat_first_report;");
  513.  }
  514.  
  515.  void World::LoadDBAllowedSecurityLevel()
  516. diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
  517. --- a/src/server/game/World/World.h
  518. +++ b/src/server/game/World/World.h
  519. @@ -163,6 +163,7 @@
  520.      CONFIG_CHATLOG_BGROUND,
  521.      CONFIG_DUNGEON_FINDER_ENABLE,
  522.      CONFIG_AUTOBROADCAST,
  523. +    CONFIG_ANTICHEAT_ENABLE,
  524.      BOOL_CONFIG_VALUE_COUNT
  525.  };
  526.  
  527. @@ -179,6 +180,7 @@
  528.      CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS,
  529.      CONFIG_THREAT_RADIUS,
  530.      CONFIG_CHANCE_OF_GM_SURVEY,
  531. +    CONFIG_ANTICHEAT_MAX_DISTANCE_DIFF_ALLOWED,
  532.      FLOAT_CONFIG_VALUE_COUNT
  533.  };
  534.  
  535. @@ -307,6 +309,8 @@
  536.      CONFIG_AUTOBROADCAST_CENTER,
  537.      CONFIG_AUTOBROADCAST_INTERVAL,
  538.      CONFIG_MAX_RESULTS_LOOKUP_COMMANDS,
  539. +       CONFIG_ANTICHEAT_MAX_DIFF_TIME,
  540. +       CONFIG_ANTICHEAT_MIN_DIFF_TIME,
  541.      INT_CONFIG_VALUE_COUNT
  542.  };
  543.  
  544. diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
  545. --- a/src/server/worldserver/worldserver.conf.dist
  546. +++ b/src/server/worldserver/worldserver.conf.dist
  547. @@ -2069,6 +2069,16 @@
  548.  #        Default: 0 - off
  549.  #                 1 - on
  550.  #
  551. +#   Anticheat.Enable
  552. +#        Enable Anticheat System
  553. +#        Default: 0 - off
  554. +#                 1 - on
  555. +#   Anticheat.MaxDiffTime
  556. +#        Default: 1000 ms
  557. +#   Anticheat.MinDiffTime
  558. +#        Default: 350 ms
  559. +#   Anticheat.MaxMaxAllowedDistance
  560. +#          Default: 1.0 f
  561.  ###############################################################################
  562.  
  563.  PlayerStart.AllReputation = 0
  564. @@ -2092,3 +2102,7 @@
  565.  LevelReq.Auction = 1
  566.  LevelReq.Mail = 1
  567.  DungeonFinder.Enable = 0
  568. +Anticheat.Enable = 0
  569. +Anticheat.MaxDiffTime = 1000
  570. +Anticheat.MinDiffTime = 50
  571. +Anticheat.MaxMaxAllowedDistance = 1.0
  572. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement