summaryrefslogtreecommitdiff
path: root/src/content_sao.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2013-08-03 23:16:37 +0300
committerPerttu Ahola <celeron55@gmail.com>2013-08-03 23:16:37 +0300
commit742614180cbbe598694a48bd9eb6f7b97a762243 (patch)
tree5b5033b1d719911ae863ca99d304ebdcca3220f2 /src/content_sao.h
parentbc5db9b0273d43fffad93cf67cf2bfdb714441a9 (diff)
downloadminetest-742614180cbbe598694a48bd9eb6f7b97a762243.tar.gz
minetest-742614180cbbe598694a48bd9eb6f7b97a762243.tar.bz2
minetest-742614180cbbe598694a48bd9eb6f7b97a762243.zip
Fix anticheat
Diffstat (limited to 'src/content_sao.h')
-rw-r--r--src/content_sao.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/content_sao.h b/src/content_sao.h
index 140211cf6..9640e5f08 100644
--- a/src/content_sao.h
+++ b/src/content_sao.h
@@ -122,6 +122,36 @@ private:
PlayerSAO needs some internals exposed.
*/
+class LagPool
+{
+ float pool;
+ float max;
+public:
+ LagPool(): pool(15), max(15)
+ {}
+ void setMax(float new_max)
+ {
+ max = new_max;
+ if(pool > new_max)
+ pool = new_max;
+ }
+ void add(float dtime)
+ {
+ pool -= dtime;
+ if(pool < 0)
+ pool = 0;
+ }
+ bool grab(float dtime)
+ {
+ if(dtime <= 0)
+ return true;
+ if(pool + dtime > max)
+ return false;
+ pool += dtime;
+ return true;
+ }
+};
+
class PlayerSAO : public ServerActiveObject
{
public:
@@ -228,6 +258,11 @@ public:
{
m_nocheat_dig_pos = v3s16(32767, 32767, 32767);
}
+ LagPool& getDigPool()
+ {
+ return m_dig_pool;
+ }
+ void checkMovementCheat();
// Other
@@ -249,8 +284,9 @@ private:
Inventory *m_inventory;
// Cheat prevention
+ LagPool m_dig_pool;
+ LagPool m_move_pool;
v3f m_last_good_position;
- float m_last_good_position_age;
float m_time_from_last_punch;
v3s16 m_nocheat_dig_pos;
float m_nocheat_dig_time;