mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
RegionWorldProvider: make loadRegion() return RegionLoader, fix 3 PHPStan null-reference errors
This commit is contained in:
parent
e810a68dd7
commit
219cf2126b
@ -130,7 +130,7 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
|||||||
return $this->path . "/region/r.$regionX.$regionZ." . static::getRegionFileExtension();
|
return $this->path . "/region/r.$regionX.$regionZ." . static::getRegionFileExtension();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadRegion(int $regionX, int $regionZ) : void{
|
protected function loadRegion(int $regionX, int $regionZ) : RegionLoader{
|
||||||
if(!isset($this->regions[$index = morton2d_encode($regionX, $regionZ)])){
|
if(!isset($this->regions[$index = morton2d_encode($regionX, $regionZ)])){
|
||||||
$path = $this->pathToRegion($regionX, $regionZ);
|
$path = $this->pathToRegion($regionX, $regionZ);
|
||||||
|
|
||||||
@ -153,6 +153,7 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
|||||||
|
|
||||||
$this->regions[$index] = $region;
|
$this->regions[$index] = $region;
|
||||||
}
|
}
|
||||||
|
return $this->regions[$index];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function unloadRegion(int $regionX, int $regionZ) : void{
|
protected function unloadRegion(int $regionX, int $regionZ) : void{
|
||||||
@ -221,9 +222,8 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
|||||||
if(!file_exists($this->pathToRegion($regionX, $regionZ))){
|
if(!file_exists($this->pathToRegion($regionX, $regionZ))){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$this->loadRegion($regionX, $regionZ);
|
|
||||||
|
|
||||||
$chunkData = $this->getRegion($regionX, $regionZ)->readChunk($chunkX & 0x1f, $chunkZ & 0x1f);
|
$chunkData = $this->loadRegion($regionX, $regionZ)->readChunk($chunkX & 0x1f, $chunkZ & 0x1f);
|
||||||
if($chunkData !== null){
|
if($chunkData !== null){
|
||||||
return $this->deserializeChunk($chunkData);
|
return $this->deserializeChunk($chunkData);
|
||||||
}
|
}
|
||||||
@ -233,9 +233,7 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
|||||||
|
|
||||||
protected function writeChunk(int $chunkX, int $chunkZ, Chunk $chunk) : void{
|
protected function writeChunk(int $chunkX, int $chunkZ, Chunk $chunk) : void{
|
||||||
self::getRegionIndex($chunkX, $chunkZ, $regionX, $regionZ);
|
self::getRegionIndex($chunkX, $chunkZ, $regionX, $regionZ);
|
||||||
$this->loadRegion($regionX, $regionZ);
|
$this->loadRegion($regionX, $regionZ)->writeChunk($chunkX & 0x1f, $chunkZ & 0x1f, $this->serializeChunk($chunk));
|
||||||
|
|
||||||
$this->getRegion($regionX, $regionZ)->writeChunk($chunkX & 0x1f, $chunkZ & 0x1f, $this->serializeChunk($chunk));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createRegionIterator() : \RegexIterator{
|
private function createRegionIterator() : \RegexIterator{
|
||||||
@ -285,8 +283,7 @@ abstract class RegionWorldProvider extends BaseWorldProvider{
|
|||||||
foreach($this->createRegionIterator() as $region){
|
foreach($this->createRegionIterator() as $region){
|
||||||
$regionX = ((int) $region[1]);
|
$regionX = ((int) $region[1]);
|
||||||
$regionZ = ((int) $region[2]);
|
$regionZ = ((int) $region[2]);
|
||||||
$this->loadRegion($regionX, $regionZ);
|
$count += $this->loadRegion($regionX, $regionZ)->calculateChunkCount();
|
||||||
$count += $this->getRegion($regionX, $regionZ)->calculateChunkCount();
|
|
||||||
$this->unloadRegion($regionX, $regionZ);
|
$this->unloadRegion($regionX, $regionZ);
|
||||||
}
|
}
|
||||||
return $count;
|
return $count;
|
||||||
|
@ -500,21 +500,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/world/format/HeightArray.php
|
path: ../../../src/world/format/HeightArray.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method readChunk\\(\\) on pocketmine\\\\world\\\\format\\\\io\\\\region\\\\RegionLoader\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/format/io/region/RegionWorldProvider.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method writeChunk\\(\\) on pocketmine\\\\world\\\\format\\\\io\\\\region\\\\RegionLoader\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/format/io/region/RegionWorldProvider.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot call method calculateChunkCount\\(\\) on pocketmine\\\\world\\\\format\\\\io\\\\region\\\\RegionLoader\\|null\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/world/format/io/region/RegionWorldProvider.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot call method setDirtyFlag\\(\\) on pocketmine\\\\world\\\\format\\\\Chunk\\|null\\.$#"
|
message: "#^Cannot call method setDirtyFlag\\(\\) on pocketmine\\\\world\\\\format\\\\Chunk\\|null\\.$#"
|
||||||
count: 4
|
count: 4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user