fix: encode CameraFovInstruction ease type as string - #8
Open
Nyrok wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
CameraInstructionSerializer_v827writes the FOV instruction's ease type as a byte enum ordinal. Bedrock clients read it as a length-prefixed string, so anyCameraInstructionPacketcarrying aCameraFovInstructiondesyncs the client's packet reader and disconnects it (disconnect.closed, no server-side error). Every codec from v827 up to v2168 inherits this write, which currently makes FOV instructions unusable on PNX.The same string encoding is already used for spline easing in
CameraInstructionSerializer_v924, and PMMP's BedrockProtocol matches it for FOV: https://github.com/pmmp/BedrockProtocol/blob/master/src/types/camera/CameraFovInstruction.phpI fixed this once on the 2.x server in PowerNukkitX/PowerNukkitX#2528, when the encoding still lived in
cn.nukkit.network.protocol.CameraInstructionPacket. The 3.x migration moved serialization into this library, which never got the equivalent change.Fix
Two lines in
CameraInstructionSerializer_v827: write withhelper.writeString(buf, easeType.getSerializeName()), read withEasingType.fromName(helper.readString(buf)). All later codecs inherit it.Tested in game on 1.26.42 (protocol 2168): before, every FOV instruction kicked the client; with the string encoding, FOV and easing work normally.