1
0

Fix crash for players out of the world. Fixes #4006 (#4007)

This commit is contained in:
Alexander Harkness 2017-09-10 17:45:18 +01:00 committed by GitHub
parent c334824199
commit 4e7325c9e2

View File

@ -1662,7 +1662,9 @@ bool cEntity::MoveToWorld(const AString & a_WorldName, bool a_ShouldSendRespawn)
void cEntity::SetSwimState(cChunk & a_Chunk)
{
int RelY = FloorC(GetPosY() + 0.1);
if ((RelY < 0) || (RelY >= cChunkDef::Height - 1))
int HeadRelY = CeilC(GetPosY() + GetHeight()) - 1;
ASSERT(RelY <= HeadRelY);
if ((RelY < 0) || (HeadRelY >= cChunkDef::Height))
{
m_IsSwimming = false;
m_IsSubmerged = false;
@ -1688,8 +1690,7 @@ void cEntity::SetSwimState(cChunk & a_Chunk)
m_IsSwimming = IsBlockWater(BlockIn);
// Check if the player is submerged:
int HeadHeight = CeilC(GetPosY() + GetHeight()) - 1;
VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, HeadHeight, RelZ, BlockIn));
VERIFY(a_Chunk.UnboundedRelGetBlockType(RelX, HeadRelY, RelZ, BlockIn));
m_IsSubmerged = IsBlockWater(BlockIn);
}