From 1dbbf08f1b35b1cd3063214e4494f02c2c87c764 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Thu, 16 May 2013 17:30:34 +0200 Subject: [PATCH] Use other things instead of array_shift --- src/Player.php | 15 ++++++--------- src/PocketMinecraftServer.php | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Player.php b/src/Player.php index b9cb17960e..9f29977bfc 100644 --- a/src/Player.php +++ b/src/Player.php @@ -148,7 +148,7 @@ class Player{ return false; } $this->freedChunks = false; - array_shift($this->chunksOrder); + unset($this->chunksOrder[$c]); $this->chunksLoaded[$c] = true; $id = explode(":", $c); $X = $id[0]; @@ -190,17 +190,14 @@ class Player{ }else{ if(!empty($this->queue)){ $maxtime = $time + 0.0025; - while(microtime(true) < $maxtime){ - $p = array_shift($this->queue); - if($p === null){ - break; - } - switch($p[0]){ + while(microtime(true) < $maxtime and ($p = each($this->queue)) !== false){ + unset($this->queue[$p[0]]); + switch($p[1][0]){ case 0: - $this->dataPacket($p[1]["id"], $p[1], false); + $this->dataPacket($p[1][1]["id"], $p[1][1], false); break; case 1: - eval($p[1]); + eval($p[1][1]); break; } } diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 497cadd55a..430a41e1aa 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -324,7 +324,7 @@ class PocketMinecraftServer{ public function tick(){ $time = microtime(true); if($this->lastTick <= ($time - 0.05)){ - array_shift($this->tickMeasure); + unset($this->tickMeasure[key($this->tickMeasure)]); $this->tickMeasure[] = $this->lastTick = $time; $this->tickerFunction($time); $this->trigger("server.tick", $time);