m_inventory(NULL),
m_damage(0),
m_last_good_position(0,0,0),
+ m_time_from_last_teleport(0),
m_time_from_last_punch(0),
m_nocheat_dig_pos(32767, 32767, 32767),
m_nocheat_dig_time(0),
// Increment cheat prevention timers
m_dig_pool.add(dtime);
m_move_pool.add(dtime);
+ m_time_from_last_teleport += dtime;
m_time_from_last_punch += dtime;
m_nocheat_dig_time += dtime;
setBasePosition(pos);
// Movement caused by this command is always valid
m_last_good_position = pos;
+ m_move_pool.empty();
+ m_time_from_last_teleport = 0.0;
m_env->getGameDef()->SendMovePlayer(m_peer_id);
}
setBasePosition(pos);
// Movement caused by this command is always valid
m_last_good_position = pos;
+ m_move_pool.empty();
+ m_time_from_last_teleport = 0.0;
m_env->getGameDef()->SendMovePlayer(m_peer_id);
}
if (m_move_pool.grab(required_time)) {
m_last_good_position = m_base_position;
} else {
- actionstream << "Player " << m_player->getName()
- << " moved too fast; resetting position"
- << std::endl;
+ const float LAG_POOL_MIN = 5.0;
+ float lag_pool_max = m_env->getMaxLagEstimate() * 2.0;
+ lag_pool_max = MYMAX(lag_pool_max, LAG_POOL_MIN);
+ if (m_time_from_last_teleport > lag_pool_max) {
+ actionstream << "Player " << m_player->getName()
+ << " moved too fast; resetting position"
+ << std::endl;
+ cheated = true;
+ }
setBasePosition(m_last_good_position);
- cheated = true;
}
return cheated;
}
public:
LagPool(): m_pool(15), m_max(15)
{}
+
void setMax(float new_max)
{
m_max = new_max;
if(m_pool > new_max)
m_pool = new_max;
}
+
void add(float dtime)
{
m_pool -= dtime;
if(m_pool < 0)
m_pool = 0;
}
+
+ void empty()
+ {
+ m_pool = m_max;
+ }
+
bool grab(float dtime)
{
if(dtime <= 0)
LagPool m_dig_pool;
LagPool m_move_pool;
v3f m_last_good_position;
+ float m_time_from_last_teleport;
float m_time_from_last_punch;
v3s16 m_nocheat_dig_pos;
float m_nocheat_dig_time;