Use other things instead of array_shift

This commit is contained in:
Shoghi Cervantes Pueyo 2013-05-16 17:30:34 +02:00
parent 5277555d33
commit 1dbbf08f1b
2 changed files with 7 additions and 10 deletions

View File

@ -148,7 +148,7 @@ class Player{
return false; return false;
} }
$this->freedChunks = false; $this->freedChunks = false;
array_shift($this->chunksOrder); unset($this->chunksOrder[$c]);
$this->chunksLoaded[$c] = true; $this->chunksLoaded[$c] = true;
$id = explode(":", $c); $id = explode(":", $c);
$X = $id[0]; $X = $id[0];
@ -190,17 +190,14 @@ class Player{
}else{ }else{
if(!empty($this->queue)){ if(!empty($this->queue)){
$maxtime = $time + 0.0025; $maxtime = $time + 0.0025;
while(microtime(true) < $maxtime){ while(microtime(true) < $maxtime and ($p = each($this->queue)) !== false){
$p = array_shift($this->queue); unset($this->queue[$p[0]]);
if($p === null){ switch($p[1][0]){
break;
}
switch($p[0]){
case 0: case 0:
$this->dataPacket($p[1]["id"], $p[1], false); $this->dataPacket($p[1][1]["id"], $p[1][1], false);
break; break;
case 1: case 1:
eval($p[1]); eval($p[1][1]);
break; break;
} }
} }

View File

@ -324,7 +324,7 @@ class PocketMinecraftServer{
public function tick(){ public function tick(){
$time = microtime(true); $time = microtime(true);
if($this->lastTick <= ($time - 0.05)){ if($this->lastTick <= ($time - 0.05)){
array_shift($this->tickMeasure); unset($this->tickMeasure[key($this->tickMeasure)]);
$this->tickMeasure[] = $this->lastTick = $time; $this->tickMeasure[] = $this->lastTick = $time;
$this->tickerFunction($time); $this->tickerFunction($time);
$this->trigger("server.tick", $time); $this->trigger("server.tick", $time);