mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
Solved packet encode/decode boilerplate code issue
Something as simple as forgetting the reset() when encoding would cause lots of problems which could go unnoticed. This should be fully backwards-compatible but needs more tests.
This commit is contained in:
@ -52,7 +52,7 @@ class AdventureSettingsPacket extends DataPacket{
|
||||
public $flags = 0;
|
||||
public $userPermission;
|
||||
|
||||
public function decode(){
|
||||
public function decodePayload(){
|
||||
$this->flags = $this->getUnsignedVarInt();
|
||||
$this->userPermission = $this->getUnsignedVarInt();
|
||||
|
||||
@ -69,9 +69,7 @@ class AdventureSettingsPacket extends DataPacket{
|
||||
$this->muted = (bool) ($this->flags & (1 << 10));
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
|
||||
public function encodePayload(){
|
||||
$this->flags |= ((int) $this->worldImmutable);
|
||||
$this->flags |= ((int) $this->noPvp) << 1;
|
||||
$this->flags |= ((int) $this->noPvm) << 2;
|
||||
|
Reference in New Issue
Block a user