mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 19:03:43 +00:00
First step of moving hand written bitstream code to struct based messages (see docs/PacketArchitecture.md). No wire changes. - GameMsg is now only a server-internal event (delivered to handlers registered with RegisterMsg); NetGameMsg is a wire message with Send(sysAddr) (UNASSIGNED broadcasts), SendToClient(sysAddr) (one client, never broadcasts), WritePacket, Serialize, Deserialize and Handle. Mixing them up is now a compile error. NetGameMsgEvent<T> / DeliverLocally carry a wire message to local handlers; loot drops, pickup, the object debugger, GM invisibility and model RequestUse use them. The GM invisibility message keeps its target, so its bytes are unchanged. - Behaviour change: GameMessageHandler logs and drops messages whose Deserialize fails instead of handling them with default fields (the 4 messages already registered: RequestUse, RequestServerObjectInfo, ShootingGalleryFire, PickupItem). - LUBitStream (kept as on main) gets a virtual destructor (Mail deleted derived packets through the base) and WritePacket, also used by ChatPackets::SendRoutedMsg with identical bytes. - BitStreamUtils::WriteOptional/ReadOptional for default-flag fields and WriteLengthPrefixed/ReadLengthPrefixed for length prefixed strings. - Every message ID enumerator (MessageType::*, ServiceType, Mail's wire enums) is pinned with static_asserts, so renumbering or removing one fails to compile. - Tests: dServerMock copies each sent packet (it kept a pointer to the caller's destroyed BitStream); PacketTestUtils.h compares packets bit for bit; helper tests use hand computed golden bytes and equality with the hand written patterns they replace; compile-time checks keep the wire/internal split in place. - docs/PacketArchitecture.md: survey, target architecture, conventions, verification method and migration plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
1.7 KiB
C++
69 lines
1.7 KiB
C++
#ifndef __GHOSTCOMPONENT__H__
|
|
#define __GHOSTCOMPONENT__H__
|
|
|
|
#include "Component.h"
|
|
#include "eReplicaComponentType.h"
|
|
#include <unordered_set>
|
|
|
|
class NiPoint3;
|
|
|
|
namespace tinyxml2 {
|
|
class XMLDocument;
|
|
}
|
|
|
|
class GhostComponent final : public Component {
|
|
public:
|
|
static inline const eReplicaComponentType ComponentType = eReplicaComponentType::GHOST;
|
|
GhostComponent(Entity* parent, const int32_t componentID);
|
|
~GhostComponent() override;
|
|
|
|
void SetGhostOverride(bool value) { m_GhostOverride = value; };
|
|
|
|
const NiPoint3& GetGhostReferencePoint() const { return m_GhostOverride ? m_GhostOverridePoint : m_GhostReferencePoint; };
|
|
|
|
const NiPoint3& GetOriginGhostReferencePoint() const { return m_GhostReferencePoint; };
|
|
|
|
const NiPoint3& GetGhostOverridePoint() const { return m_GhostOverridePoint; };
|
|
|
|
bool GetGhostOverride() const { return m_GhostOverride; };
|
|
|
|
void SetGhostReferencePoint(const NiPoint3& value);
|
|
|
|
void SetGhostOverridePoint(const NiPoint3& value);
|
|
|
|
void AddLimboConstruction(const LWOOBJID objectId);
|
|
|
|
void RemoveLimboConstruction(const LWOOBJID objectId);
|
|
|
|
void ConstructLimboEntities();
|
|
|
|
void ObserveEntity(const LWOOBJID id);
|
|
|
|
bool IsObserved(const LWOOBJID id);
|
|
|
|
void GhostEntity(const LWOOBJID id);
|
|
|
|
bool OnToggleGMInvis(GameMessages::ToggleGMInvisEvent& event);
|
|
|
|
bool OnGetGMInvis(GameMessages::GetGMInvis& msg);
|
|
|
|
bool MsgGetObjectReportInfo(GameMessages::GetObjectReportInfo& msg);
|
|
|
|
private:
|
|
|
|
NiPoint3 m_GhostReferencePoint;
|
|
|
|
NiPoint3 m_GhostOverridePoint;
|
|
|
|
std::unordered_set<LWOOBJID> m_ObservedEntities;
|
|
|
|
std::unordered_set<LWOOBJID> m_LimboConstructions;
|
|
|
|
bool m_GhostOverride;
|
|
|
|
bool m_IsGMInvisible{ false };
|
|
|
|
};
|
|
|
|
#endif //!__GHOSTCOMPONENT__H__
|