fix: write what the client reads for a chest, a choice build and a roller

The three components were made from the registry and wrote nothing, so
the client read the next component's bits as theirs.

- LWOChestComponent::Deserialize (0x00c22010), construction only: the
  player (u64) and the loot offer count (u32).
- LWOChoiceBuildComponent::Deserialize (0x00bf26d0): a flag, then the
  state (u32, 0 waiting, 1 building), the built object and the user
  (u64 each). Always in a construction.
- LWORollerComponent::Deserialize (0x00c15920), construction: the level's
  activity_camera_pos and activity_camera_lookat_pos (3 floats each) and
  the projectile skill (u32, the client starts at 1348); then the flag of
  the block about its user, which is never set.

LWOGameObject::Deserialize (0x00f99690) reads the components in the order
of the object's component list, which ObjectLoader2::DoObjectComponentLoad
(0x0105ebb0) fills in the order of FillComponentOrder (0x0101f8e0): the
roller after the shooting gallery and before the moving platform, the
choice build after the moving platform and before the LUP exhibit and the
model, the chest after the zone control and before render. They are
placed against the components their objects have.

The gate rush control (103) is left out: its two registry entries have no
object, and there is no component for it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 15:54:54 -06:00
parent b2fba9d35b
commit c5c90f73a2
9 changed files with 351 additions and 5 deletions

View File

@@ -33,6 +33,7 @@ set(DGAME_DCOMPONENTS_SOURCES
"ProximityMonitorComponent.cpp"
"Activity/RacingControlComponent.cpp"
"RailActivatorComponent.cpp"
"RollerComponent.cpp"
"Activity/QuickBuildComponent.cpp"
"RenderComponent.cpp"
"Physics/RigidbodyPhantomPhysicsComponent.cpp"

View File

@@ -1,17 +1,40 @@
#ifndef CHESTCOMPONENT_H
#define CHESTCOMPONENT_H
#include "BitStream.h"
#include "Component.h"
#include "dCommonVars.h"
#include "eReplicaComponentType.h"
/**
* Chest, as the client's LWOChestComponent makes it from the registry. Nothing of it is sent or done on the server yet.
* Chest, as the client's LWOChestComponent makes it from the registry (LOT 2196). Its construction carries the player
* the chest is for and the number of loot offers in it; nothing else of it is done on the server yet.
*/
class ChestComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::CHEST;
ChestComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {}
// LWOChestComponent::Deserialize (0x00c22010) reads on construction only: the player (u64) and the loot offer count
// (u32), which it keeps when the chest is the local player's. Nothing in an update.
void Serialize(RakNet::BitStream& outBitStream, const bool isConstruction) override {
if (!isConstruction) return;
outBitStream.Write(m_PlayerID);
outBitStream.Write(m_LootOfferCount);
}
LWOOBJID GetPlayerID() const { return m_PlayerID; }
void SetPlayerID(const LWOOBJID value) { m_PlayerID = value; }
uint32_t GetLootOfferCount() const { return m_LootOfferCount; }
void SetLootOfferCount(const uint32_t value) { m_LootOfferCount = value; }
private:
// The player the chest belongs to; none (the client's own start value) until something gives it one
LWOOBJID m_PlayerID = LWOOBJID_EMPTY;
// The loot offers in the chest
uint32_t m_LootOfferCount = 0;
};
#endif // CHESTCOMPONENT_H

View File

