Skip to content

Commit cf0bceb

Browse files
sfan5SmallJoker
authored andcommittedFeb 2, 2018
Refine movement anticheat again (#7004)
* Account for walking speed in vertical dir * Avoid undefined behaviour due to division-by-zero
1 parent 49b65a5 commit cf0bceb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

‎src/content_sao.cpp

+11-2
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,12 @@ bool PlayerSAO::checkMovementCheat()
14141414
// until this can be verified correctly, tolerate higher jumping speeds
14151415
player_max_jump *= 2.0;
14161416

1417+
// Don't divide by zero!
1418+
if (player_max_walk < 0.0001f)
1419+
player_max_walk = 0.0001f;
1420+
if (player_max_jump < 0.0001f)
1421+
player_max_jump = 0.0001f;
1422+
14171423
v3f diff = (m_base_position - m_last_good_position);
14181424
float d_vert = diff.Y;
14191425
diff.Y = 0;
@@ -1422,8 +1428,11 @@ bool PlayerSAO::checkMovementCheat()
14221428

14231429
// FIXME: Checking downwards movement is not easily possible currently,
14241430
// the server could calculate speed differences to examine the gravity
1425-
if (d_vert > 0)
1426-
required_time = MYMAX(required_time, d_vert / player_max_jump);
1431+
if (d_vert > 0) {
1432+
// In certain cases (water, ladders) walking speed is applied vertically
1433+
float s = MYMAX(player_max_jump, player_max_walk);
1434+
required_time = MYMAX(required_time, d_vert / s);
1435+
}
14271436

14281437
if (m_move_pool.grab(required_time)) {
14291438
m_last_good_position = m_base_position;

0 commit comments

Comments
 (0)
Please sign in to comment.