Fixed issues with CPU loop

This commit is contained in:
Shoghi Cervantes 2014-03-12 03:25:50 +01:00
parent e033af0e72
commit 18117b91ed
4 changed files with 11 additions and 11 deletions

View File

@ -116,7 +116,7 @@ namespace PocketMine {
$opts = getopt("", array("enable-ansi", "disable-ansi", "data-path:", "no-wizard"));
define("PocketMine\\DATA", isset($opts["data-path"]) ? realpath($opts["data-path"]) . DIRECTORY_SEPARATOR : \PocketMine\PATH);
if((strpos(strtoupper(php_uname("s")), "WIN") or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"])){
if((!strpos(strtoupper(php_uname("s")), "WIN") or isset($opts["enable-ansi"])) and !isset($opts["disable-ansi"])){
define("PocketMine\\ANSI", true);
} else{
define("PocketMine\\ANSI", false);

View File

@ -588,18 +588,16 @@ class Server{
$this->packetHandler($packet);
$lastLoop = 0;
}
if($this->tick() > 0){
$lastLoop = 0;
} else{
if(($ticks = $this->tick()) === 0){
++$lastLoop;
if($lastLoop < 64){
if($lastLoop < 16){
usleep(1);
} elseif($lastLoop < 128){
usleep(1000);
} elseif($lastLoop < 256){
usleep(100);
} elseif($lastLoop < 512){
usleep(512);
usleep(2000);
} else{
usleep(5000);
usleep(4000);
}
}
}

View File

@ -21,6 +21,8 @@
namespace PocketMine;
use PocketMine\Level;
class TimeAPI{
public static $phases = array(
"day" => 0,

View File

@ -262,7 +262,7 @@ abstract class Block extends Position{
self::DANDELION => new Dandelion(),
self::CYAN_FLOWER => new CyanFlower(),
self::BROWN_MUSHROOM => new BrownMushroom(),
self::RED_MUSHROOM => new RedMushRoom(),
self::RED_MUSHROOM => new RedMushroom(),
self::GOLD_BLOCK => new Gold(),
self::IRON_BLOCK => new Iron(),
self::DOUBLE_SLAB => new DoubleSlab(),