Decreased chunk ordering times

This commit is contained in:
Shoghi Cervantes 2014-10-17 09:57:18 +02:00
parent 94e9485be9
commit 1c03c3afcf
2 changed files with 8 additions and 8 deletions

View File

@ -695,8 +695,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
++$count; ++$count;
$chunkX = $X + $centerX; $chunkX = $X + $centerX;
$chunkZ = $Z + $centerZ; $chunkZ = $Z + $centerZ;
$index = Level::chunkHash($chunkX, $chunkZ); if(!isset($this->usedChunks[$index = "$chunkX:$chunkZ"])){
if(!isset($this->usedChunks[$index])){
$newOrder[$index] = abs($X) + abs($Z); $newOrder[$index] = abs($X) + abs($Z);
} }
unset($lastChunk[$index]); unset($lastChunk[$index]);
@ -1057,11 +1056,11 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
} }
$oldPos = new Vector3($this->x, $this->y, $this->z); $oldPos = new Vector3($this->x, $this->y, $this->z);
$distance = $oldPos->distance($this->newPosition); $distanceSquared = $oldPos->distanceSquared($this->newPosition);
$revert = false; $revert = false;
if($distance > 100){ if($distanceSquared > 10000){
$revert = true; $revert = true;
}else{ }else{
if($this->chunk === null or !$this->chunk->isGenerated()){ if($this->chunk === null or !$this->chunk->isGenerated()){
@ -1072,7 +1071,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
} }
} }
if(!$revert and $distance != 0){ if(!$revert and $distanceSquared != 0){
$dx = $this->newPosition->x - $this->x; $dx = $this->newPosition->x - $this->x;
$dy = $this->newPosition->y - $this->y; $dy = $this->newPosition->y - $this->y;
$dz = $this->newPosition->z - $this->z; $dz = $this->newPosition->z - $this->z;
@ -1153,8 +1152,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->forceMovement = new Vector3($from->x, $from->y, $from->z); $this->forceMovement = new Vector3($from->x, $from->y, $from->z);
}else{ }else{
$this->forceMovement = null; $this->forceMovement = null;
if($this->nextChunkOrderRun > 4){ if($this->nextChunkOrderRun > 20){
$this->nextChunkOrderRun = 4; $this->nextChunkOrderRun = 20;
} }
} }
} }

View File

@ -36,7 +36,8 @@ abstract class DataPacket extends \stdClass{
abstract public function decode(); abstract public function decode();
protected function reset(){ protected function reset(){
$this->setBuffer(chr($this->pid())); $this->buffer = chr($this->pid());
$this->offset = 0;
} }
public function setBuffer($buffer = ""){ public function setBuffer($buffer = ""){