Anvil fixes, improved memory settings

This commit is contained in:
Shoghi Cervantes
2015-04-19 11:45:43 +02:00
parent 5860bdcc4d
commit e3c48b22cb
16 changed files with 61 additions and 46 deletions

View File

@ -65,7 +65,8 @@ class AddEntityPacket extends DataPacket{
$this->putFloat($this->speedZ);
$this->putFloat($this->yaw);
$this->putFloat($this->pitch);
$this->put(Binary::writeMetadata($this->metadata));
$meta = Binary::writeMetadata($this->metadata);
$this->put($meta);
$this->putShort(count($this->links));
foreach($this->links as $link){
$this->putLong($link[0]);

View File

@ -78,7 +78,8 @@ class AddPlayerPacket extends DataPacket{
$this->putShort($this->meta);
$this->putByte($this->slim ? 1 : 0);
$this->putString($this->skin);
$this->put(Binary::writeMetadata($this->metadata));
$meta = Binary::writeMetadata($this->metadata);
$this->put($meta);
}
}

View File

@ -57,9 +57,9 @@ abstract class DataPacket extends \stdClass{
return $this->channel;
}
public function setBuffer($buffer = ""){
public function setBuffer(&$buffer = null, $offset = 0){
$this->buffer =& $buffer;
$this->offset = 0;
$this->offset = (int) $offset;
}
public function getOffset(){
@ -81,7 +81,7 @@ abstract class DataPacket extends \stdClass{
return $len === 1 ? $this->buffer{$this->offset++} : substr($this->buffer, ($this->offset += $len) - $len, $len);
}
protected function put($str){
protected function put(&$str){
$this->buffer .= $str;
}
@ -179,7 +179,7 @@ abstract class DataPacket extends \stdClass{
return $this->get($this->getShort());
}
protected function putString($v){
protected function putString(&$v){
$this->putShort(strlen($v));
$this->put($v);
}

View File

@ -46,7 +46,8 @@ class SetEntityDataPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putLong($this->eid);
$this->put(Binary::writeMetadata($this->metadata));
$meta = Binary::writeMetadata($this->metadata);
$this->put($meta);
}
}