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:
Dylan K. Taylor 2020-06-17 21:01:01 +01:00
parent f970be0e4d
commit 1c13ba5656

View File

@ -88,11 +88,10 @@ class NetworkBinaryStream extends BinaryStream{
$animationCount = $this->getLInt();
$animations = [];
for($i = 0; $i < $animationCount; ++$i){
$animations[] = new SkinAnimation(
$skinImage = $this->getSkinImage(),
$animationType = $this->getLInt(),
$animationFrames = $this->getLFloat()
);
$skinImage = $this->getSkinImage();
$animationType = $this->getLInt();
$animationFrames = $this->getLFloat();
$animations[] = new SkinAnimation($skinImage, $animationType, $animationFrames);
}
$capeData = $this->getSkinImage();
$geometryData = $this->getString();
@ -107,13 +106,12 @@ class NetworkBinaryStream extends BinaryStream{
$personaPieceCount = $this->getLInt();
$personaPieces = [];
for($i = 0; $i < $personaPieceCount; ++$i){
$personaPieces[] = new PersonaSkinPiece(
$pieceId = $this->getString(),
$pieceType = $this->getString(),
$packId = $this->getString(),
$isDefaultPiece = $this->getBool(),
$productId = $this->getString()
);
$pieceId = $this->getString();
$pieceType = $this->getString();
$packId = $this->getString();
$isDefaultPiece = $this->getBool();
$productId = $this->getString();
$personaPieces[] = new PersonaSkinPiece($pieceId, $pieceType, $packId, $isDefaultPiece, $productId);
}
$pieceTintColorCount = $this->getLInt();
$pieceTintColors = [];
@ -546,11 +544,10 @@ class NetworkBinaryStream extends BinaryStream{
* Reads a floating-point Vector3 object with coordinates rounded to 4 decimal places.
*/
public function getVector3() : Vector3{
return new Vector3(
$this->getLFloat(),
$this->getLFloat(),
$this->getLFloat()
);
$x = $this->getLFloat();
$y = $this->getLFloat();
$z = $this->getLFloat();
return new Vector3($x, $y, $z);
}
/**
@ -647,12 +644,11 @@ class NetworkBinaryStream extends BinaryStream{
}
protected function getEntityLink() : EntityLink{
return new EntityLink(
$fromEntityUniqueId = $this->getEntityUniqueId(),
$toEntityUniqueId = $this->getEntityUniqueId(),
$type = $this->getByte(),
$immediate = $this->getBool()
);
$fromEntityUniqueId = $this->getEntityUniqueId();
$toEntityUniqueId = $this->getEntityUniqueId();
$type = $this->getByte();
$immediate = $this->getBool();
return new EntityLink($fromEntityUniqueId, $toEntityUniqueId, $type, $immediate);
}
protected function putEntityLink(EntityLink $link) : void{