From 750f9ab74fa7dfb04739dd5dd9d8a3fb4976b901 Mon Sep 17 00:00:00 2001 From: "admin@omencraft.com" Date: Fri, 11 Nov 2011 00:21:52 +0000 Subject: Found and fixed a bug not letting users place blocks in water or lava. git-svn-id: http://mc-server.googlecode.com/svn/trunk@91 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cClientHandle.cpp | 9 +++++++-- source/cClientHandle.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index a399441de..d41759d09 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -695,8 +695,10 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) bool bPlaceBlock = true; bool UpdateRedstone = false; bool AddedCurrent = false; + if( PacketData->m_Direction >= 0 ) { + ENUM_BLOCK_ID BlockID = (ENUM_BLOCK_ID)m_Player->GetWorld()->GetBlock( PacketData->m_PosX, PacketData->m_PosY, PacketData->m_PosZ ); switch( BlockID ) { @@ -814,6 +816,7 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) char MetaData = (char)Equipped.m_ItemHealth; bool LavaBucket = false; bool WaterBucket = false; + switch( PacketData->m_ItemType ) // Special handling for special items { case E_ITEM_BUCKET: @@ -947,10 +950,12 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) char Y = PacketData->m_PosY; int Z = PacketData->m_PosZ; AddDirection( X, Y, Z, PacketData->m_Direction ); - if( m_Player->GetWorld()->GetBlock( X, Y, Z ) != E_BLOCK_AIR ) { //tried to place a block *into* another? + + int PlaceBlock = m_Player->GetWorld()->GetBlock( X, Y, Z ); + if (!( ( PlaceBlock == E_BLOCK_AIR ) || ( PlaceBlock == E_BLOCK_WATER ) || ( PlaceBlock == E_BLOCK_STATIONARY_WATER ) || ( PlaceBlock == E_BLOCK_LAVA ) || ( PlaceBlock == E_BLOCK_STATIONARY_LAVA ) ) ) { //tried to place a block *into* another? break; //happens when you place a block aiming at side of block like torch or stem } - + if( (m_Player->GetGameMode() == 1) || (m_Player->GetInventory().RemoveItem( Item )) ) { if (isDoor) { diff --git a/source/cClientHandle.h b/source/cClientHandle.h index 5025f03d2..e38165604 100644 --- a/source/cClientHandle.h +++ b/source/cClientHandle.h @@ -20,7 +20,7 @@ public: cClientHandle(const cSocket & a_Socket); ~cClientHandle(); - static const int VIEWDISTANCE = 13; + static const int VIEWDISTANCE = 17; const cSocket & GetSocket(); cPlayer* GetPlayer() { return m_Player; } // tolua_export -- cgit v1.2.3