mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 17:20:02 +00:00
RegionLevelProvider: Unload regions when finished scanning them, fixes running out of file descriptors during conversion
This commit is contained in:
parent
ad19696364
commit
08c399529d
@ -162,6 +162,13 @@ abstract class RegionLevelProvider extends BaseLevelProvider{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function unloadRegion(int $regionX, int $regionZ) : void{
|
||||||
|
if(isset($this->regions[$hash = Level::chunkHash($regionX, $regionZ)])){
|
||||||
|
$this->regions[$hash]->close();
|
||||||
|
unset($this->regions[$hash]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function close() : void{
|
public function close() : void{
|
||||||
foreach($this->regions as $index => $region){
|
foreach($this->regions as $index => $region){
|
||||||
$region->close();
|
$region->close();
|
||||||
@ -246,6 +253,8 @@ abstract class RegionLevelProvider extends BaseLevelProvider{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->unloadRegion($rX, $rZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,6 +263,7 @@ abstract class RegionLevelProvider extends BaseLevelProvider{
|
|||||||
foreach($this->createRegionIterator() as $region){
|
foreach($this->createRegionIterator() as $region){
|
||||||
$this->loadRegion((int) $region[1], (int) $region[2]);
|
$this->loadRegion((int) $region[1], (int) $region[2]);
|
||||||
$count += $this->getRegion((int) $region[1], (int) $region[2])->calculateChunkCount();
|
$count += $this->getRegion((int) $region[1], (int) $region[2])->calculateChunkCount();
|
||||||
|
$this->unloadRegion((int) $region[1], (int) $region[2]);
|
||||||
}
|
}
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user