Merge branch 'stable' into master

# Conflicts:
#	composer.lock
#	resources/vanilla
#	src/command/defaults/StatusCommand.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/level/format/SubChunk.php
This commit is contained in:
Dylan K. Taylor 2020-09-26 13:27:08 +01:00
commit 75e3a0aa0f
7 changed files with 16 additions and 8 deletions

View File

@ -40,6 +40,7 @@ use function fwrite;
use function gc_collect_cycles; use function gc_collect_cycles;
use function gc_disable; use function gc_disable;
use function gc_enable; use function gc_enable;
use function gc_mem_caches;
use function get_class; use function get_class;
use function get_declared_classes; use function get_declared_classes;
use function ini_get; use function ini_get;
@ -276,6 +277,7 @@ class MemoryManager{
} }
$cycles = gc_collect_cycles(); $cycles = gc_collect_cycles();
gc_mem_caches();
Timings::$garbageCollectorTimer->stopTiming(); Timings::$garbageCollectorTimer->stopTiming();

View File

@ -54,9 +54,9 @@ class StatusCommand extends VanillaCommand{
$server = $sender->getServer(); $server = $sender->getServer();
$sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "Server status" . TextFormat::GREEN . " ----"); $sender->sendMessage(TextFormat::GREEN . "---- " . TextFormat::WHITE . "Server status" . TextFormat::GREEN . " ----");
$time = microtime(true) - $server->getStartTime(); $time = (int) (microtime(true) - $server->getStartTime());
$seconds = floor($time % 60); $seconds = $time % 60;
$minutes = null; $minutes = null;
$hours = null; $hours = null;
$days = null; $days = null;

View File

@ -893,7 +893,7 @@ abstract class Entity{
} }
public function getHorizontalFacing() : int{ public function getHorizontalFacing() : int{
$angle = $this->location->yaw % 360; $angle = fmod($this->location->yaw, 360);
if($angle < 0){ if($angle < 0){
$angle += 360.0; $angle += 360.0;
} }

View File

@ -25,11 +25,13 @@ namespace pocketmine\scheduler;
use function gc_collect_cycles; use function gc_collect_cycles;
use function gc_enable; use function gc_enable;
use function gc_mem_caches;
class GarbageCollectionTask extends AsyncTask{ class GarbageCollectionTask extends AsyncTask{
public function onRun() : void{ public function onRun() : void{
gc_enable(); gc_enable();
gc_collect_cycles(); gc_collect_cycles();
gc_mem_caches();
} }
} }

View File

@ -69,11 +69,14 @@ final class RegionGarbageMap{
/** @var RegionLocationTableEntry|null $prevEntry */ /** @var RegionLocationTableEntry|null $prevEntry */
$prevEntry = null; $prevEntry = null;
foreach($usedMap as $firstSector => $entry){ foreach($usedMap as $firstSector => $entry){
$expectedStart = ($prevEntry !== null ? $prevEntry->getLastSector() + 1 : RegionLoader::FIRST_SECTOR); $prevEndPlusOne = ($prevEntry !== null ? $prevEntry->getLastSector() + 1 : RegionLoader::FIRST_SECTOR);
$actualStart = $entry->getFirstSector(); $currentStart = $entry->getFirstSector();
if($expectedStart < $actualStart){ if($prevEndPlusOne < $currentStart){
//found a gap in the table //found a gap in the table
$garbageMap[$expectedStart] = new RegionLocationTableEntry($expectedStart, $actualStart - $expectedStart, 0); $garbageMap[$prevEndPlusOne] = new RegionLocationTableEntry($prevEndPlusOne, $currentStart - $prevEndPlusOne, 0);
}elseif($prevEndPlusOne > $currentStart){
//current entry starts inside the previous. This would be a bug since RegionLoader should prevent this
throw new AssumptionFailedError("Overlapping entries detected");
} }
$prevEntry = $entry; $prevEntry = $entry;
} }

View File

@ -283,6 +283,7 @@ class RegionLoader{
throw new CorruptedRegionException("Corrupted region header (unexpected end of file)"); throw new CorruptedRegionException("Corrupted region header (unexpected end of file)");
} }
/** @var int[] $data */
$data = unpack("N*", $headerRaw); $data = unpack("N*", $headerRaw);
for($i = 0; $i < 1024; ++$i){ for($i = 0; $i < 1024; ++$i){

View File

@ -49,7 +49,7 @@ before_script:
- pecl install channel://pecl.php.net/igbinary-3.1.2 - pecl install channel://pecl.php.net/igbinary-3.1.2
- git clone https://github.com/pmmp/pthreads.git - git clone https://github.com/pmmp/pthreads.git
- cd pthreads - cd pthreads
- git checkout e0f514dfde01c5e7e9cf94c43615918af482a45c - git checkout b81ab29df58fa0fb239a9d5ca1c2380a0d087feb
- phpize - phpize
- ./configure - ./configure
- make - make