fix(network): correct dest inversion in newPacket(nbt) and null packet size (BUG-058, BUG-059)#54
Open
ximaks00-hue wants to merge 1 commit into
Conversation
…t size (BUG-058, BUG-059)
Owner
|
This is a complex network change, so we'll wait for testing. |
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.
Summary
Two regressions in
Network.scalaaffecting packet routing and size calculation.BUG-058 —
newPacket(nbt)invertsdestkey checkFile:
src/main/scala/li/cil/oc/server/network/Network.scala:567-569Root cause: The condition loading the
destinationfield from NBT is inverted:Save side (line 727) correctly writes
"dest"only whendestination != null && !destination.isEmpty. So:dest = "node-abc"→ NBT contains key"dest"nbt.contains("dest")→true→destination = null→ packet becomes broadcastImpact: Any targeted modem packet (linked card, relay with unicast) saved in a hub/switch queue is silently converted to a broadcast after world reload. Routing breaks for all targeted transmissions that survive a reload cycle.
Note: This bug is identical in Original 1.12.2 (
if (nbt.hasKey("dest")) null else getString). It is not a CE regression per se, but the CE code inherits it — correcting it here brings CE ahead of Original.Fix: Swap the branches:
BUG-059 —
Packet.sizecountsnull/None/unit as 4 bytes instead of 1File:
src/main/scala/li/cil/oc/server/network/Network.scala:709Root cause:
In OC's packet size calculation, a
null/None/unit value represents an empty/void slot. Original counted it as 1 byte. CE counts it as 4 bytes — a 4x inflation for void slots.Impact:
null/Nonevalues hitmaxNetworkPacketSize~4x soonerFix:
=> 1(matches Original).Verification
savewrites"dest"when targeted →containsis true on load → inverted condition assignsnull→ routing bug confirmed.nullvalues → CE size 40 bytes; Original 10 bytes. AtmaxNetworkPacketSize = 8192, CE rejects packets that are mostly sparse data.Test plan