From ff7171fc5a567590dd52d4213439778f0dfcce53 Mon Sep 17 00:00:00 2001 From: Howaner Date: Wed, 6 Aug 2014 14:04:25 +0200 Subject: Resending fire to the client when the interact cancelled. --- src/ClientHandle.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 72257028a..3e046f38d 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -920,6 +920,10 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB ) { m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))->IsClickedThrough()) + { + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); + } return; } @@ -928,6 +932,10 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB { // A plugin doesn't agree with the action, replace the block on the client and quit: m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))->IsClickedThrough()) + { + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); + } return; } -- cgit v1.2.3 From 4271d719b68521f91770574b3064525512116670 Mon Sep 17 00:00:00 2001 From: Howaner Date: Thu, 7 Aug 2014 01:07:32 +0200 Subject: Added SetDoDaylightCycle() and IsDaylightCycleEnabled() to cWorld. I need this for a GameRule plugin. --- src/ClientHandle.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 3e046f38d..286c17513 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -342,7 +342,16 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, } // Send time - m_Protocol->SendTimeUpdate(World->GetWorldAge(), World->GetTimeOfDay()); + Int64 TimeOfDay = World->GetTimeOfDay(); + if (!World->IsDaylightCycleEnabled()) + { + TimeOfDay *= -1; + if (TimeOfDay == 0) + { + TimeOfDay = -1; + } + } + m_Protocol->SendTimeUpdate(World->GetWorldAge(), TimeOfDay); // Send contents of the inventory window m_Protocol->SendWholeInventory(*m_Player->GetWindow()); -- cgit v1.2.3 From 42bad0edec58f42e4072360c52870d3be9ced3c5 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 10 Aug 2014 20:06:03 +0200 Subject: Added a comment and simplified code. --- src/ClientHandle.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 286c17513..37d7edbc1 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -341,15 +341,12 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, m_Protocol->SendWeather(World->GetWeather()); } - // Send time + // Send time: Int64 TimeOfDay = World->GetTimeOfDay(); if (!World->IsDaylightCycleEnabled()) { - TimeOfDay *= -1; - if (TimeOfDay == 0) - { - TimeOfDay = -1; - } + // When writing a "-" before the number the client ignores it but it will stop the client-side time expiration. + TimeOfDay = std::min(-TimeOfDay, -1); } m_Protocol->SendTimeUpdate(World->GetWorldAge(), TimeOfDay); -- cgit v1.2.3 From 47c928cab7d1ff73e50925bc7ef50586b6ec9821 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 11 Aug 2014 00:20:28 +0200 Subject: Exported daylight cycle flag to the protocol. --- src/ClientHandle.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 37d7edbc1..d386f3576 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -342,13 +342,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, } // Send time: - Int64 TimeOfDay = World->GetTimeOfDay(); - if (!World->IsDaylightCycleEnabled()) - { - // When writing a "-" before the number the client ignores it but it will stop the client-side time expiration. - TimeOfDay = std::min(-TimeOfDay, -1); - } - m_Protocol->SendTimeUpdate(World->GetWorldAge(), TimeOfDay); + m_Protocol->SendTimeUpdate(World->GetWorldAge(), World->GetTimeOfDay(), World->IsDaylightCycleEnabled()); // Send contents of the inventory window m_Protocol->SendWholeInventory(*m_Player->GetWindow()); @@ -2595,9 +2589,9 @@ void cClientHandle::SendThunderbolt(int a_BlockX, int a_BlockY, int a_BlockZ) -void cClientHandle::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay) +void cClientHandle::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle) { - m_Protocol->SendTimeUpdate(a_WorldAge, a_TimeOfDay); + m_Protocol->SendTimeUpdate(a_WorldAge, a_TimeOfDay, a_DoDaylightCycle); } -- cgit v1.2.3 From 202a0d1c1d6de6cc1b229026d0304a736a1d9b75 Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 11 Aug 2014 14:24:36 +0200 Subject: Fixed cancelled fire interact from all directions. --- src/ClientHandle.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 3e046f38d..8eff45cf4 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -920,9 +920,13 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB ) { m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))->IsClickedThrough()) + if (a_BlockFace != BLOCK_FACE_NONE) { - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY, a_BlockZ))->IsClickedThrough()) + { + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + } } return; } @@ -932,9 +936,13 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB { // A plugin doesn't agree with the action, replace the block on the client and quit: m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ))->IsClickedThrough()) + if (a_BlockFace != BLOCK_FACE_NONE) { - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); + if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY, a_BlockZ))->IsClickedThrough()) + { + m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + } } return; } -- cgit v1.2.3 From 74fabb079c710ab9f81e0b7ee30a8a3e3604595c Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 11 Aug 2014 22:34:33 +0200 Subject: Moved the clicked-through block check to the top of the function. --- src/ClientHandle.cpp | 53 +++++++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 36 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 8eff45cf4..f09e9531d 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -912,6 +912,23 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB return; } + // Check for clickthrough-blocks: + /* When the user breaks a fire block, the client send the wrong block location. + We must find the right block with the face direction. */ + if (a_BlockFace != BLOCK_FACE_NONE) + { + int BlockX = a_BlockX; + int BlockY = a_BlockY; + int BlockZ = a_BlockZ; + AddFaceDirection(BlockX, BlockY, BlockZ, a_BlockFace); + if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(BlockX, BlockY, BlockZ))->IsClickedThrough()) + { + a_BlockX = BlockX; + a_BlockY = BlockY; + a_BlockZ = BlockZ; + } + } + if ( ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored ((Diff(m_Player->GetPosX(), (double)a_BlockX) > 6) || @@ -920,14 +937,6 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB ) { m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - if (a_BlockFace != BLOCK_FACE_NONE) - { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY, a_BlockZ))->IsClickedThrough()) - { - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - } - } return; } @@ -936,14 +945,6 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB { // A plugin doesn't agree with the action, replace the block on the client and quit: m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - if (a_BlockFace != BLOCK_FACE_NONE) - { - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - if (cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY, a_BlockZ))->IsClickedThrough()) - { - m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - } - } return; } @@ -1067,26 +1068,6 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc m_LastDigBlockY = a_BlockY; m_LastDigBlockZ = a_BlockZ; - // Check for clickthrough-blocks: - /* When the user breaks a fire block, the client send the wrong block location. - We must find the right block with the face direction. */ - if (a_BlockFace != BLOCK_FACE_NONE) - { - int pX = a_BlockX; - int pY = a_BlockY; - int pZ = a_BlockZ; - - AddFaceDirection(pX, pY, pZ, a_BlockFace); // Get the block in front of the clicked coordinates (m_bInverse defaulted to false) - cBlockHandler * Handler = cBlockInfo::GetHandler(m_Player->GetWorld()->GetBlock(pX, pY, pZ)); - - if (Handler->IsClickedThrough()) - { - cChunkInterface ChunkInterface(m_Player->GetWorld()->GetChunkMap()); - Handler->OnDigging(ChunkInterface, *m_Player->GetWorld(), m_Player, pX, pY, pZ); - return; - } - } - if ( (m_Player->IsGameModeCreative()) || // In creative mode, digging is done immediately cBlockInfo::IsOneHitDig(a_OldBlock) // One-hit blocks get destroyed immediately, too -- cgit v1.2.3 From 01001d2a49a3366e9b1eccf938d5073ab9a2f06e Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 11 Aug 2014 22:37:28 +0200 Subject: Removes the fire if the block under the fire was broken. --- src/ClientHandle.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index f09e9531d..4b5c52c8c 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1143,6 +1143,11 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this); World->DigBlock(a_BlockX, a_BlockY, a_BlockZ); + if (World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ) == E_BLOCK_FIRE) + { + World->SetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, E_BLOCK_AIR, 0); + } + cRoot::Get()->GetPluginManager()->CallHookPlayerBrokenBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta); } -- cgit v1.2.3 From cb980145820b1bb016dac17a28731cc0b600442a Mon Sep 17 00:00:00 2001 From: Howaner Date: Mon, 11 Aug 2014 23:12:32 +0200 Subject: Revert "Removes the fire if the block under the fire was broken." This reverts commit 01001d2a49a3366e9b1eccf938d5073ab9a2f06e. --- src/ClientHandle.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 4b5c52c8c..f09e9531d 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1143,11 +1143,6 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo World->BroadcastSoundParticleEffect(2001, a_BlockX, a_BlockY, a_BlockZ, a_OldBlock, this); World->DigBlock(a_BlockX, a_BlockY, a_BlockZ); - if (World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ) == E_BLOCK_FIRE) - { - World->SetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, E_BLOCK_AIR, 0); - } - cRoot::Get()->GetPluginManager()->CallHookPlayerBrokenBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta); } -- cgit v1.2.3 From 64fec204c4c5062461a7188b58026d062519b417 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 21 Aug 2014 22:39:53 +0200 Subject: Added initializers for class members. As reported by Coverity, these weren't initialized. --- src/ClientHandle.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index e2b438831..ee4fdfa7d 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -75,11 +75,21 @@ cClientHandle::cClientHandle(const cSocket * a_Socket, int a_ViewDistance) : m_TimeSinceLastPacket(0), m_Ping(1000), m_PingID(1), + m_PingStartTime(0), + m_LastPingTime(1000), m_BlockDigAnimStage(-1), + m_BlockDigAnimSpeed(0), + m_BlockDigAnimX(0), + m_BlockDigAnimY(256), // Invalid Y, so that the coords don't get picked up + m_BlockDigAnimZ(0), m_HasStartedDigging(false), + m_LastDigBlockX(0), + m_LastDigBlockY(256), // Invalid Y, so that the coords don't get picked up + m_LastDigBlockZ(0), m_State(csConnected), m_ShouldCheckDownloaded(false), m_NumExplosionsThisTick(0), + m_NumBlockChangeInteractionsThisTick(0), m_UniqueID(0), m_HasSentPlayerChunk(false), m_Locale("en_GB") -- cgit v1.2.3 From 8fa4ac9ad957d951cf25c668ffbb4e5d2fafa7f7 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 22 Aug 2014 15:32:27 +0200 Subject: Fixed item drop. Fixes #1341 --- src/ClientHandle.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index ee4fdfa7d..8aa883144 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -922,11 +922,16 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB return; } - // Check for clickthrough-blocks: - /* When the user breaks a fire block, the client send the wrong block location. - We must find the right block with the face direction. */ - if (a_BlockFace != BLOCK_FACE_NONE) + if ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) { + if (a_BlockFace == BLOCK_FACE_NONE) + { + return; + } + + /* Check for clickthrough-blocks: + When the user breaks a fire block, the client send the wrong block location. + We must find the right block with the face direction. */ int BlockX = a_BlockX; int BlockY = a_BlockY; int BlockZ = a_BlockZ; @@ -937,17 +942,16 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB a_BlockY = BlockY; a_BlockZ = BlockZ; } - } - if ( - ((a_Status == DIG_STATUS_STARTED) || (a_Status == DIG_STATUS_FINISHED)) && // Only do a radius check for block destruction - things like pickup tossing send coordinates that are to be ignored - ((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; + 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; + } } cPluginManager * PlgMgr = cRoot::Get()->GetPluginManager(); -- cgit v1.2.3 From 4470ebffd72a091cddc46022bb3f5ed378651584 Mon Sep 17 00:00:00 2001 From: Hownaer Date: Thu, 28 Aug 2014 20:49:34 +0200 Subject: Fire can be destroyed with the sword in creative-mode --- src/ClientHandle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 8aa883144..f9c6a664c 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1059,7 +1059,8 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc if ( m_Player->IsGameModeCreative() && - ItemCategory::IsSword(m_Player->GetInventory().GetEquippedItem().m_ItemType) + ItemCategory::IsSword(m_Player->GetInventory().GetEquippedItem().m_ItemType) && + (m_Player->GetWorld()->GetBlock(a_BlockX, a_BlockY, a_BlockZ) != E_BLOCK_FIRE) ) { // Players can't destroy blocks with a Sword in the hand. -- cgit v1.2.3