summaryrefslogtreecommitdiff
path: root/src/content_sao.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2018-01-28 10:21:21 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2018-01-28 10:21:21 +0100
commitde2c40c8fc189eeeeba010a0aaa1d28aed588c68 (patch)
tree779f3a038dc48e276e7c193f38049371b7b39497 /src/content_sao.cpp
parent7d3295e21f96495cb0b3e2f732939344ce892e2a (diff)
downloadminetest-de2c40c8fc189eeeeba010a0aaa1d28aed588c68.tar.gz
minetest-de2c40c8fc189eeeeba010a0aaa1d28aed588c68.tar.bz2
minetest-de2c40c8fc189eeeeba010a0aaa1d28aed588c68.zip
Apply physics overrides correctly during anticheat calculations (#6970)
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r--src/content_sao.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 1fb74263b..2b9d53665 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -1401,26 +1401,29 @@ bool PlayerSAO::checkMovementCheat()
too, and much more lightweight.
*/
- float player_max_speed = 0;
+ float player_max_walk = 0; // horizontal movement
+ float player_max_jump = 0; // vertical upwards movement
- if (m_privs.count("fast") != 0) {
- // Fast speed
- player_max_speed = m_player->movement_speed_fast * m_physics_override_speed;
- } else {
- // Normal speed
- player_max_speed = m_player->movement_speed_walk * m_physics_override_speed;
- }
- // Tolerance. The lag pool does this a bit.
- //player_max_speed *= 2.5;
+ if (m_privs.count("fast") != 0)
+ player_max_walk = m_player->movement_speed_fast; // Fast speed
+ else
+ player_max_walk = m_player->movement_speed_walk; // Normal speed
+ player_max_walk *= m_physics_override_speed;
+ player_max_jump = m_player->movement_speed_jump * m_physics_override_jump;
+ // FIXME: Bouncy nodes cause practically unbound increase in Y speed,
+ // until this can be verified correctly, tolerate higher jumping speeds
+ player_max_jump *= 2.0;
v3f diff = (m_base_position - m_last_good_position);
float d_vert = diff.Y;
diff.Y = 0;
float d_horiz = diff.getLength();
- float required_time = d_horiz / player_max_speed;
+ float required_time = d_horiz / player_max_walk;
- if (d_vert > 0 && d_vert / player_max_speed > required_time)
- required_time = d_vert / player_max_speed; // Moving upwards
+ // FIXME: Checking downwards movement is not easily possible currently,
+ // the server could calculate speed differences to examine the gravity
+ if (d_vert > 0)
+ required_time = MYMAX(required_time, d_vert / player_max_jump);
if (m_move_pool.grab(required_time)) {
m_last_good_position = m_base_position;