mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Use integers instead of booleans
This commit is contained in:
parent
4523b15991
commit
d0af367395
@ -29,7 +29,7 @@ class PMFLevel extends PMF{
|
||||
private $chunks = array();
|
||||
private $chunkChange = array();
|
||||
private $chunkInfo = array();
|
||||
public $isGenerating = false;
|
||||
public $isGenerating = 0;
|
||||
|
||||
public function getData($index){
|
||||
if(!isset($this->levelData[$index])){
|
||||
@ -186,19 +186,12 @@ class PMFLevel extends PMF{
|
||||
if(!file_exists(dirname($path))){
|
||||
@mkdir(dirname($path), 0755);
|
||||
}
|
||||
if($this->isGenerating === false){
|
||||
$this->isGenerating = true;
|
||||
$this->initCleanChunk($X, $Z);
|
||||
$ret = $this->level->generateChunk($X, $Z);
|
||||
$ret = $ret and $this->level->populateChunk($X, $Z);
|
||||
$this->saveChunk($X, $Z);
|
||||
$this->isGenerating = false;
|
||||
}else{
|
||||
$this->initCleanChunk($X, $Z);
|
||||
$ret = $this->level->generateChunk($X, $Z);
|
||||
$ret = $ret and $this->level->populateChunk($X, $Z);
|
||||
$this->saveChunk($X, $Z);
|
||||
}
|
||||
++$this->isGenerating;
|
||||
$this->initCleanChunk($X, $Z);
|
||||
$ret = $this->level->generateChunk($X, $Z);
|
||||
$ret = $ret and $this->level->populateChunk($X, $Z);
|
||||
$this->saveChunk($X, $Z);
|
||||
--$this->isGenerating;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@ -211,7 +204,7 @@ class PMFLevel extends PMF{
|
||||
}
|
||||
$path = $this->getChunkPath($X, $Z);
|
||||
if(!file_exists($path)){
|
||||
if($this->isGenerating === true){
|
||||
if($this->isGenerating > 0){
|
||||
$this->level->generateChunk($X, $Z);
|
||||
$this->saveChunk($X, $Z);
|
||||
}elseif($this->generateChunk($X, $Z) === false){
|
||||
@ -219,14 +212,10 @@ class PMFLevel extends PMF{
|
||||
}
|
||||
}
|
||||
|
||||
if($this->isGenerating === false and !$this->isPopulated($X, $Z)){
|
||||
if($this->isGenerating === false){
|
||||
$this->isGenerating = true;
|
||||
$this->level->populateChunk($X, $Z);
|
||||
$this->isGenerating = false;
|
||||
}else{
|
||||
$this->level->populateChunk($X, $Z);
|
||||
}
|
||||
if($this->isGenerating === 0 and !$this->isPopulated($X, $Z)){
|
||||
++$this->isGenerating;
|
||||
$this->level->populateChunk($X, $Z);
|
||||
--$this->isGenerating;
|
||||
}
|
||||
|
||||
$chunk = @gzopen($path, "rb");
|
||||
@ -334,7 +323,7 @@ class PMFLevel extends PMF{
|
||||
}
|
||||
|
||||
public function setMiniChunk($X, $Z, $Y, $data){
|
||||
if($this->isGenerating === true){
|
||||
if($this->isGenerating > 0){
|
||||
$this->initCleanChunk($X, $Z);
|
||||
}elseif($this->isChunkLoaded($X, $Z) === false){
|
||||
$this->loadChunk($X, $Z);
|
||||
@ -538,7 +527,7 @@ class PMFLevel extends PMF{
|
||||
public function saveChunk($X, $Z){
|
||||
$X = (int) $X;
|
||||
$Z = (int) $Z;
|
||||
if($this->isGenerating === true){
|
||||
if($this->isGenerating > 0){
|
||||
$this->initCleanChunk($X, $Z);
|
||||
}elseif(!$this->isChunkLoaded($X, $Z)){
|
||||
return false;
|
||||
|
@ -105,7 +105,7 @@ class Level{
|
||||
$now = microtime(true);
|
||||
$this->players = $this->server->api->player->getAll($this);
|
||||
|
||||
if($this->level->isGenerating === false and count($this->changedCount) > 0){
|
||||
if($this->level->isGenerating === 0 and count($this->changedCount) > 0){
|
||||
arsort($this->changedCount);
|
||||
foreach($this->changedCount as $index => $count){
|
||||
if($count < 582){//Optimal value, calculated using the relation between minichunks and single packets
|
||||
|
Loading…
x
Reference in New Issue
Block a user