From d699a97bb79e0a31c9f8fd388fb1a2eddabb70a1 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 15 Feb 2014 01:39:37 +0100 Subject: [PATCH] small things --- src/Player.php | 4 ++-- src/pmf/PMFLevel.php | 13 ++++++------- src/world/Level.php | 4 ++++ src/world/generator/WorldGenerator.php | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Player.php b/src/Player.php index 95dc81c5c..4819c0dc5 100644 --- a/src/Player.php +++ b/src/Player.php @@ -210,8 +210,8 @@ class Player{ $c = key($this->chunksOrder); $d = @$this->chunksOrder[$c]; - if($c === null){ - $this->server->schedule(50, array($this, "getNextChunk")); + if($c === null or $d === null){ + $this->server->schedule(40, array($this, "getNextChunk")); return false; } unset($this->chunksOrder[$c]); diff --git a/src/pmf/PMFLevel.php b/src/pmf/PMFLevel.php index 61bb92e44..46f6bb98d 100644 --- a/src/pmf/PMFLevel.php +++ b/src/pmf/PMFLevel.php @@ -212,26 +212,25 @@ class PMFLevel extends PMF{ $this->isGenerated($X - 1, $Z - 1) and $this->isGenerated($X + 1, $Z - 1) and $this->isGenerated($X - 1, $Z + 1)){ - $this->level->populateChunk($X, $Z); + $this->level->populateChunk($X, $Z); $this->saveChunk($X, $Z); } } public function loadChunk($X, $Z){ - $X = (int) $X; - $Z = (int) $Z; - $index = self::getIndex($X, $Z); if($this->isChunkLoaded($X, $Z)){ return true; } + $index = self::getIndex($X, $Z); $path = $this->getChunkPath($X, $Z); if(!file_exists($path)){ if($this->generateChunk($X, $Z) === false){ return false; - }elseif($this->isGenerating === 0){ - $this->populateChunk($X, $Z); - return true; } + if($this->isGenerating === 0){ + $this->populateChunk($X, $Z); + } + return true; } $chunk = @gzopen($path, "rb"); diff --git a/src/world/Level.php b/src/world/Level.php index dc8a8bff3..01a256dde 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -77,6 +77,10 @@ class Level{ unset($this->usedChunks[$X.".".$Z][$player->CID]); } + public function isChunkPopulated($X, $Z){ + return $this->level->isPopulated($X, $Z); + } + public function checkTime(){ if(!isset($this->level)){ return false; diff --git a/src/world/generator/WorldGenerator.php b/src/world/generator/WorldGenerator.php index b9b842d53..9825adea5 100644 --- a/src/world/generator/WorldGenerator.php +++ b/src/world/generator/WorldGenerator.php @@ -50,7 +50,7 @@ class WorldGenerator{ //Generate 4 chunks for spawning players for($Z = 7; $Z <= 8; ++$Z){ - for($X = 7; $X <= 8; ++$X){ + for($X = 7; $X <= 9; ++$X){ $this->level->level->loadChunk($X, $Z); } }