mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Avoid parameter ordering bugs during packet decoding
A PhpStorm refactor could have side effects on code that directly reads stuff from the packet input stream in the arguments block, because those calls will get moved into a different order if the constructor gets refactored. This would, obviously, break packet decoding, so that's something we should avoid and really should not encourage.
This commit is contained in:
parent
f970be0e4d
commit
1c13ba5656
@ -88,11 +88,10 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
$animationCount = $this->getLInt();
|
$animationCount = $this->getLInt();
|
||||||
$animations = [];
|
$animations = [];
|
||||||
for($i = 0; $i < $animationCount; ++$i){
|
for($i = 0; $i < $animationCount; ++$i){
|
||||||
$animations[] = new SkinAnimation(
|
$skinImage = $this->getSkinImage();
|
||||||
$skinImage = $this->getSkinImage(),
|
$animationType = $this->getLInt();
|
||||||
$animationType = $this->getLInt(),
|
$animationFrames = $this->getLFloat();
|
||||||
$animationFrames = $this->getLFloat()
|
$animations[] = new SkinAnimation($skinImage, $animationType, $animationFrames);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$capeData = $this->getSkinImage();
|
$capeData = $this->getSkinImage();
|
||||||
$geometryData = $this->getString();
|
$geometryData = $this->getString();
|
||||||
@ -107,13 +106,12 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
$personaPieceCount = $this->getLInt();
|
$personaPieceCount = $this->getLInt();
|
||||||
$personaPieces = [];
|
$personaPieces = [];
|
||||||
for($i = 0; $i < $personaPieceCount; ++$i){
|
for($i = 0; $i < $personaPieceCount; ++$i){
|
||||||
$personaPieces[] = new PersonaSkinPiece(
|
$pieceId = $this->getString();
|
||||||
$pieceId = $this->getString(),
|
$pieceType = $this->getString();
|
||||||
$pieceType = $this->getString(),
|
$packId = $this->getString();
|
||||||
$packId = $this->getString(),
|
$isDefaultPiece = $this->getBool();
|
||||||
$isDefaultPiece = $this->getBool(),
|
$productId = $this->getString();
|
||||||
$productId = $this->getString()
|
$personaPieces[] = new PersonaSkinPiece($pieceId, $pieceType, $packId, $isDefaultPiece, $productId);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
$pieceTintColorCount = $this->getLInt();
|
$pieceTintColorCount = $this->getLInt();
|
||||||
$pieceTintColors = [];
|
$pieceTintColors = [];
|
||||||
@ -546,11 +544,10 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
* Reads a floating-point Vector3 object with coordinates rounded to 4 decimal places.
|
* Reads a floating-point Vector3 object with coordinates rounded to 4 decimal places.
|
||||||
*/
|
*/
|
||||||
public function getVector3() : Vector3{
|
public function getVector3() : Vector3{
|
||||||
return new Vector3(
|
$x = $this->getLFloat();
|
||||||
$this->getLFloat(),
|
$y = $this->getLFloat();
|
||||||
$this->getLFloat(),
|
$z = $this->getLFloat();
|
||||||
$this->getLFloat()
|
return new Vector3($x, $y, $z);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -647,12 +644,11 @@ class NetworkBinaryStream extends BinaryStream{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function getEntityLink() : EntityLink{
|
protected function getEntityLink() : EntityLink{
|
||||||
return new EntityLink(
|
$fromEntityUniqueId = $this->getEntityUniqueId();
|
||||||
$fromEntityUniqueId = $this->getEntityUniqueId(),
|
$toEntityUniqueId = $this->getEntityUniqueId();
|
||||||
$toEntityUniqueId = $this->getEntityUniqueId(),
|
$type = $this->getByte();
|
||||||
$type = $this->getByte(),
|
$immediate = $this->getBool();
|
||||||
$immediate = $this->getBool()
|
return new EntityLink($fromEntityUniqueId, $toEntityUniqueId, $type, $immediate);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function putEntityLink(EntityLink $link) : void{
|
protected function putEntityLink(EntityLink $link) : void{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user