From a66f6d905d0c0ade3d4e594e9f855141a2c75952 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 7 Sep 2012 20:53:37 +0000 Subject: Relaxed the check for held item, the client sometimes sends wrong ItemType. http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 git-svn-id: http://mc-server.googlecode.com/svn/trunk@846 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cClientHandle.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index 1d539ff79..193b6b450 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -574,6 +574,10 @@ void cClientHandle::HandleBlockDig(int a_BlockX, int a_BlockY, int a_BlockZ, cha void cClientHandle::HandleBlockPlace(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, const cItem & a_HeldItem) { + LOGD("HandleBlockPlace: {%d, %d, %d}, face %d, itemtype: %d", + a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_HeldItem.m_ItemType + ); + if (!CheckBlockInteractionsRate()) { return; @@ -581,8 +585,11 @@ void cClientHandle::HandleBlockPlace(int a_BlockX, int a_BlockY, int a_BlockZ, c cItem & Equipped = m_Player->GetInventory().GetEquippedItem(); - if ((Equipped.m_ItemType != a_HeldItem.m_ItemType)) // Not valid + if ((Equipped.m_ItemType != a_HeldItem.m_ItemType) && (a_HeldItem.m_ItemType != -1)) { + // Only compare ItemType, not meta (torches have different metas) + // The -1 check is there because sometimes the client sends -1 instead of the held item + // ( http://forum.mc-server.org/showthread.php?tid=549&pid=4502#pid4502 ) LOGWARN("Player %s tried to place a block that was not equipped (exp %d, got %d)", m_Username.c_str(), Equipped.m_ItemType, a_HeldItem.m_ItemType ); @@ -596,7 +603,7 @@ void cClientHandle::HandleBlockPlace(int a_BlockX, int a_BlockY, int a_BlockZ, c return; } - if (cRoot::Get()->GetPluginManager()->CallHookBlockPlace(m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_HeldItem)) + if (cRoot::Get()->GetPluginManager()->CallHookBlockPlace(m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, Equipped)) { if (a_BlockFace > -1) { -- cgit v1.2.3