1
0

Fixed chunk neighbor-getting for long distances.

This fixes a server hang when teleporting to coords too far away.
This commit is contained in:
madmaxoft 2014-03-27 18:13:52 +01:00
parent 8c2c4f2463
commit bbebb3a2cd

View File

@ -2510,6 +2510,17 @@ cChunk * cChunk::GetNeighborChunk(int a_BlockX, int a_BlockZ)
cChunk * cChunk::GetRelNeighborChunk(int a_RelX, int a_RelZ)
{
// If the relative coords are too far away, use the parent's chunk lookup instead:
if ((a_RelX < 128) || (a_RelX > 128) || (a_RelZ < -128) || (a_RelZ > 128))
{
int BlockX = m_PosX * cChunkDef::Width + a_RelX;
int BlockZ = m_PosZ * cChunkDef::Width + a_RelZ;
int BlockY, ChunkX, ChunkZ;
AbsoluteToRelative(BlockX, BlockY, BlockZ, ChunkX, ChunkZ);
return m_ChunkMap->GetChunkNoLoad(ChunkX, ZERO_CHUNK_Y, ChunkZ);
}
// Walk the neighbors:
bool ReturnThis = true;
if (a_RelX < 0)
{