fix(wire): UnSmash only writes duration when it is not the default

THIS CHANGES THE BYTES SENT TO THE CLIENT (intentionally).

UnSmash::Serialize wrote the "duration != 3.0f" flag but guarded the
value with "builderID != 3.0f" (a typo), so the 32-bit duration was
always written, even after a 0 flag. The LEGO Universe 1.10.64 client
(GameMessage::UnSmash::Serialize/Deserialize @ 00dc0e80/00dc0f50,
default 3.0f @ 017e66b4) writes it only when
duration != 3.0f. The client read the flag and ignored the trailing 32
bits, so this removes 4 junk bytes from default UnSmash messages;
messages with a non-default duration are unchanged.

Uses WriteOptional/ReadOptional and adds Deserialize. Verified with
hand computed golden bits for every flag combination and round trips.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-26 10:28:08 -05:00
parent 350d35dab5
commit ac858dd1e2
4 changed files with 64 additions and 4 deletions

View File

@@ -6450,10 +6450,14 @@ namespace GameMessages {
}
void UnSmash::Serialize(RakNet::BitStream& stream) const {
stream.Write(builderID != LWOOBJID_EMPTY);
if (builderID != LWOOBJID_EMPTY) stream.Write(builderID);
stream.Write(duration != 3.0f);
if (builderID != 3.0f) stream.Write(duration);
// Both fields are optional with a default, like the client's GameMessage::UnSmash::Serialize.
BitStreamUtils::WriteOptional(stream, builderID, LWOOBJID_EMPTY);
BitStreamUtils::WriteOptional(stream, duration, 3.0f);
}
bool UnSmash::Deserialize(RakNet::BitStream& stream) {
VALIDATE_READ(BitStreamUtils::ReadOptional(stream, builderID, LWOOBJID_EMPTY));
VALIDATE_READ(BitStreamUtils::ReadOptional(stream, duration, 3.0f));
return true;
}
void PlayBehaviorSound::Serialize(RakNet::BitStream& stream) const {

View File

@@ -890,6 +890,7 @@ namespace GameMessages {
UnSmash() : NetGameMsg(MessageType::Game::UN_SMASH) {}
void Serialize(RakNet::BitStream& stream) const override;
bool Deserialize(RakNet::BitStream& stream) override;
LWOOBJID builderID{ LWOOBJID_EMPTY };
float duration{ 3.0f };