pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.28k stars 1.56k forks source link

Broadcast system never reuses packets, because every session has a different serializer context #5623

Closed dktapps closed 1 year ago

dktapps commented 1 year ago

Description

https://github.com/pmmp/PocketMine-MP/blob/b13e97de3d3fb5ff8dd155cf61f5238426ecb15e/src/network/mcpe/StandardPacketBroadcaster.php#L44-L62

This code divides up packet recipients by their packet serializer context. The purpose of this is to allow packets to be encoded differently for different context (to potentially allow for multi version broadcasts in the future).

However, in a moment of epic dumbfuckery, I made every session have its own packet serializer context, as seen here:

https://github.com/pmmp/PocketMine-MP/blob/b13e97de3d3fb5ff8dd155cf61f5238426ecb15e/src/network/mcpe/NetworkSession.php#L215-L216

This means that the broadcaster will encode a separate copy of the packet for every single session, exactly as it was doing before 4.16.0.

dktapps commented 1 year ago

Fixed in next-minor by fa7c38276cc9f44765b70e488b559e3711d39965.