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

@ -217,7 +217,7 @@ class Network{
if($pk->pid() === Info::BATCH_PACKET){
throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket");
}
$pk->setBuffer(substr($str, $offset));
$pk->setBuffer($str, $offset);
$pk->decode();
$p->handleDataPacket($pk);
$offset += $pk->getOffset();

View File

@ -147,10 +147,10 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
$this->players[$identifier]->handleDataPacket($pk);
}
}catch(\Exception $e){
if(\pocketmine\DEBUG > 1){
if(\pocketmine\DEBUG > 1 and isset($pk)){
$logger = $this->server->getLogger();
if($logger instanceof MainLogger){
//$logger->debug("Packet " . get_class($pk) . " 0x" . bin2hex($packet->buffer));
$logger->debug("Packet " . get_class($pk) . " 0x" . bin2hex($packet->buffer));
$logger->logException($e);
}
}
@ -255,7 +255,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
$data = new UnknownPacket();
$data->packetID = $pid;
}
$data->setBuffer(substr($buffer, 1));
$data->setBuffer($buffer, 1);
return $data;
}

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