Anticheat: Use the physics_override modifiers aswell

This commit is contained in:
SmallJoker 2016-09-09 07:03:36 +02:00 committed by kwolekr
parent 2de8c22a99
commit c0cd7aa351

@ -1326,52 +1326,52 @@ std::string PlayerSAO::getPropertyPacket()
bool PlayerSAO::checkMovementCheat() bool PlayerSAO::checkMovementCheat()
{ {
bool cheated = false; if (isAttached() || m_is_singleplayer ||
if(isAttached() || m_is_singleplayer || g_settings->getBool("disable_anticheat")) {
g_settings->getBool("disable_anticheat"))
{
m_last_good_position = m_player->getPosition(); m_last_good_position = m_player->getPosition();
return false;
} }
else
{
/*
Check player movements
NOTE: Actually the server should handle player physics like the bool cheated = false;
client does and compare player's position to what is calculated /*
on our side. This is required when eg. players fly due to an Check player movements
explosion. Altough a node-based alternative might be possible
too, and much more lightweight.
*/
float player_max_speed = 0; NOTE: Actually the server should handle player physics like the
if(m_privs.count("fast") != 0){ client does and compare player's position to what is calculated
// Fast speed on our side. This is required when eg. players fly due to an
player_max_speed = m_player->movement_speed_fast; explosion. Altough a node-based alternative might be possible
} else { too, and much more lightweight.
// Normal speed */
player_max_speed = m_player->movement_speed_walk;
}
// Tolerance. With the lag pool we shouldn't need it.
//player_max_speed *= 2.5;
//player_max_speed_up *= 2.5;
v3f diff = (m_player->getPosition() - m_last_good_position); float player_max_speed = 0;
float d_vert = diff.Y;
diff.Y = 0; if (m_privs.count("fast") != 0) {
float d_horiz = diff.getLength(); // Fast speed
float required_time = d_horiz/player_max_speed; player_max_speed = m_player->movement_speed_fast * m_physics_override_speed;
if(d_vert > 0 && d_vert/player_max_speed > required_time) } else {
required_time = d_vert/player_max_speed; // Normal speed
if(m_move_pool.grab(required_time)){ player_max_speed = m_player->movement_speed_walk * m_physics_override_speed;
m_last_good_position = m_player->getPosition(); }
} else { // Tolerance. The lag pool does this a bit.
actionstream<<"Player "<<m_player->getName() //player_max_speed *= 2.5;
<<" moved too fast; resetting position"
<<std::endl; v3f diff = (m_player->getPosition() - m_last_good_position);
m_player->setPosition(m_last_good_position); float d_vert = diff.Y;
cheated = true; diff.Y = 0;
} float d_horiz = diff.getLength();
float required_time = d_horiz / player_max_speed;
if (d_vert > 0 && d_vert / player_max_speed > required_time)
required_time = d_vert / player_max_speed; // Moving upwards
if (m_move_pool.grab(required_time)) {
m_last_good_position = m_player->getPosition();
} else {
actionstream << "Player " << m_player->getName()
<< " moved too fast; resetting position"
<< std::endl;
m_player->setPosition(m_last_good_position);
cheated = true;
} }
return cheated; return cheated;
} }