mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +00:00
Do not sleep on main Thread when actions are being done
This commit is contained in:
parent
980ee223d0
commit
bf412b1c20
@ -473,8 +473,9 @@ class MainServer{
|
|||||||
$this->tickMeasure[] = $this->lastTick = $time;
|
$this->tickMeasure[] = $this->lastTick = $time;
|
||||||
unset($this->tickMeasure[key($this->tickMeasure)]);
|
unset($this->tickMeasure[key($this->tickMeasure)]);
|
||||||
++$this->ticks;
|
++$this->ticks;
|
||||||
$this->tickerFunction($time);
|
return $this->tickerFunction($time);
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function clientID($ip, $port){
|
public static function clientID($ip, $port){
|
||||||
@ -565,6 +566,8 @@ class MainServer{
|
|||||||
if($packet instanceof Packet){
|
if($packet instanceof Packet){
|
||||||
$this->packetHandler($packet);
|
$this->packetHandler($packet);
|
||||||
$lastLoop = 0;
|
$lastLoop = 0;
|
||||||
|
}elseif($this->tick() > 0){
|
||||||
|
$lastLoop = 0;
|
||||||
}else{
|
}else{
|
||||||
++$lastLoop;
|
++$lastLoop;
|
||||||
if($lastLoop < 16){
|
if($lastLoop < 16){
|
||||||
@ -620,6 +623,7 @@ class MainServer{
|
|||||||
$this->preparedSQL->selectActions->bindValue(":time", $time, SQLITE3_FLOAT);
|
$this->preparedSQL->selectActions->bindValue(":time", $time, SQLITE3_FLOAT);
|
||||||
$actions = $this->preparedSQL->selectActions->execute();
|
$actions = $this->preparedSQL->selectActions->execute();
|
||||||
|
|
||||||
|
$actionCount = 0;
|
||||||
if($actions instanceof SQLite3Result){
|
if($actions instanceof SQLite3Result){
|
||||||
while(($action = $actions->fetchArray(SQLITE3_ASSOC)) !== false){
|
while(($action = $actions->fetchArray(SQLITE3_ASSOC)) !== false){
|
||||||
$cid = $action["ID"];
|
$cid = $action["ID"];
|
||||||
@ -630,6 +634,7 @@ class MainServer{
|
|||||||
if(!@is_callable($this->schedule[$cid][0])){
|
if(!@is_callable($this->schedule[$cid][0])){
|
||||||
$return = false;
|
$return = false;
|
||||||
}else{
|
}else{
|
||||||
|
++$actionCount;
|
||||||
$return = call_user_func($this->schedule[$cid][0], $this->schedule[$cid][1], $this->schedule[$cid][2]);
|
$return = call_user_func($this->schedule[$cid][0], $this->schedule[$cid][1], $this->schedule[$cid][2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,6 +646,7 @@ class MainServer{
|
|||||||
}
|
}
|
||||||
$actions->finalize();
|
$actions->finalize();
|
||||||
}
|
}
|
||||||
|
return $actionCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function event($event,callable $func){
|
public function event($event,callable $func){
|
||||||
|
@ -216,7 +216,7 @@ class HumanEntity extends CreatureEntity implements ProjectileSourceEntity, Inve
|
|||||||
|
|
||||||
public function getSlot($slot){
|
public function getSlot($slot){
|
||||||
$slot = (int) $slot;
|
$slot = (int) $slot;
|
||||||
if(!($this->inventory[$slot] instanceof Item)){
|
if(!isset($this->inventory[$slot])){
|
||||||
$this->inventory[$slot] = BlockAPI::getItem(AIR, 0, 0);
|
$this->inventory[$slot] = BlockAPI::getItem(AIR, 0, 0);
|
||||||
}
|
}
|
||||||
return $this->inventory[$slot];
|
return $this->inventory[$slot];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user