mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Level: fix chunk locks not getting released on generation errors
This commit is contained in:
parent
edd150971e
commit
7b17a83227
@ -2296,28 +2296,33 @@ class Level implements ChunkManager, Metadatable{
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function generateChunkCallback(int $x, int $z, Chunk $chunk){
|
||||
public function generateChunkCallback(int $x, int $z, ?Chunk $chunk){
|
||||
Timings::$generationCallbackTimer->startTiming();
|
||||
if(isset($this->chunkPopulationQueue[$index = Level::chunkHash($x, $z)])){
|
||||
$oldChunk = $this->getChunk($x, $z, false);
|
||||
for($xx = -1; $xx <= 1; ++$xx){
|
||||
for($zz = -1; $zz <= 1; ++$zz){
|
||||
unset($this->chunkPopulationLock[Level::chunkHash($x + $xx, $z + $zz)]);
|
||||
}
|
||||
}
|
||||
unset($this->chunkPopulationQueue[$index]);
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
if(($oldChunk === null or !$oldChunk->isPopulated()) and $chunk->isPopulated()){
|
||||
$this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($this, $chunk));
|
||||
|
||||
foreach($this->getChunkLoaders($x, $z) as $loader){
|
||||
$loader->onChunkPopulated($chunk);
|
||||
if($chunk !== null){
|
||||
$oldChunk = $this->getChunk($x, $z, false);
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
if(($oldChunk === null or !$oldChunk->isPopulated()) and $chunk->isPopulated()){
|
||||
$this->server->getPluginManager()->callEvent(new ChunkPopulateEvent($this, $chunk));
|
||||
|
||||
foreach($this->getChunkLoaders($x, $z) as $loader){
|
||||
$loader->onChunkPopulated($chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif(isset($this->chunkPopulationLock[$index])){
|
||||
unset($this->chunkPopulationLock[$index]);
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
}else{
|
||||
if($chunk !== null){
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
}
|
||||
}elseif($chunk !== null){
|
||||
$this->setChunk($x, $z, $chunk, false);
|
||||
}
|
||||
Timings::$generationCallbackTimer->stopTiming();
|
||||
|
@ -152,11 +152,11 @@ class PopulationTask extends AsyncTask{
|
||||
$c = $this->{"chunk$i"};
|
||||
if($c !== null){
|
||||
$c = Chunk::fastDeserialize($c);
|
||||
$level->generateChunkCallback($c->getX(), $c->getZ(), $c);
|
||||
$level->generateChunkCallback($c->getX(), $c->getZ(), $this->state ? $c : null);
|
||||
}
|
||||
}
|
||||
|
||||
$level->generateChunkCallback($chunk->getX(), $chunk->getZ(), $chunk);
|
||||
$level->generateChunkCallback($chunk->getX(), $chunk->getZ(), $this->state ? $chunk : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user