From 32f28bf1fb61195f4f3709fccce09abc3b20a166 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 18 Jun 2013 19:32:31 +0000 Subject: Added a crude limiter for explosions sent to client. Now the client can survive even 3000k TNT blocks exploding without jerking much. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1606 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/ClientHandle.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source/ClientHandle.h') diff --git a/source/ClientHandle.h b/source/ClientHandle.h index 4568f1a58..cd0ca1ee6 100644 --- a/source/ClientHandle.h +++ b/source/ClientHandle.h @@ -56,7 +56,10 @@ public: #endif static const int MAX_VIEW_DISTANCE = 10; static const int MIN_VIEW_DISTANCE = 4; - + + /// How many ticks should be checked for a running average of explosions, for limiting purposes + static const int NUM_CHECK_EXPLOSIONS_TICKS = 20; + cClientHandle(const cSocket * a_Socket, int a_ViewDistance); virtual ~cClientHandle(); @@ -258,6 +261,17 @@ private: /// If set to true during csDownloadingWorld, the tick thread calls CheckIfWorldDownloaded() bool m_ShouldCheckDownloaded; + /// Stores the recent history of the number of explosions per tick + int m_NumExplosionsPerTick[NUM_CHECK_EXPLOSIONS_TICKS]; + + /// Points to the current tick in the m_NumExplosionsPerTick[] array + int m_CurrentExplosionTick; + + /// Running sum of m_NumExplosionsPerTick[] + int m_RunningSumExplosions; + + + /// Returns true if the rate block interactions is within a reasonable limit (bot protection) bool CheckBlockInteractionsRate(void); -- cgit v1.2.3