DataPacket: inject buffer via parameter instead of class field (packet & stream separation, step 2)

this is not complete yet, but the final change (having the binarystream actually come from outside) is a little more disruptive, and some extra changes need to be made. This will grant some sanity in the meantime without breaking too much stuff.
This commit is contained in:
Dylan K. Taylor
2020-02-25 16:19:11 +00:00
parent a633e415ef
commit 5c2ae0257c
145 changed files with 1704 additions and 1562 deletions

View File

@ -26,6 +26,7 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\network\mcpe\handler\PacketHandler;
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
class ScriptCustomEventPacket extends DataPacket{ //TODO: this doesn't have handlers in either client or server in the game as of 1.8
public const NETWORK_ID = ProtocolInfo::SCRIPT_CUSTOM_EVENT_PACKET;
@ -35,14 +36,14 @@ class ScriptCustomEventPacket extends DataPacket{ //TODO: this doesn't have hand
/** @var string json data */
public $eventData;
protected function decodePayload() : void{
$this->eventName = $this->buf->getString();
$this->eventData = $this->buf->getString();
protected function decodePayload(NetworkBinaryStream $in) : void{
$this->eventName = $in->getString();
$this->eventData = $in->getString();
}
protected function encodePayload() : void{
$this->buf->putString($this->eventName);
$this->buf->putString($this->eventData);
protected function encodePayload(NetworkBinaryStream $out) : void{
$out->putString($this->eventName);
$out->putString($this->eventData);
}
public function handle(PacketHandler $handler) : bool{