From ebc2fd3abf4cf7b8469692ea1913407d097259d6 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Wed, 30 Sep 2026 08:39:23 -0500 Subject: [PATCH] fix(pet): write the names bit on updates too The client reads the moderation and names bit whenever the pet component is dirty, on updates as well as on construction (LWOPetComponent::Deserialize), and live wrote a 0 there on updates. DLU wrote it only on construction, so on an update the client took the next component's first bit (a combat AI's dirty bit) for it. Co-Authored-By: Claude Opus 5.5 --- dGame/dComponents/PetComponent.cpp | 5 ++++- .../dComponentsTests/PetComponentTests.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 9e3296b6b..8cf32bafc 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -96,7 +96,10 @@ void PetComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpd outBitStream.Write(m_Owner); } - if (bIsInitialUpdate) { + // The client reads this bit on every update while dirty (as live wrote it): the names follow when it is set + if (!bIsInitialUpdate) { + outBitStream.Write0(); + } else { outBitStream.Write(tamed); if (tamed) { outBitStream.Write(m_ModerationStatus); diff --git a/tests/dGameTests/dComponentsTests/PetComponentTests.cpp b/tests/dGameTests/dComponentsTests/PetComponentTests.cpp index 9b7846078..a351c719a 100644 --- a/tests/dGameTests/dComponentsTests/PetComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/PetComponentTests.cpp @@ -41,3 +41,15 @@ TEST_F(PetTest, PlacementNewAddComponentTest) { ASSERT_EQ(petComponent->GetParent()->GetObjectID(), 15); ASSERT_EQ(petComponent->GetAbility(), ePetAbilityType::Invalid); } + +// The client reads the names bit on every update while the pet is dirty (as live wrote it); DLU wrote it only on +// construction, so the client took the next component's first bit for it +TEST_F(PetTest, UpdateWritesTheNamesBit) { + petComponent->Serialize(bitStream, false); + // dirty, status, ability, interaction, owner, names + EXPECT_EQ(bitStream.GetNumberOfBitsUsed(), 1u + 32 + 32 + 1 + 1 + 1); + bitStream.IgnoreBits(1 + 32 + 32 + 1 + 1); + bool names = true; + ASSERT_TRUE(bitStream.Read(names)); + EXPECT_FALSE(names); +}