From d873545ac70331a224967493f9296a854d292dd8 Mon Sep 17 00:00:00 2001 From: Ekdohibs Date: Mon, 30 Jan 2017 07:58:43 +0100 Subject: Fix anticheat resetting client position after the client is teleported Previously, m_move_pool could accomodate the client moving from the new position to the old one, and the server accepted the client to go back to its old position. However, it couldn't then accomodate the client moving from its old to its new position, and therefore would reset position to the old position. Thus, by emptying m_move_pool after a teleport, the server no longer accepts the client to go back to its old position. A drawback is however that a laggy client *will* trigger a few "moved_too_fast" anticheats before being told about its new position. Don't report player cheated if caused by lag. Fixes #5118 --- src/content_sao.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/content_sao.h') diff --git a/src/content_sao.h b/src/content_sao.h index bbf244742..1ccea0d78 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -157,18 +157,26 @@ class LagPool public: LagPool(): m_pool(15), m_max(15) {} + void setMax(float new_max) { m_max = new_max; if(m_pool > new_max) m_pool = new_max; } + void add(float dtime) { m_pool -= dtime; if(m_pool < 0) m_pool = 0; } + + void empty() + { + m_pool = m_max; + } + bool grab(float dtime) { if(dtime <= 0) @@ -358,6 +366,7 @@ private: LagPool m_dig_pool; LagPool m_move_pool; v3f m_last_good_position; + float m_time_from_last_teleport; float m_time_from_last_punch; v3s16 m_nocheat_dig_pos; float m_nocheat_dig_time; -- cgit v1.2.3