summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-06-14 12:06:48 +0200
committermadmaxoft <github@xoft.cz>2014-06-14 12:06:48 +0200
commitf8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b (patch)
treed2f3e35f37821e93d92143db2055bcedeaf57142 /src/ClientHandle.cpp
parentPlayer.h: Moved doxy-comments to Entity.h (diff)
parentFixed a repeater issue (diff)
downloadcuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar.gz
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar.bz2
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar.lz
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar.xz
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.tar.zst
cuberite-f8f7748a09b936cc888c0c4a1f0ae9e9e444ba5b.zip
Diffstat (limited to '')
-rw-r--r--src/ClientHandle.cpp69
1 files changed, 22 insertions, 47 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 83b21ae3c..e4bb9d8e9 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -12,7 +12,6 @@
#include "BlockEntities/SignEntity.h"
#include "UI/Window.h"
#include "Item.h"
-#include "Piston.h"
#include "Mobs/Monster.h"
#include "ChatColor.h"
#include "OSSupport/Socket.h"
@@ -328,7 +327,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID)
// Send experience
m_Player->SendExperience();
- m_Player->Initialize(World);
+ m_Player->Initialize(*World);
m_State = csAuthenticated;
// Query player team
@@ -357,7 +356,7 @@ void cClientHandle::StreamChunks(void)
}
ASSERT(m_Player != NULL);
-
+
int ChunkPosX = FAST_FLOOR_DIV((int)m_Player->GetPosX(), cChunkDef::Width);
int ChunkPosZ = FAST_FLOOR_DIV((int)m_Player->GetPosZ(), cChunkDef::Width);
if ((ChunkPosX == m_LastStreamedChunkX) && (ChunkPosZ == m_LastStreamedChunkZ))
@@ -1090,18 +1089,25 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
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)
+ (a_BlockFace != BLOCK_FACE_NONE) && // The client is interacting with a specific block
+ (
+ (Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || // The block is too far away
+ (Diff(m_Player->GetPosY(), (double)a_BlockY) > 6) ||
+ (Diff(m_Player->GetPosZ(), (double)a_BlockZ) > 6)
+ )
)
{
- if (a_BlockFace != BLOCK_FACE_NONE)
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
+ if (a_BlockY < cChunkDef::Height - 1)
{
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things
- m_Player->GetInventory().SendEquippedSlot();
}
+ if (a_BlockY > 0)
+ {
+ World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, m_Player); // 2 block high things
+ }
+ m_Player->GetInventory().SendEquippedSlot();
return;
}
@@ -1307,7 +1313,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, e
if (!a_ItemHandler.GetPlacementBlockTypeMeta(World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta))
{
// Handler refused the placement, send that information back to the client:
- World->SendBlockTo(a_BlockX, a_BlockY, a_BlockY, m_Player);
+ World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
m_Player->GetInventory().SendEquippedSlot();
return;
}
@@ -1391,28 +1397,8 @@ void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsO
void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround)
{
- if ((m_Player == NULL) || (m_State != csPlaying))
- {
- // The client hasn't been spawned yet and sends nonsense, we know better
- return;
- }
-
- /*
- // TODO: Invalid stance check
- if ((a_PosY >= a_Stance) || (a_Stance > a_PosY + 1.65))
- {
- LOGD("Invalid stance");
- SendPlayerMoveLook();
- return;
- }
- */
-
- m_Player->MoveTo(Vector3d(a_PosX, a_PosY, a_PosZ));
- m_Player->SetStance (a_Stance);
- m_Player->SetTouchGround(a_IsOnGround);
- m_Player->SetHeadYaw (a_Rotation);
- m_Player->SetYaw (a_Rotation);
- m_Player->SetPitch (a_Pitch);
+ HandlePlayerLook(a_Rotation, a_Pitch, a_IsOnGround);
+ HandlePlayerPos(a_PosX, a_PosY, a_PosZ, a_Stance, a_IsOnGround);
}
@@ -1767,18 +1753,8 @@ void cClientHandle::SendData(const char * a_Data, size_t a_Size)
-void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket)
+void cClientHandle::RemoveFromWorld(void)
{
- UNUSED(a_World);
- ASSERT(m_Player != NULL);
-
- if (a_SendRespawnPacket)
- {
- SendRespawn();
- }
-
- cWorld * World = m_Player->GetWorld();
-
// Remove all associated chunks:
cChunkCoordsList Chunks;
{
@@ -1788,7 +1764,6 @@ void cClientHandle::MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket)
}
for (cChunkCoordsList::iterator itr = Chunks.begin(), end = Chunks.end(); itr != end; ++itr)
{
- World->RemoveChunkClient(itr->m_ChunkX, itr->m_ChunkZ, this);
m_Protocol->SendUnloadChunk(itr->m_ChunkX, itr->m_ChunkZ);
} // for itr - Chunks[]
@@ -2393,9 +2368,9 @@ void cClientHandle::SendRemoveEntityEffect(const cEntity & a_Entity, int a_Effec
-void cClientHandle::SendRespawn(void)
+void cClientHandle::SendRespawn(const cWorld & a_World)
{
- m_Protocol->SendRespawn();
+ m_Protocol->SendRespawn(a_World);
}