mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
RegionLoader: mark area as garbage in removeChunk()
This commit is contained in:
parent
5920b0ba40
commit
15401d740f
@ -182,6 +182,23 @@ class RegionLoader{
|
|||||||
return $this->isChunkGenerated(self::getChunkOffset($x, $z));
|
return $this->isChunkGenerated(self::getChunkOffset($x, $z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function disposeGarbageArea(RegionLocationTableEntry $oldLocation) : void{
|
||||||
|
/* release the area containing the old copy to the garbage pool */
|
||||||
|
$this->garbageTable->add($oldLocation);
|
||||||
|
|
||||||
|
$endGarbage = $this->garbageTable->end();
|
||||||
|
$nextSector = $this->nextSector;
|
||||||
|
for(; $endGarbage !== null and $endGarbage->getLastSector() + 1 === $nextSector; $endGarbage = $this->garbageTable->end()){
|
||||||
|
$nextSector = $endGarbage->getFirstSector();
|
||||||
|
$this->garbageTable->remove($endGarbage);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($nextSector !== $this->nextSector){
|
||||||
|
$this->nextSector = $nextSector;
|
||||||
|
ftruncate($this->filePointer, $this->nextSector << 12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ChunkException
|
* @throws ChunkException
|
||||||
@ -226,20 +243,7 @@ class RegionLoader{
|
|||||||
$this->writeLocationIndex($index);
|
$this->writeLocationIndex($index);
|
||||||
|
|
||||||
if($oldLocation !== null){
|
if($oldLocation !== null){
|
||||||
/* release the area containing the old copy to the garbage pool */
|
$this->disposeGarbageArea($oldLocation);
|
||||||
$this->garbageTable->add($oldLocation);
|
|
||||||
|
|
||||||
$endGarbage = $this->garbageTable->end();
|
|
||||||
$nextSector = $this->nextSector;
|
|
||||||
for(; $endGarbage !== null and $endGarbage->getLastSector() + 1 === $nextSector; $endGarbage = $this->garbageTable->end()){
|
|
||||||
$nextSector = $endGarbage->getFirstSector();
|
|
||||||
$this->garbageTable->remove($endGarbage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($nextSector !== $this->nextSector){
|
|
||||||
$this->nextSector = $nextSector;
|
|
||||||
ftruncate($this->filePointer, $this->nextSector << 12);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,8 +253,12 @@ class RegionLoader{
|
|||||||
*/
|
*/
|
||||||
public function removeChunk(int $x, int $z){
|
public function removeChunk(int $x, int $z){
|
||||||
$index = self::getChunkOffset($x, $z);
|
$index = self::getChunkOffset($x, $z);
|
||||||
|
$oldLocation = $this->locationTable[$index];
|
||||||
$this->locationTable[$index] = null;
|
$this->locationTable[$index] = null;
|
||||||
$this->writeLocationIndex($index);
|
$this->writeLocationIndex($index);
|
||||||
|
if($oldLocation !== null){
|
||||||
|
$this->disposeGarbageArea($oldLocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user