mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 02:38:54 +00:00
PacketPool: Properly deal with varint packet IDs now that BatchPacket is gone
This commit is contained in:
parent
64ecc373be
commit
cdcafb1e75
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user