RegionLoader: backport 62185d476bc2463be6de20604cd4ef83733dcce2

This commit is contained in:
Dylan K. Taylor 2019-10-20 19:59:02 +01:00
parent 0aed7f86f5
commit 93cb9390e0

View File

@ -31,7 +31,7 @@ use function array_fill;
use function ceil; use function ceil;
use function chr; use function chr;
use function fclose; use function fclose;
use function fgetc; use function feof;
use function file_exists; use function file_exists;
use function filesize; use function filesize;
use function fopen; use function fopen;
@ -283,7 +283,7 @@ class RegionLoader{
$fileOffset = $offset << 12; $fileOffset = $offset << 12;
fseek($this->filePointer, $fileOffset); fseek($this->filePointer, $fileOffset);
if(fgetc($this->filePointer) === false){ //Try and read from the location if(feof($this->filePointer)){
throw new CorruptedRegionException("Region file location offset x=$x,z=$z points to invalid file location $fileOffset"); throw new CorruptedRegionException("Region file location offset x=$x,z=$z points to invalid file location $fileOffset");
}elseif(isset($usedOffsets[$offset])){ }elseif(isset($usedOffsets[$offset])){
self::getChunkCoords($usedOffsets[$offset], $existingX, $existingZ); self::getChunkCoords($usedOffsets[$offset], $existingX, $existingZ);