From 143b8499e09cba53bfc4b7e73ba0ea75238c24d2 Mon Sep 17 00:00:00 2001 From: "mtilden@gmail.com" Date: Wed, 28 Dec 2011 16:09:36 +0000 Subject: - Fixed too fast actions kick for real git-svn-id: http://mc-server.googlecode.com/svn/trunk@149 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cClientHandle.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/cClientHandle.cpp') diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index e27ed4ecb..d65c47e8e 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -564,10 +564,10 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) { int LastActionCnt = m_Player->GetLastBlockActionCnt(); - if ( cRoot::Get()->GetWorld()->GetTime() - m_Player->GetLastBlockActionTime() < 0.1 ) { //only allow block interactions every 0.1 seconds + if ( (cRoot::Get()->GetWorld()->GetTime() - m_Player->GetLastBlockActionTime()) < 0.1 ) { //only allow block interactions every 0.1 seconds m_Player->SetLastBlockActionTime(); //Player tried to interact with a block. Reset last block interation time. m_Player->SetLastBlockActionCnt(LastActionCnt+1); - if (LastActionCnt > MAXBLOCKCHANGEINTERACTIONS) { //kick if more than MAXBLOCKCHANGEINTERACTIONS per .1 seconds + if (m_Player->GetLastBlockActionCnt() > MAXBLOCKCHANGEINTERACTIONS) { //kick if more than MAXBLOCKCHANGEINTERACTIONS per .1 seconds LOGWARN("Player %s tried to interact with a block too quickly! (could indicate bot) Was Kicked.", GetUsername() ); //TODO Too many false-positives :s for example on a minimal server lagg :s should be re checked Kick("You're a baaaaaad boy!"); @@ -739,10 +739,10 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) { int LastActionCnt = m_Player->GetLastBlockActionCnt(); - if ( cRoot::Get()->GetWorld()->GetTime() - m_Player->GetLastBlockActionTime() < 0.1 ) { //only allow block interactions every 0.1 seconds + if ( (cRoot::Get()->GetWorld()->GetTime() - m_Player->GetLastBlockActionTime()) < 0.1 ) { //only allow block interactions every 0.1 seconds m_Player->SetLastBlockActionTime(); //Player tried to interact with a block. Reset last block interation time. m_Player->SetLastBlockActionCnt(LastActionCnt+1); - if (LastActionCnt > MAXBLOCKCHANGEINTERACTIONS) { //kick if more than MAXBLOCKCHANGEINTERACTIONS per .1 seconds + if (m_Player->GetLastBlockActionCnt() > MAXBLOCKCHANGEINTERACTIONS) { //kick if more than MAXBLOCKCHANGEINTERACTIONS per .1 seconds LOGWARN("Player %s tried to interact with a block too quickly! (could indicate bot) Was Kicked.", GetUsername() ); Kick("You're a baaaaaad boy!"); break; @@ -1235,7 +1235,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) if (PacketData->m_KeepAliveID == m_PingID) { cTimer t1; - m_Ping = (short)(t1.GetNowTime() - m_PingStartTime); + m_Ping = (short)((t1.GetNowTime() - m_PingStartTime) / 2); } } break; -- cgit v1.2.3