mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 11:58:00 +00:00
Merge branch 'stable'
This commit is contained in:
@@ -695,9 +695,9 @@ class InGamePacketHandler extends PacketHandler{
|
||||
$raw = $matches[1];
|
||||
$lastComma = -1;
|
||||
$newParts = [];
|
||||
$quoteType = null;
|
||||
$inQuotes = false;
|
||||
for($i = 0, $len = strlen($raw); $i <= $len; ++$i){
|
||||
if($i === $len or ($raw[$i] === "," and $quoteType === null)){
|
||||
if($i === $len or ($raw[$i] === "," and !$inQuotes)){
|
||||
$part = substr($raw, $lastComma + 1, $i - ($lastComma + 1));
|
||||
if(trim($part) === ""){ //regular parts will have quotes or something else that makes them non-empty
|
||||
$part = '""';
|
||||
@@ -705,12 +705,13 @@ class InGamePacketHandler extends PacketHandler{
|
||||
$newParts[] = $part;
|
||||
$lastComma = $i;
|
||||
}elseif($raw[$i] === '"'){
|
||||
if($quoteType === null){
|
||||
$quoteType = $raw[$i];
|
||||
}elseif($raw[$i] === $quoteType){
|
||||
for($backslashes = 0; $backslashes < $i && $raw[$i - $backslashes - 1] === "\\"; ++$backslashes){}
|
||||
if(!$inQuotes){
|
||||
$inQuotes = true;
|
||||
}else{
|
||||
$backslashes = 0;
|
||||
for(; $backslashes < $i && $raw[$i - $backslashes - 1] === "\\"; ++$backslashes){}
|
||||
if(($backslashes % 2) === 0){ //unescaped quote
|
||||
$quoteType = null;
|
||||
$inQuotes = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -82,7 +82,7 @@ class LoginPacketHandler extends PacketHandler{
|
||||
new SkinImage(
|
||||
$animation[LoginPacket::I_ANIMATION_IMAGE_HEIGHT],
|
||||
$animation[LoginPacket::I_ANIMATION_IMAGE_WIDTH],
|
||||
base64_decode($animation[LoginPacket::I_ANIMATION_IMAGE_DATA])
|
||||
base64_decode($animation[LoginPacket::I_ANIMATION_IMAGE_DATA], true)
|
||||
),
|
||||
$animation[LoginPacket::I_ANIMATION_IMAGE_TYPE],
|
||||
$animation[LoginPacket::I_ANIMATION_IMAGE_FRAMES]
|
||||
@@ -90,12 +90,12 @@ class LoginPacketHandler extends PacketHandler{
|
||||
}
|
||||
$skinData = new SkinData(
|
||||
$packet->clientData[LoginPacket::I_SKIN_ID],
|
||||
base64_decode($packet->clientData[LoginPacket::I_SKIN_RESOURCE_PATCH]),
|
||||
new SkinImage($packet->clientData[LoginPacket::I_SKIN_HEIGHT], $packet->clientData[LoginPacket::I_SKIN_WIDTH], base64_decode($packet->clientData[LoginPacket::I_SKIN_DATA])),
|
||||
base64_decode($packet->clientData[LoginPacket::I_SKIN_RESOURCE_PATCH], true),
|
||||
new SkinImage($packet->clientData[LoginPacket::I_SKIN_HEIGHT], $packet->clientData[LoginPacket::I_SKIN_WIDTH], base64_decode($packet->clientData[LoginPacket::I_SKIN_DATA], true)),
|
||||
$animations,
|
||||
new SkinImage($packet->clientData[LoginPacket::I_CAPE_HEIGHT], $packet->clientData[LoginPacket::I_CAPE_WIDTH], base64_decode($packet->clientData[LoginPacket::I_CAPE_DATA])),
|
||||
base64_decode($packet->clientData[LoginPacket::I_GEOMETRY_DATA]),
|
||||
base64_decode($packet->clientData[LoginPacket::I_ANIMATION_DATA]),
|
||||
new SkinImage($packet->clientData[LoginPacket::I_CAPE_HEIGHT], $packet->clientData[LoginPacket::I_CAPE_WIDTH], base64_decode($packet->clientData[LoginPacket::I_CAPE_DATA], true)),
|
||||
base64_decode($packet->clientData[LoginPacket::I_GEOMETRY_DATA], true),
|
||||
base64_decode($packet->clientData[LoginPacket::I_ANIMATION_DATA], true),
|
||||
$packet->clientData[LoginPacket::I_PREMIUM_SKIN],
|
||||
$packet->clientData[LoginPacket::I_PERSONA_SKIN],
|
||||
$packet->clientData[LoginPacket::I_PERSONA_CAPE_ON_CLASSIC_SKIN],
|
||||
|
@@ -94,7 +94,7 @@ class AdventureSettingsPacket extends DataPacket implements ClientboundPacket, S
|
||||
}
|
||||
|
||||
public function getFlag(int $flag) : bool{
|
||||
if($flag & self::BITFLAG_SECOND_SET){
|
||||
if(($flag & self::BITFLAG_SECOND_SET) !== 0){
|
||||
return ($this->flags2 & $flag) !== 0;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class AdventureSettingsPacket extends DataPacket implements ClientboundPacket, S
|
||||
}
|
||||
|
||||
public function setFlag(int $flag, bool $value) : void{
|
||||
if($flag & self::BITFLAG_SECOND_SET){
|
||||
if(($flag & self::BITFLAG_SECOND_SET) !== 0){
|
||||
$flagSet =& $this->flags2;
|
||||
}else{
|
||||
$flagSet =& $this->flags;
|
||||
|
@@ -60,7 +60,7 @@ class AnimatePacket extends DataPacket implements ClientboundPacket, Serverbound
|
||||
protected function decodePayload() : void{
|
||||
$this->action = $this->getVarInt();
|
||||
$this->entityRuntimeId = $this->getEntityRuntimeId();
|
||||
if($this->action & 0x80){
|
||||
if(($this->action & 0x80) !== 0){
|
||||
$this->float = $this->getLFloat();
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class AnimatePacket extends DataPacket implements ClientboundPacket, Serverbound
|
||||
protected function encodePayload() : void{
|
||||
$this->putVarInt($this->action);
|
||||
$this->putEntityRuntimeId($this->entityRuntimeId);
|
||||
if($this->action & 0x80){
|
||||
if(($this->action & 0x80) !== 0){
|
||||
$this->putLFloat($this->float);
|
||||
}
|
||||
}
|
||||
|
@@ -304,13 +304,13 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
$parameter->isOptional = $this->getBool();
|
||||
$parameter->flags = $this->getByte();
|
||||
|
||||
if($parameter->paramType & self::ARG_FLAG_ENUM){
|
||||
if(($parameter->paramType & self::ARG_FLAG_ENUM) !== 0){
|
||||
$index = ($parameter->paramType & 0xffff);
|
||||
$parameter->enum = $enums[$index] ?? null;
|
||||
if($parameter->enum === null){
|
||||
throw new BadPacketException("deserializing $name parameter $parameter->paramName: expected enum at $index, but got none");
|
||||
}
|
||||
}elseif($parameter->paramType & self::ARG_FLAG_POSTFIX){
|
||||
}elseif(($parameter->paramType & self::ARG_FLAG_POSTFIX) !== 0){
|
||||
$index = ($parameter->paramType & 0xffff);
|
||||
$parameter->postfix = $postfixes[$index] ?? null;
|
||||
if($parameter->postfix === null){
|
||||
@@ -374,8 +374,8 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
* @phpstan-param array<int, string> $postfixes
|
||||
*/
|
||||
private function argTypeToString(int $argtype, array $postfixes) : string{
|
||||
if($argtype & self::ARG_FLAG_VALID){
|
||||
if($argtype & self::ARG_FLAG_ENUM){
|
||||
if(($argtype & self::ARG_FLAG_VALID) !== 0){
|
||||
if(($argtype & self::ARG_FLAG_ENUM) !== 0){
|
||||
return "stringenum (" . ($argtype & 0xffff) . ")";
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
case self::ARG_TYPE_COMMAND:
|
||||
return "command";
|
||||
}
|
||||
}elseif($argtype & self::ARG_FLAG_POSTFIX){
|
||||
}elseif(($argtype & self::ARG_FLAG_POSTFIX) !== 0){
|
||||
$postfix = $postfixes[$argtype & 0xffff];
|
||||
|
||||
return "int (postfix $postfix)";
|
||||
@@ -422,7 +422,7 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{
|
||||
/** @var CommandEnum[] $enums */
|
||||
$enums = [];
|
||||
|
||||
$addEnumFn = static function(CommandEnum $enum) use (&$enums, &$enumIndexes, &$enumValueIndexes){
|
||||
$addEnumFn = static function(CommandEnum $enum) use (&$enums, &$enumIndexes, &$enumValueIndexes) : void{
|
||||
if(!isset($enumIndexes[$enum->getName()])){
|
||||
$enums[$enumIndexes[$enum->getName()] = count($enumIndexes)] = $enum;
|
||||
}
|
||||
|
@@ -42,8 +42,8 @@ class ClientCacheBlobStatusPacket extends DataPacket implements ServerboundPacke
|
||||
*/
|
||||
public static function create(array $hitHashes, array $missHashes) : self{
|
||||
//type checks
|
||||
(static function(int ...$hashes){})(...$hitHashes);
|
||||
(static function(int ...$hashes){})(...$missHashes);
|
||||
(static function(int ...$hashes) : void{})(...$hitHashes);
|
||||
(static function(int ...$hashes) : void{})(...$missHashes);
|
||||
|
||||
$result = new self;
|
||||
$result->hitHashes = $hitHashes;
|
||||
|
@@ -40,7 +40,7 @@ class ClientCacheMissResponsePacket extends DataPacket implements ClientboundPac
|
||||
*/
|
||||
public static function create(array $blobs) : self{
|
||||
//type check
|
||||
(static function(ChunkCacheBlob ...$blobs){})(...$blobs);
|
||||
(static function(ChunkCacheBlob ...$blobs) : void{})(...$blobs);
|
||||
|
||||
$result = new self;
|
||||
$result->blobs = $blobs;
|
||||
|
@@ -60,7 +60,7 @@ class LevelChunkPacket extends DataPacket implements ClientboundPacket{
|
||||
* @param int[] $usedBlobHashes
|
||||
*/
|
||||
public static function withCache(int $chunkX, int $chunkZ, int $subChunkCount, array $usedBlobHashes, string $extraPayload) : self{
|
||||
(static function(int ...$hashes){})(...$usedBlobHashes);
|
||||
(static function(int ...$hashes) : void{})(...$usedBlobHashes);
|
||||
$result = new self;
|
||||
$result->chunkX = $chunkX;
|
||||
$result->chunkZ = $chunkZ;
|
||||
|
@@ -59,7 +59,7 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
private function maybeReadCoord(int $flag) : int{
|
||||
if($this->flags & $flag){
|
||||
if(($this->flags & $flag) !== 0){
|
||||
return $this->getVarInt();
|
||||
}
|
||||
return 0;
|
||||
@@ -69,7 +69,7 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
private function maybeReadRotation(int $flag) : float{
|
||||
if($this->flags & $flag){
|
||||
if(($this->flags & $flag) !== 0){
|
||||
return $this->getByteRotation();
|
||||
}
|
||||
return 0.0;
|
||||
@@ -87,13 +87,13 @@ class MoveActorDeltaPacket extends DataPacket implements ClientboundPacket{
|
||||
}
|
||||
|
||||
private function maybeWriteCoord(int $flag, int $val) : void{
|
||||
if($this->flags & $flag){
|
||||
if(($this->flags & $flag) !== 0){
|
||||
$this->putVarInt($val);
|
||||
}
|
||||
}
|
||||
|
||||
private function maybeWriteRotation(int $flag, float $val) : void{
|
||||
if($this->flags & $flag){
|
||||
if(($this->flags & $flag) !== 0){
|
||||
$this->putByteRotation($val);
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ use pocketmine\utils\BinaryDataException;
|
||||
|
||||
class PacketPool{
|
||||
/** @var \SplFixedArray<Packet> */
|
||||
protected static $pool = null;
|
||||
protected static $pool;
|
||||
|
||||
public static function init() : void{
|
||||
static::$pool = new \SplFixedArray(256);
|
||||
|
@@ -122,7 +122,7 @@ final class RuntimeBlockMapping{
|
||||
*/
|
||||
private static function randomizeTable(array $table) : array{
|
||||
$postSeed = mt_rand(); //save a seed to set afterwards, to avoid poor quality randoms
|
||||
mt_srand(getmypid() ?: 0); //Use a seed which is the same on all threads. This isn't a secure seed, but we don't care.
|
||||
mt_srand(getmypid()); //Use a seed which is the same on all threads. This isn't a secure seed, but we don't care.
|
||||
shuffle($table);
|
||||
mt_srand($postSeed); //restore a good quality seed that isn't dependent on PID
|
||||
return $table;
|
||||
|
@@ -35,7 +35,7 @@ class CommandEnumConstraint{
|
||||
* @param int[] $constraints
|
||||
*/
|
||||
public function __construct(CommandEnum $enum, int $valueOffset, array $constraints){
|
||||
(static function(int ...$_){})(...$constraints);
|
||||
(static function(int ...$_) : void{})(...$constraints);
|
||||
if(!isset($enum->getValues()[$valueOffset])){
|
||||
throw new \InvalidArgumentException("Invalid enum value offset $valueOffset");
|
||||
}
|
||||
|
@@ -498,7 +498,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
* @see NetworkBinaryStream::putVector3()
|
||||
*/
|
||||
public function putVector3Nullable(?Vector3 $vector) : void{
|
||||
if($vector){
|
||||
if($vector !== null){
|
||||
$this->putVector3($vector);
|
||||
}else{
|
||||
$this->putLFloat(0.0);
|
||||
@@ -520,7 +520,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
* @throws BinaryDataException
|
||||
*/
|
||||
public function getByteRotation() : float{
|
||||
return (float) ($this->getByte() * (360 / 256));
|
||||
return ($this->getByte() * (360 / 256));
|
||||
}
|
||||
|
||||
public function putByteRotation(float $rotation) : void{
|
||||
|
Reference in New Issue
Block a user