From 1ba32c98c74d80f7ca234ea9f6cbc3ce225cd96f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 17 Jul 2020 23:19:33 +0100 Subject: [PATCH] protocol: avoid potential constructor refactoring packet decode bug if the order of the constructor parameters were changed, it would cause these statements to be reordered, causing packet fields to be decoded in the wrong order. --- .../resourcepacks/ResourcePackInfoEntry.php | 17 ++++++++--------- .../resourcepacks/ResourcePackStackEntry.php | 9 ++++----- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/network/mcpe/protocol/types/resourcepacks/ResourcePackInfoEntry.php b/src/network/mcpe/protocol/types/resourcepacks/ResourcePackInfoEntry.php index e2ed65901..0e0308ece 100644 --- a/src/network/mcpe/protocol/types/resourcepacks/ResourcePackInfoEntry.php +++ b/src/network/mcpe/protocol/types/resourcepacks/ResourcePackInfoEntry.php @@ -91,14 +91,13 @@ class ResourcePackInfoEntry{ } public static function read(PacketSerializer $in) : self{ - return new self( - $uuid = $in->getString(), - $version = $in->getString(), - $sizeBytes = $in->getLLong(), - $encryptionKey = $in->getString(), - $subPackName = $in->getString(), - $contentId = $in->getString(), - $hasScripts = $in->getBool() - ); + $uuid = $in->getString(); + $version = $in->getString(); + $sizeBytes = $in->getLLong(); + $encryptionKey = $in->getString(); + $subPackName = $in->getString(); + $contentId = $in->getString(); + $hasScripts = $in->getBool(); + return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts); } } diff --git a/src/network/mcpe/protocol/types/resourcepacks/ResourcePackStackEntry.php b/src/network/mcpe/protocol/types/resourcepacks/ResourcePackStackEntry.php index 2e809fb7e..1151d37d5 100644 --- a/src/network/mcpe/protocol/types/resourcepacks/ResourcePackStackEntry.php +++ b/src/network/mcpe/protocol/types/resourcepacks/ResourcePackStackEntry.php @@ -59,10 +59,9 @@ class ResourcePackStackEntry{ } public static function read(PacketSerializer $in) : self{ - return new self( - $packId = $in->getString(), - $version = $in->getString(), - $subPackName = $in->getString() - ); + $packId = $in->getString(); + $version = $in->getString(); + $subPackName = $in->getString(); + return new self($packId, $version, $subPackName); } }