added PlayerStoreNotify

This commit is contained in:
REL
2025-01-07 23:36:27 -05:00
parent e56a6228aa
commit e65f046520
7 changed files with 355 additions and 76 deletions

View File

@@ -2,6 +2,17 @@
#include <cstdint>
#include <span>
#define PROPERTY_GET_CONST(type, name, funcBody) \
type get_##name() const funcBody \
__declspec(property(get = get_##name)) type name;
enum class PacketType : uint8_t
{
None = 0,
Achivement = 1,
Inventory = 2,
};
template <typename T>
class Array
{
@@ -21,27 +32,41 @@ public:
std::span<T> AsSpan() {
return { vector, max_length };
}
template <typename U>
U As() {
return reinterpret_cast<U>(vector);
}
};
static_assert(alignof(Array<uint8_t>) == 8, "Array alignment is incorrect");
static_assert(offsetof(Array<uint8_t>, vector) == 32, "vector offset is incorrect");
#pragma pack(push, 1)
struct PacketMeta
class PacketMeta
{
uint16_t HeadMagic;
uint16_t CmdId;
uint16_t HeaderLength;
uint32_t DataLength;
uint8_t Data[1];
public:
uint16_t m_HeadMagic;
uint16_t m_CmdId;
uint16_t m_HeaderLength;
uint32_t m_DataLength;
uint8_t m_Data[1];
PacketMeta() = delete;
PROPERTY_GET_CONST(uint16_t, HeadMagic, { return _byteswap_ushort(m_HeadMagic); });
PROPERTY_GET_CONST(uint16_t, CmdId, { return _byteswap_ushort(m_CmdId); });
PROPERTY_GET_CONST(uint16_t, HeaderLength, { return _byteswap_ushort(m_HeaderLength); });
PROPERTY_GET_CONST(uint32_t, DataLength, { return _byteswap_ulong(m_DataLength); });
std::span<uint8_t> AsSpan() {
return {Data, DataLength};
return { m_Data, DataLength };
}
};
#pragma pack(pop)
static_assert(offsetof(PacketMeta, CmdId) == 2, "CmdId offset is incorrect");
static_assert(offsetof(PacketMeta, HeaderLength) == 4, "HeadLength offset is incorrect");
static_assert(offsetof(PacketMeta, DataLength) == 6, "DataLength offset is incorrect");
static_assert(offsetof(PacketMeta, Data) == 10, "Data offset is incorrect");
static_assert(offsetof(PacketMeta, m_CmdId) == 2, "CmdId offset is incorrect");
static_assert(offsetof(PacketMeta, m_HeaderLength) == 4, "HeadLength offset is incorrect");
static_assert(offsetof(PacketMeta, m_DataLength) == 6, "DataLength offset is incorrect");
static_assert(offsetof(PacketMeta, m_Data) == 10, "Data offset is incorrect");