Fix anticheat false positives whith speed physics override

This commit is contained in:
Desour 2023-12-02 16:47:56 +01:00 committed by DS
parent 91134015e7
commit bf53e7e1ca

@ -617,9 +617,14 @@ bool PlayerSAO::checkMovementCheat()
float player_max_walk = 0; // horizontal movement
float player_max_jump = 0; // vertical upwards movement
float speed_walk = m_player->movement_speed_walk * m_player->physics_override.speed;
float speed_fast = m_player->movement_speed_fast;
float speed_walk = m_player->movement_speed_walk;
float speed_fast = m_player->movement_speed_fast;
float speed_crouch = m_player->movement_speed_crouch * m_player->physics_override.speed_crouch;
float speed_climb = m_player->movement_speed_climb * m_player->physics_override.speed_climb;
speed_walk *= m_player->physics_override.speed;
speed_fast *= m_player->physics_override.speed;
speed_crouch *= m_player->physics_override.speed;
speed_climb *= m_player->physics_override.speed;
// Get permissible max. speed
if (m_privs.count("fast") != 0) {
@ -641,7 +646,7 @@ bool PlayerSAO::checkMovementCheat()
// 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;
player_max_jump = MYMAX(player_max_jump, m_player->movement_speed_climb * m_player->physics_override.speed_climb);
player_max_jump = MYMAX(player_max_jump, speed_climb);
player_max_jump = MYMAX(player_max_jump, override_max_V);
// Don't divide by zero!
@ -659,7 +664,8 @@ 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) {
// In certain cases (water, ladders) walking speed is applied vertically
// In certain cases (swimming, climbing, flying) walking speed is applied
// vertically
float s = MYMAX(player_max_jump, player_max_walk);
required_time = MYMAX(required_time, d_vert / s);
}