Avoid use of internal fields in BinaryStream

This commit is contained in:
Dylan K. Taylor
2019-01-01 16:42:14 +00:00
parent 4a629e1a26
commit f81bbd60e8
9 changed files with 21 additions and 20 deletions

View File

@ -56,7 +56,7 @@ class ChunkRequestTask extends AsyncTask{
$stream = new PacketStream();
$stream->putPacket($pk);
$this->setResult(NetworkCompression::compress($stream->buffer, $this->compressionLevel));
$this->setResult(NetworkCompression::compress($stream->getBuffer(), $this->compressionLevel));
}
public function onCompletion() : void{

View File

@ -31,12 +31,12 @@ class CompressBatchTask extends AsyncTask{
private $data;
/**
* @param PacketStream $stream
* @param string $data
* @param int $compressionLevel
* @param CompressBatchPromise $promise
*/
public function __construct(PacketStream $stream, int $compressionLevel, CompressBatchPromise $promise){
$this->data = $stream->buffer;
public function __construct(string $data, int $compressionLevel, CompressBatchPromise $promise){
$this->data = $data;
$this->level = $compressionLevel;
$this->storeLocal($promise);
}

View File

@ -198,14 +198,14 @@ class NetworkSession{
$packet->decode();
if(!$packet->feof() and !$packet->mayHaveUnreadBytes()){
$remains = substr($packet->buffer, $packet->offset);
$remains = substr($packet->getBuffer(), $packet->getOffset());
$this->server->getLogger()->debug("Still " . strlen($remains) . " bytes unread in " . $packet->getName() . ": 0x" . bin2hex($remains));
}
$ev = new DataPacketReceiveEvent($this->player, $packet);
$ev->call();
if(!$ev->isCancelled() and !$packet->handle($this->handler)){
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->player->getName() . ": 0x" . bin2hex($packet->buffer));
$this->server->getLogger()->debug("Unhandled " . $packet->getName() . " received from " . $this->player->getName() . ": 0x" . bin2hex($packet->getBuffer()));
}
$timings->stopTiming();

View File

@ -32,7 +32,7 @@ class PacketStream extends NetworkBinaryStream{
if(!$packet->isEncoded){
$packet->encode();
}
$this->putString($packet->buffer);
$this->putString($packet->getBuffer());
}
public function getPacket() : DataPacket{

View File

@ -62,7 +62,7 @@ abstract class DataPacket extends NetworkBinaryStream{
}
public function decode() : void{
$this->offset = 0;
$this->rewind();
$this->decodeHeader();
$this->decodePayload();
}

View File

@ -262,7 +262,7 @@ class StartGamePacket extends DataPacket{
$stream->putString($v["name"]);
$stream->putLShort($v["data"]);
}
self::$runtimeIdTable = $stream->buffer;
self::$runtimeIdTable = $stream->getBuffer();
}
$this->put(self::$runtimeIdTable);