PacketPool: Properly deal with varint packet IDs now that BatchPacket is gone

This commit is contained in:
Dylan K. Taylor 2018-07-19 15:19:33 +01:00
parent 64ecc373be
commit cdcafb1e75

View File

@ -23,6 +23,8 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol; namespace pocketmine\network\mcpe\protocol;
use pocketmine\utils\Binary;
class PacketPool{ class PacketPool{
/** @var \SplFixedArray<DataPacket> */ /** @var \SplFixedArray<DataPacket> */
protected static $pool = null; protected static $pool = null;
@ -165,8 +167,9 @@ class PacketPool{
* @return DataPacket * @return DataPacket
*/ */
public static function getPacket(string $buffer) : DataPacket{ public static function getPacket(string $buffer) : DataPacket{
$pk = static::getPacketById(ord($buffer{0})); $offset = 0;
$pk->setBuffer($buffer); $pk = static::getPacketById(Binary::readUnsignedVarInt($buffer, $offset));
$pk->setBuffer($buffer, $offset);
return $pk; return $pk;
} }