mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Anvil fixes, improved memory settings
This commit is contained in:
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user