mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 20:14:31 +00:00
Faster generation, ticks catch up when slower
This commit is contained in:
@@ -644,7 +644,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->chunksOrder = $newOrder;
|
||||
|
||||
$i = 0;
|
||||
while(count($this->chunksOrder) === 0 and $generateQueue->count() > 0 and $i < 8){
|
||||
while(count($this->chunksOrder) < 3 and $generateQueue->count() > 0 and $i < 16){
|
||||
$d = $generateQueue->extract();
|
||||
$this->getLevel()->generateChunk($d[0], $d[1]);
|
||||
++$i;
|
||||
|
@@ -63,7 +63,7 @@ class TickScheduler extends \Thread{
|
||||
|
||||
public function run(){
|
||||
$tickTime = microtime(true);
|
||||
$this->hasTick = true;
|
||||
$this->tickMeasure = $this->sleepTime;
|
||||
while(true){
|
||||
$this->synchronized(function (){
|
||||
$this->hasTick = true;
|
||||
@@ -73,7 +73,8 @@ class TickScheduler extends \Thread{
|
||||
|
||||
$this->tickMeasure = (int) ((($time = microtime(true)) - $tickTime) * 1000000);
|
||||
$tickTime = $time;
|
||||
usleep($this->sleepTime - 100); //Remove a few ms for processing
|
||||
$sleepTime = $this->sleepTime * ($this->sleepTime / max($this->sleepTime, $this->tickMeasure));
|
||||
usleep($sleepTime - 100); //Remove a few ms for processing
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user