From 6627b022d4903f1baf8c7bc5cf983ee84f05eb05 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Thu, 1 Oct 2026 17:18:52 -0500 Subject: [PATCH] feat(component): the BBB component only where the client has one The client makes a BBB component (76) for a character (DoObjectPreLoad, LOT 1) and for registry entries (none in the CDClient), and reads it last (LWOBBBComponent::Deserialize: a metadata-source-item bit and the item). DLU wrote a placeholder 0 bit at the end of every construction; now only a character's BBBComponent writes it. Every other object sends one bit less, which the client never read (live non-player constructions decode without it; the zone control object stays byte for byte equal to live). Co-Authored-By: Claude Opus 5.5 --- dGame/Entity.cpp | 14 +++++---- dGame/dComponents/BBBComponent.h | 31 +++++++++++++++++++ .../ReplicaComponentOrderTests.cpp | 6 ++-- 3 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 dGame/dComponents/BBBComponent.h diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index fc00439a9..0d5902846 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -99,6 +99,7 @@ #include "PetCreatorComponent.h" #include "HFLightDirectionGadgetComponent.h" #include "SpawnerComponent.h" +#include "BBBComponent.h" #include "ExhibitComponent.h" #include "PathfindingComponent.h" #include "PhysicsSystemComponent.h" @@ -929,6 +930,12 @@ void Entity::DoObjectComponentLoad(ObjectLoadState& state) { if (id > -1) AddComponent(id); break; } + case eReplicaComponentType::BBB: { + // DoObjectPreLoad gives a character (LOT 1) one with id 0; any other object the registry's + const auto id = m_TemplateID == 1 ? 0 : state.GetComponentID(eReplicaComponentType::BBB, -1); + if (id > -1) AddComponent(id); + break; + } case eReplicaComponentType::ROCKET_LANDING: { // LWORocketAnimationControlComponent: the client makes it from the registry const auto id = state.GetComponentID(eReplicaComponentType::ROCKET_LANDING, -1); @@ -1301,7 +1308,7 @@ namespace { PHANTOM_PHYSICS, SOUND_TRIGGER, RACING_SOUND_TRIGGER, BUFF, DESTROYABLE, COLLECTIBLE, PET, PLAYER_FORCED_MOVEMENT, CHARACTER, INVENTORY, SCRIPT, SKILL, BASE_COMBAT_AI, ITEM, QUICK_BUILD, MOVING_PLATFORM, SWITCH, VENDOR, DONATION_VENDOR, ACHIEVEMENT_VENDOR, - BOUNCER, SCRIPTED_ACTIVITY, SHOOTING_GALLERY, RACING_CONTROL, LUP_EXHIBIT, MODEL, RENDER, MINI_GAME_CONTROL, + BOUNCER, SCRIPTED_ACTIVITY, SHOOTING_GALLERY, RACING_CONTROL, LUP_EXHIBIT, MODEL, RENDER, MINI_GAME_CONTROL, BBB, }; }(); @@ -1343,11 +1350,6 @@ void Entity::WriteComponents(RakNet::BitStream& outBitStream, eReplicaPacketType } component->Serialize(outBitStream, bIsInitialUpdate); } - - // BBB Component, unused currently - // Need to to write0 so that is serialized correctly - // TODO: Implement BBB Component - outBitStream.Write0(); } void Entity::UpdateXMLDoc(tinyxml2::XMLDocument& doc) { diff --git a/dGame/dComponents/BBBComponent.h b/dGame/dComponents/BBBComponent.h new file mode 100644 index 000000000..ae214c835 --- /dev/null +++ b/dGame/dComponents/BBBComponent.h @@ -0,0 +1,31 @@ +#ifndef BBBCOMPONENT_H +#define BBBCOMPONENT_H + +#include "BitStream.h" +#include "Component.h" +#include "dCommonVars.h" +#include "eReplicaComponentType.h" + +/** + * The BBB component (76), as the client's LWOBBBComponent: DoObjectPreLoad gives every character one (and the registry + * any object listing it). It sends whether there is a metadata source item, then the item's ID. + */ +class BBBComponent final : public Component { +public: + static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::BBB; + + BBBComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {} + + // LWOBBBComponent::Deserialize 0x00bd6690 + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override { + outBitStream.Write(m_MetadataSourceItem != LWOOBJID_EMPTY); + if (m_MetadataSourceItem != LWOOBJID_EMPTY) outBitStream.Write(m_MetadataSourceItem); + } + + void SetMetadataSourceItem(const LWOOBJID item) { m_MetadataSourceItem = item; } + +private: + LWOOBJID m_MetadataSourceItem = LWOOBJID_EMPTY; +}; + +#endif // BBBCOMPONENT_H diff --git a/tests/dGameTests/dComponentsTests/ReplicaComponentOrderTests.cpp b/tests/dGameTests/dComponentsTests/ReplicaComponentOrderTests.cpp index d9fad33aa..6430eefb9 100644 --- a/tests/dGameTests/dComponentsTests/ReplicaComponentOrderTests.cpp +++ b/tests/dGameTests/dComponentsTests/ReplicaComponentOrderTests.cpp @@ -283,10 +283,8 @@ namespace { miniGameControlComponent->Serialize(outBitStream, bIsInitialUpdate); } - // BBB Component, unused currently - // Need to to write0 so that is serialized correctly - // TODO: Implement BBB Component - outBitStream.Write0(); + // The BBB component (characters): no metadata source item + if (entity.GetLOT() == 1) outBitStream.Write0(); }