Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Improved initial chunk loading, do not skip near chunks, fixes world …
Browse files Browse the repository at this point in the history
…loading getting stuck
  • Loading branch information
shoghicp committed Oct 5, 2014
1 parent 376e359 commit 9abd2c6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/pocketmine/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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 != ""){
Expand Down

0 comments on commit 9abd2c6

Please sign in to comment.