Faster generation, ticks catch up when slower

This commit is contained in:
Shoghi Cervantes 2014-06-15 16:54:28 +02:00
parent ed5325c069
commit e6224be46f
3 changed files with 5 additions and 4 deletions

View File

@ -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;

View File

@ -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
}
}
}

@ -1 +1 @@
Subproject commit cac93ad971a0b2792f4bb9873c73a76254dd1f7d
Subproject commit 79e7386ed8f655af65af9c4878173df4a8bf7e04