mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
RegionLoader: added utility function generateSectorMap()
this proved very useful while debugging some internal issues.
This commit is contained in:
parent
627a7c951a
commit
63b14a083c
@ -46,6 +46,7 @@ use function max;
|
||||
use function ord;
|
||||
use function pack;
|
||||
use function str_pad;
|
||||
use function str_repeat;
|
||||
use function stream_set_read_buffer;
|
||||
use function stream_set_write_buffer;
|
||||
use function strlen;
|
||||
@ -381,6 +382,28 @@ class RegionLoader{
|
||||
$this->nextSector = max($this->nextSector, $entry->getLastSector() + 1);
|
||||
}
|
||||
|
||||
public function generateSectorMap(string $usedChar, string $freeChar) : string{
|
||||
$result = str_repeat($freeChar, $this->nextSector);
|
||||
for($i = 0; $i < self::FIRST_SECTOR; ++$i){
|
||||
$result[$i] = $usedChar;
|
||||
}
|
||||
foreach($this->locationTable as $locationTableEntry){
|
||||
if($locationTableEntry === null){
|
||||
continue;
|
||||
}
|
||||
foreach($locationTableEntry->getUsedSectors() as $sectorIndex){
|
||||
if($sectorIndex >= strlen($result)){
|
||||
throw new AssumptionFailedError("This should never happen...");
|
||||
}
|
||||
if($result[$sectorIndex] === $usedChar){
|
||||
throw new AssumptionFailedError("Overlap detected");
|
||||
}
|
||||
$result[$sectorIndex] = $usedChar;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getX() : int{
|
||||
return $this->x;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user