@@ -1,17 +1,61 @@
#ifndef CHOICEBUILDCOMPONENT_H
#define CHOICEBUILDCOMPONENT_H
#include "BitStream.h"
#include "Component.h"
#include "dCommonVars.h"
#include "eReplicaComponentType.h"
/**
* Choice build, as the client's LWOChoiceBuildComponent makes it from the registry. Nothing of it is sent or done on the server yet.
* Choice build, as the client's LWOChoiceBuildComponent makes it from the registry (LOTs 5668, 6414, 6462, 7002, 16205).
* Its state, the object built and the player using it are sent; nothing else of it is done on the server yet.
*/
class ChoiceBuildComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::CHOICE_BUILD;
// The client's states (its constructor starts at Waiting)
enum class eState : uint32_t {
Waiting = 0,
Building = 1,
};
ChoiceBuildComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {}
// LWOChoiceBuildComponent::Deserialize (0x00bf26d0) reads, in constructions and updates alike: a flag, then the
// state (u32), the built object (u64) and the user (u64). A construction always carries them.
void Serialize(RakNet::BitStream& outBitStream, const bool isConstruction) override {
outBitStream.Write(isConstruction || m_Dirty);
if (isConstruction || m_Dirty) {
outBitStream.Write(m_State);
outBitStream.Write(m_ChildObject);
outBitStream.Write(m_UserID);
}
if (!isConstruction) m_Dirty = false;
}
eState GetState() const { return m_State; }
LWOOBJID GetChildObject() const { return m_ChildObject; }
LWOOBJID GetUserID() const { return m_UserID; }
// Changes what the clients are told with the next update (the caller serializes the object)
void SetState(const eState state, const LWOOBJID childObject, const LWOOBJID userID) {
m_State = state;
m_ChildObject = childObject;
m_UserID = userID;
m_Dirty = true;
}
private:
eState m_State = eState::Waiting;
// The object the choice build made, none while waiting
LWOOBJID m_ChildObject = LWOOBJID_EMPTY;
// The player using the choice build, none while waiting
LWOOBJID m_UserID = LWOOBJID_EMPTY;
bool m_Dirty = false;
};
#endif // CHOICEBUILDCOMPONENT_H

View File

@@ -0,0 +1,17 @@
#include "RollerComponent.h"
#include "Entity.h"
#include "GeneralUtils.h"
namespace {
// A level point: the three numbers with character 31 between them
NiPoint3 LevelPoint(const Entity& entity, const std::u16string& key) {
const auto parts = GeneralUtils::SplitString(entity.GetVarAsString(key), '\x1f');
return GeneralUtils::TryParse<NiPoint3>(parts).value_or(NiPoint3Constant::ZERO);
}
}
void RollerComponent::LoadConfigData() {
m_CameraPosition = LevelPoint(*m_Parent, u"activity_camera_pos");
m_CameraLookAt = LevelPoint(*m_Parent, u"activity_camera_lookat_pos");
}

View File

@@ -1,17 +1,54 @@
#ifndef ROLLERCOMPONENT_H
#define ROLLERCOMPONENT_H
#include "BitStream.h"
#include "Component.h"
#include "NiPoint3.h"
#include "dCommonVars.h"
#include "eReplicaComponentType.h"
/**
* Roller, as the client's LWORollerComponent makes it from the registry. Nothing of it is sent or done on the server yet.
* Roller (a launcher a player fires from: LOTs 2714, 13951), as the client's LWORollerComponent makes it from the
* registry. Its construction carries the activity camera and the projectile skill; nobody uses one on the server
* yet, so the block about its user is never sent.
*/
class RollerComponent final : public Component {
public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ROLLER;
// The projectile skill the client's constructor starts with (LWORollerComponent::Initialize 0x00cc7e30)
static constexpr uint32_t DEFAULT_PROJECTILE_SKILL = 1348;
RollerComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {}
// The level's activity_camera_pos and activity_camera_lookat_pos (LWORollerComponent::LoadConfigData 0x00c31820);
// both stay at the origin without the key, as in the client
void LoadConfigData() override;
// LWORollerComponent::Deserialize (0x00c15920) reads on construction: the camera position and what it looks at
// (3 floats each) and the projectile skill (u32). Then, in constructions and updates alike, a flag in front of the
// block about the player using it (3 x u64, 3 floats, a float, 3 floats, the player u64, a float): never set here.
void Serialize(RakNet::BitStream& outBitStream, const bool isConstruction) override {
if (isConstruction) {
outBitStream.Write(m_CameraPosition.x);
outBitStream.Write(m_CameraPosition.y);
outBitStream.Write(m_CameraPosition.z);
outBitStream.Write(m_CameraLookAt.x);
outBitStream.Write(m_CameraLookAt.y);
outBitStream.Write(m_CameraLookAt.z);
outBitStream.Write(m_ProjectileSkill);
}
outBitStream.Write0();
}
const NiPoint3& GetCameraPosition() const { return m_CameraPosition; }
const NiPoint3& GetCameraLookAt() const { return m_CameraLookAt; }
uint32_t GetProjectileSkill() const { return m_ProjectileSkill; }
private:
NiPoint3 m_CameraPosition = NiPoint3Constant::ZERO;
NiPoint3 m_CameraLookAt = NiPoint3Constant::ZERO;
uint32_t m_ProjectileSkill = DEFAULT_PROJECTILE_SKILL;
};
#endif // ROLLERCOMPONENT_H