forked from Mirrorlandia_minetest/minetest
Anticheat: Use the physics_override modifiers aswell
This commit is contained in:
parent
2de8c22a99
commit
c0cd7aa351
@ -1326,14 +1326,13 @@ 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
|
|
||||||
{
|
bool cheated = false;
|
||||||
/*
|
/*
|
||||||
Check player movements
|
Check player movements
|
||||||
|
|
||||||
@ -1345,24 +1344,26 @@ bool PlayerSAO::checkMovementCheat()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
float player_max_speed = 0;
|
float player_max_speed = 0;
|
||||||
|
|
||||||
if (m_privs.count("fast") != 0) {
|
if (m_privs.count("fast") != 0) {
|
||||||
// Fast speed
|
// Fast speed
|
||||||
player_max_speed = m_player->movement_speed_fast;
|
player_max_speed = m_player->movement_speed_fast * m_physics_override_speed;
|
||||||
} else {
|
} else {
|
||||||
// Normal speed
|
// Normal speed
|
||||||
player_max_speed = m_player->movement_speed_walk;
|
player_max_speed = m_player->movement_speed_walk * m_physics_override_speed;
|
||||||
}
|
}
|
||||||
// Tolerance. With the lag pool we shouldn't need it.
|
// Tolerance. The lag pool does this a bit.
|
||||||
//player_max_speed *= 2.5;
|
//player_max_speed *= 2.5;
|
||||||
//player_max_speed_up *= 2.5;
|
|
||||||
|
|
||||||
v3f diff = (m_player->getPosition() - m_last_good_position);
|
v3f diff = (m_player->getPosition() - m_last_good_position);
|
||||||
float d_vert = diff.Y;
|
float d_vert = diff.Y;
|
||||||
diff.Y = 0;
|
diff.Y = 0;
|
||||||
float d_horiz = diff.getLength();
|
float d_horiz = diff.getLength();
|
||||||
float required_time = d_horiz / player_max_speed;
|
float required_time = d_horiz / player_max_speed;
|
||||||
|
|
||||||
if (d_vert > 0 && d_vert / player_max_speed > required_time)
|
if (d_vert > 0 && d_vert / player_max_speed > required_time)
|
||||||
required_time = d_vert/player_max_speed;
|
required_time = d_vert / player_max_speed; // Moving upwards
|
||||||
|
|
||||||
if (m_move_pool.grab(required_time)) {
|
if (m_move_pool.grab(required_time)) {
|
||||||
m_last_good_position = m_player->getPosition();
|
m_last_good_position = m_player->getPosition();
|
||||||
} else {
|
} else {
|
||||||
@ -1372,7 +1373,6 @@ bool PlayerSAO::checkMovementCheat()
|
|||||||
m_player->setPosition(m_last_good_position);
|
m_player->setPosition(m_last_good_position);
|
||||||
cheated = true;
|
cheated = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return cheated;
|
return cheated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user