From 1bb4d7941267ee55cdf7f35fa6a0055521115960 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 2 Sep 2014 19:12:35 +0200 Subject: Added SetCustomName() to players. --- src/ClientHandle.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index f9c6a664c..e97c126a1 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -124,13 +124,11 @@ cClientHandle::~cClientHandle() if (m_Player != NULL) { cWorld * World = m_Player->GetWorld(); - if (!m_Username.empty() && (World != NULL)) - { - // Send the Offline PlayerList packet: - World->BroadcastPlayerListItem(*m_Player, false, this); - } if (World != NULL) { + // Send the Offline PlayerList packet: + World->BroadcastPlayerListItem(m_Player->GetTabListName(), false, 0, this); + World->RemovePlayer(m_Player, true); // Must be called before cPlayer::Destroy() as otherwise cChunk tries to delete the player, and then we do it again m_Player->Destroy(); } @@ -2371,9 +2369,9 @@ void cClientHandle::SendPlayerAbilities() -void cClientHandle::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline) +void cClientHandle::SendPlayerListItem(const AString & a_PlayerName, bool a_IsOnline, short a_Ping) { - m_Protocol->SendPlayerListItem(a_Player, a_IsOnline); + m_Protocol->SendPlayerListItem(a_PlayerName, a_IsOnline, a_Ping); } -- cgit v1.2.3 From 8f8693a71eb896ccc7c14c4033ae8d07dae27ac3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 8 Sep 2014 17:02:54 +0200 Subject: Fixed more 1.8 packets. --- src/ClientHandle.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 4a768771e..4c36dec4d 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1198,6 +1198,12 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e cWorld * World = m_Player->GetWorld(); + // 1.8 protocol fix + if ((int)a_BlockFace == 255) + { + a_BlockFace = BLOCK_FACE_NONE; + } + if ( (a_BlockFace != BLOCK_FACE_NONE) && // The client is interacting with a specific block ( @@ -1268,22 +1274,25 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e return; } - BLOCKTYPE BlockType; - NIBBLETYPE BlockMeta; - World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); - cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); - - if (BlockHandler->IsUseable() && !m_Player->IsCrouched()) + if ((Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() <= 5) { - if (PlgMgr->CallHookPlayerUsingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta)) + BLOCKTYPE BlockType; + NIBBLETYPE BlockMeta; + World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta); + cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); + + if (BlockHandler->IsUseable() && !m_Player->IsCrouched()) { - // A plugin doesn't agree with using the block, abort + if (PlgMgr->CallHookPlayerUsingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta)) + { + // A plugin doesn't agree with using the block, abort + return; + } + cChunkInterface ChunkInterface(World->GetChunkMap()); + BlockHandler->OnUse(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ); + PlgMgr->CallHookPlayerUsedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); return; } - cChunkInterface ChunkInterface(World->GetChunkMap()); - BlockHandler->OnUse(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ); - PlgMgr->CallHookPlayerUsedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta); - return; } short EquippedDamage = Equipped.m_ItemDamage; -- cgit v1.2.3 From 76fa3a7ccd69aee7293a19dc06c327020d3cf908 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 8 Sep 2014 20:12:43 +0200 Subject: More fixes. --- src/ClientHandle.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 4c36dec4d..a614d5597 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1198,19 +1198,9 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e cWorld * World = m_Player->GetWorld(); - // 1.8 protocol fix - if ((int)a_BlockFace == 255) - { - a_BlockFace = BLOCK_FACE_NONE; - } - if ( (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) - ) + ((Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() >= 5) ) { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); -- cgit v1.2.3 From 4b1f4e8d7ecaed0cc9c4dffbf58c5665183297c7 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 9 Sep 2014 01:52:51 +0200 Subject: 1.8: Added new uuid field. --- src/ClientHandle.cpp | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index a614d5597..e91644fbc 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1192,6 +1192,8 @@ void cClientHandle::FinishDigAnimation() void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem) { + // TODO: Rewrite this function + LOGD("HandleRightClick: {%d, %d, %d}, face %d, HeldItem: %s", a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, ItemToFullString(a_HeldItem).c_str() ); @@ -1204,14 +1206,17 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e ) { 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) + if ((a_BlockX >= 0) && (a_BlockY >= 0) && (a_BlockZ >= 0)) { - World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things - } - if (a_BlockY > 0) - { - World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, m_Player); // 2 block high things + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + if (a_BlockY < cChunkDef::Height - 1) + { + World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things + } + if (a_BlockY > 0) + { + World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, m_Player); // 2 block high things + } } m_Player->GetInventory().SendEquippedSlot(); return; @@ -1221,17 +1226,20 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) { // A plugin doesn't agree with the action, replace the block on the client and quit: - cChunkInterface ChunkInterface(World->GetChunkMap()); - BLOCKTYPE BlockType = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); - BlockHandler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - - if (a_BlockFace != BLOCK_FACE_NONE) + if ((a_BlockX >= 0) && (a_BlockY >= 0) && (a_BlockZ >= 0)) { - 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(); + cChunkInterface ChunkInterface(World->GetChunkMap()); + BLOCKTYPE BlockType = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + cBlockHandler * BlockHandler = cBlockInfo::GetHandler(BlockType); + BlockHandler->OnCancelRightClick(ChunkInterface, *World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + + 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); + World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things + m_Player->GetInventory().SendEquippedSlot(); + } } return; } -- cgit v1.2.3 From f94df06b6601f9dcecd383f5d093d225f41d1c65 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 9 Sep 2014 03:02:25 +0200 Subject: Added the player list to the 1.8 protocol. --- src/ClientHandle.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index f24309159..f97ce26c9 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -127,7 +127,7 @@ cClientHandle::~cClientHandle() if (!m_Username.empty() && (World != NULL)) { // Send the Offline PlayerList packet: - World->BroadcastPlayerListItem(*m_Player, false, this); + World->BroadcastPlayerListItem(*m_Player, 4, this); } if (World != NULL) { @@ -366,6 +366,10 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, m_Player->Initialize(*World); m_State = csAuthenticated; + // Send player list items + SendPlayerListItem(*m_Player, 0); + World->SendPlayerList(m_Player); + // Query player team m_Player->UpdateTeam(); @@ -2378,9 +2382,9 @@ void cClientHandle::SendPlayerAbilities() -void cClientHandle::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline) +void cClientHandle::SendPlayerListItem(const cPlayer & a_Player, char a_Action) { - m_Protocol->SendPlayerListItem(a_Player, a_IsOnline); + m_Protocol->SendPlayerListItem(a_Player, a_Action); } -- cgit v1.2.3 From 71c3369e084d0b9e3b91f9517069e58aaecc15e3 Mon Sep 17 00:00:00 2001 From: Howaner Date: Tue, 9 Sep 2014 18:27:31 +0200 Subject: 1.8: Added MultiBlockChange packet. --- src/ClientHandle.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index f97ce26c9..fa2c2124b 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -362,13 +362,14 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, // Send experience m_Player->SendExperience(); - - m_Player->Initialize(*World); - m_State = csAuthenticated; // Send player list items SendPlayerListItem(*m_Player, 0); + World->BroadcastPlayerListItem(*m_Player, 0); World->SendPlayerList(m_Player); + + m_Player->Initialize(*World); + m_State = csAuthenticated; // Query player team m_Player->UpdateTeam(); -- cgit v1.2.3 From 3bd3ac2200392542b111d2bcd2951bd342edf721 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 11 Sep 2014 17:03:09 +0200 Subject: 1.8: Added ParticleEffect packet. --- src/ClientHandle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index fa2c2124b..3b32b06b9 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2339,9 +2339,9 @@ void cClientHandle::SendMapInfo(int a_ID, unsigned int a_Scale) -void cClientHandle::SendParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount) +void cClientHandle::SendParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) { - m_Protocol->SendParticleEffect(a_ParticleName, a_SrcX, a_SrcY, a_SrcZ, a_OffsetX, a_OffsetY, a_OffsetZ, a_ParticleData, a_ParticleAmmount); + m_Protocol->SendParticleEffect(a_ParticleName, a_SrcX, a_SrcY, a_SrcZ, a_OffsetX, a_OffsetY, a_OffsetZ, a_ParticleData, a_ParticleAmount); } -- cgit v1.2.3 From 4e2d75bde56a8c0913006b5978ff418ea042ef0b Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 12 Sep 2014 01:37:19 +0200 Subject: 1.8: Fixed eating. --- src/ClientHandle.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 3b32b06b9..2bffc3cb1 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1207,6 +1207,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e if ( (a_BlockFace != BLOCK_FACE_NONE) && // The client is interacting with a specific block + IsValidBlock(a_HeldItem.m_ItemType) && ((Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() >= 5) ) { -- cgit v1.2.3 From f2c5d8a7615ca46f1894ae5ad651a92cee421a18 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 12 Sep 2014 13:19:33 +0200 Subject: Fixed many right click issues. --- src/ClientHandle.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 2bffc3cb1..642a5246a 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1204,15 +1204,16 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e ); cWorld * World = m_Player->GetWorld(); + bool AreRealCoords = (Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() <= 5; if ( (a_BlockFace != BLOCK_FACE_NONE) && // The client is interacting with a specific block IsValidBlock(a_HeldItem.m_ItemType) && - ((Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() >= 5) + !AreRealCoords ) { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - if ((a_BlockX >= 0) && (a_BlockY >= 0) && (a_BlockZ >= 0)) + if ((a_BlockX != -1) && (a_BlockY >= 0) && (a_BlockZ != -1)) { World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); if (a_BlockY < cChunkDef::Height - 1) @@ -1228,11 +1229,16 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e return; } + if (!AreRealCoords) + { + a_BlockFace = BLOCK_FACE_NONE; + } + cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); if (PlgMgr->CallHookPlayerRightClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) { // A plugin doesn't agree with the action, replace the block on the client and quit: - if ((a_BlockX >= 0) && (a_BlockY >= 0) && (a_BlockZ >= 0)) + if (AreRealCoords) { cChunkInterface ChunkInterface(World->GetChunkMap()); BLOCKTYPE BlockType = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); @@ -1278,7 +1284,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e return; } - if ((Vector3d(a_BlockX, a_BlockY, a_BlockZ) - m_Player->GetPosition()).Length() <= 5) + if (AreRealCoords) { BLOCKTYPE BlockType; NIBBLETYPE BlockMeta; -- cgit v1.2.3 From b462416e1fef58b3ddccc92f3dfe613fc27d5483 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sat, 13 Sep 2014 02:20:04 +0200 Subject: 1.8: Fixed maps. --- src/ClientHandle.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 9b6151656..fa27664ef 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -2337,18 +2337,18 @@ void cClientHandle::SendInventorySlot(char a_WindowID, short a_SlotNum, const cI -void cClientHandle::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length) +void cClientHandle::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length, unsigned int m_Scale) { - m_Protocol->SendMapColumn(a_ID, a_X, a_Y, a_Colors, a_Length); + m_Protocol->SendMapColumn(a_ID, a_X, a_Y, a_Colors, a_Length, m_Scale); } -void cClientHandle::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decorators) +void cClientHandle::SendMapDecorators(int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) { - m_Protocol->SendMapDecorators(a_ID, a_Decorators); + m_Protocol->SendMapDecorators(a_ID, a_Decorators, m_Scale); } -- cgit v1.2.3 From 43ed690520d3c3b47ed7ff6f48f868e8011565e0 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 18 Sep 2014 18:50:17 +0200 Subject: Exported player list states to extra functions. --- src/ClientHandle.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index df6847767..487ef3867 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -127,7 +127,7 @@ cClientHandle::~cClientHandle() if (!m_Username.empty() && (World != NULL)) { // Send the Offline PlayerList packet: - World->BroadcastPlayerListItem(*m_Player, 4, this); + World->BroadcastPlayerListRemovePlayer(*m_Player, this); } if (World != NULL) { @@ -364,10 +364,10 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, m_Player->SendExperience(); // Send player list items - SendPlayerListItem(*m_Player, 0); - World->BroadcastPlayerListItem(*m_Player, 0); + SendPlayerListAddPlayer(*m_Player); + World->BroadcastPlayerListAddPlayer(*m_Player); World->SendPlayerList(m_Player); - + m_Player->Initialize(*World); m_State = csAuthenticated; @@ -2408,9 +2408,45 @@ void cClientHandle::SendPlayerAbilities() -void cClientHandle::SendPlayerListItem(const cPlayer & a_Player, char a_Action) +void cClientHandle::SendPlayerListAddPlayer(const cPlayer & a_Player) +{ + m_Protocol->SendPlayerListAddPlayer(a_Player); +} + + + + + +void cClientHandle::SendPlayerListRemovePlayer(const cPlayer & a_Player) +{ + m_Protocol->SendPlayerListRemovePlayer(a_Player); +} + + + + + +void cClientHandle::SendPlayerListUpdateGameMode(const cPlayer & a_Player) +{ + m_Protocol->SendPlayerListUpdateGameMode(a_Player); +} + + + + + +void cClientHandle::SendPlayerListUpdatePing(const cPlayer & a_Player) +{ + m_Protocol->SendPlayerListUpdatePing(a_Player); +} + + + + + +void cClientHandle::SendPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_OldListName) { - m_Protocol->SendPlayerListItem(a_Player, a_Action); + m_Protocol->SendPlayerListUpdateDisplayName(a_Player, a_OldListName); } -- cgit v1.2.3