Files
DarkflameServer/dGame/dComponents/ChestComponent.h
Aaron Kimbrell c5c90f73a2 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>
2026-11-10 15:54:54 -06:00

41 lines
1.5 KiB
C++

#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 (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