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;
}
$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;
}
}

View File

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