Add block place/break distance check.
This commit is contained in:
parent
c8631d9a9b
commit
eb0f713b6a
@ -1016,6 +1016,17 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
|
||||
}
|
||||
|
||||
cWorld * World = m_Player->GetWorld();
|
||||
|
||||
if (
|
||||
(Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) ||
|
||||
(Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) ||
|
||||
(Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6)
|
||||
)
|
||||
{
|
||||
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
|
||||
return;
|
||||
}
|
||||
|
||||
ItemHandler->OnBlockDestroyed(World, m_Player, m_Player->GetEquippedItem(), a_BlockX, a_BlockY, a_BlockZ);
|
||||
// The ItemHandler is also responsible for spawning the pickups
|
||||
cChunkInterface ChunkInterface(World->GetChunkMap());
|
||||
@ -1191,6 +1202,16 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e
|
||||
// The block is being placed outside the world, ignore this packet altogether (#128)
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
(Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) ||
|
||||
(Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) ||
|
||||
(Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6)
|
||||
)
|
||||
{
|
||||
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
|
||||
return;
|
||||
}
|
||||
|
||||
World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta);
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "ChatColor.h"
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
|
||||
@ -528,6 +529,15 @@ inline float GetSpecialSignf( float a_Val )
|
||||
|
||||
|
||||
|
||||
template<class T> inline int Diff(T a_Val1, T a_Val2)
|
||||
{
|
||||
return std::abs(a_Val1 - a_Val2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// tolua_begin
|
||||
|
||||
enum eMessageType
|
||||
|
Loading…
Reference in New Issue
Block a user