summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2016-08-29 13:32:34 +0200
committerGitHub <noreply@github.com>2016-08-29 13:32:34 +0200
commitc6c2c5afdf883e2a330b02425e59e5ac5ff25ae3 (patch)
treef1d9104b186d02f5da8f31ed8ce124bfbff3f6b2 /src/ClientHandle.cpp
parentFixed SendUnloadChunk bug (#3353) (diff)
parentProper respawn packets on dimension travel (diff)
downloadcuberite-c6c2c5afdf883e2a330b02425e59e5ac5ff25ae3.tar
cuberite-c6c2c5afdf883e2a330b02425e59e5ac5ff25ae3.tar.gz
cuberite-c6c2c5afdf883e2a330b02425e59e5ac5ff25ae3.tar.bz2
cuberite-c6c2c5afdf883e2a330b02425e59e5ac5ff25ae3.tar.lz
cuberite-c6c2c5afdf883e2a330b02425e59e5ac5ff25ae3.tar.xz
cuberite-c6c2c5afdf883e2a330b02425e59e5ac5ff25ae3.tar.zst
cuberite-c6c2c5afdf883e2a330b02425e59e5ac5ff25ae3.zip
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r--src/ClientHandle.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 882c7f283..6febbfc3a 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -62,6 +62,7 @@ int cClientHandle::s_ClientCount = 0;
// cClientHandle:
cClientHandle::cClientHandle(const AString & a_IPString, int a_ViewDistance) :
+ m_LastSentDimension(dimNotSet),
m_CurrentViewDistance(a_ViewDistance),
m_RequestedViewDistance(a_ViewDistance),
m_IPString(a_IPString),
@@ -368,6 +369,7 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID,
// Return a server login packet
m_Protocol->SendLogin(*m_Player, *World);
+ m_LastSentDimension = World->GetDimension();
// Send Weather if raining:
if ((World->GetWeather() == 1) || (World->GetWeather() == 2))
@@ -2704,7 +2706,21 @@ void cClientHandle::SendResetTitle()
void cClientHandle::SendRespawn(eDimension a_Dimension, bool a_ShouldIgnoreDimensionChecks)
{
- m_Protocol->SendRespawn(a_Dimension, a_ShouldIgnoreDimensionChecks);
+ // If a_ShouldIgnoreDimensionChecks is true, we must be traveling to the same dimension
+ ASSERT((!a_ShouldIgnoreDimensionChecks) || (a_Dimension == m_LastSentDimension));
+
+ if ((!a_ShouldIgnoreDimensionChecks) && (a_Dimension == m_LastSentDimension))
+ {
+ // The client goes crazy if we send a respawn packet with the dimension of the current world
+ // So we send a temporary one first.
+ // This is not needed when the player dies, hence the a_ShouldIgnoreDimensionChecks flag.
+ // a_ShouldIgnoreDimensionChecks is true only at cPlayer::respawn, which is called after
+ // the player dies.
+ eDimension TemporaryDimension = (a_Dimension == dimOverworld) ? dimNether : dimOverworld;
+ m_Protocol->SendRespawn(TemporaryDimension);
+ }
+ m_Protocol->SendRespawn(a_Dimension);
+ m_LastSentDimension = a_Dimension;
}