diff options
author | sfan5 <sfan5@live.de> | 2018-02-02 23:34:09 +0100 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2018-02-02 23:34:09 +0100 |
commit | cf0bcebc7620ff2a4bfb44bcbc4909ff9dbe8d24 (patch) | |
tree | 488732fcae1f13053e6e9fbb9aaf45a0e3c23fd6 /src/content_sao.cpp | |
parent | 49b65a5593c981a4ebc587538923e267a22c2437 (diff) | |
download | minetest-cf0bcebc7620ff2a4bfb44bcbc4909ff9dbe8d24.tar.gz minetest-cf0bcebc7620ff2a4bfb44bcbc4909ff9dbe8d24.tar.bz2 minetest-cf0bcebc7620ff2a4bfb44bcbc4909ff9dbe8d24.zip |
Refine movement anticheat again (#7004)
* Account for walking speed in vertical dir
* Avoid undefined behaviour due to division-by-zero
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r-- | src/content_sao.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp index 2b9d53665..247b6df0a 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -1414,6 +1414,12 @@ bool PlayerSAO::checkMovementCheat() // until this can be verified correctly, tolerate higher jumping speeds player_max_jump *= 2.0; + // Don't divide by zero! + if (player_max_walk < 0.0001f) + player_max_walk = 0.0001f; + if (player_max_jump < 0.0001f) + player_max_jump = 0.0001f; + v3f diff = (m_base_position - m_last_good_position); float d_vert = diff.Y; diff.Y = 0; @@ -1422,8 +1428,11 @@ bool PlayerSAO::checkMovementCheat() // 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 (d_vert > 0) { + // In certain cases (water, ladders) walking speed is applied vertically + float s = MYMAX(player_max_jump, player_max_walk); + required_time = MYMAX(required_time, d_vert / s); + } if (m_move_pool.grab(required_time)) { m_last_good_position = m_base_position; |