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
This commit is contained in:
madmaxoft@gmail.com
2013-06-18 19:32:31 +00:00
parent 961c7bc51e
commit 32f28bf1fb
2 changed files with 42 additions and 2 deletions
+15 -1
View File
@@ -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);