From 9abd2c63f498681b2cef0520b02783b5a46ef80c Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 6 Oct 2014 00:45:02 +0200 Subject: [PATCH] Improved initial chunk loading, do not skip near chunks, fixes world loading getting stuck --- src/pocketmine/Player.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index dce4bb4cc..4eb4e5e83 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -612,7 +612,11 @@ public function sendNextChunk(){ $Z = null; Level::getXZ($index, $X, $Z); if(!$this->getLevel()->isChunkPopulated($X, $Z)){ - continue; + if($this->spawned === true){ + continue; + }else{ + break; + } } unset($this->loadQueue[$index]); @@ -704,7 +708,7 @@ public function orderChunks(){ $chunkZ = $Z + $centerZ; $index = Level::chunkHash($chunkX, $chunkZ); if(!isset($this->usedChunks[$index])){ - if($this->level->isChunkPopulated($chunkX, $chunkZ)){ + if($this->spawned === false or $this->level->isChunkPopulated($chunkX, $chunkZ)){ $newOrder[$index] = $distance; }else{ $generateQueue->insert([$chunkX, $chunkZ], $distance); @@ -729,7 +733,7 @@ public function orderChunks(){ } $i = 0; - while(count($this->loadQueue) < 8 and $generateQueue->count() > 0 and $i < 32){ + while($generateQueue->count() > 0 and $i < 32){ $d = $generateQueue->extract(); $this->getLevel()->generateChunk($d[0], $d[1]); ++$i; @@ -2240,7 +2244,7 @@ public function close($message = "", $reason = "generic reason"){ } $this->tasks = []; - if($this->connected === true){ + if($this->connected and !$this->closed){ $this->connected = false; if($this->username != ""){