From f03408c9bda99893297110c00f9bf0607ed3d1b8 Mon Sep 17 00:00:00 2001 From: maybegreat48 <96936658+maybegreat48@users.noreply.github.com> Date: Wed, 10 Jul 2024 00:12:20 +0000 Subject: [PATCH] fix rlGamerHandle (#23) Co-authored-by: maybegreat48 --- CMakeLists.txt | 4 ++-- network/rlGamerHandle.cpp | 22 ++++++++++++++++++++++ network/rlGamerHandle.hpp | 17 +++++++++++------ rage/datBitBuffer.hpp | 2 +- 4 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 network/rlGamerHandle.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c2ca894..c37d08b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,8 @@ set(CMAKE_REQUIRED_QUIET ON) set(OK TRUE) file(GLOB_RECURSE HEADERS "**.hpp") -file(GLOB_RECURSE SRC_MAIN "classes.cpp") -source_group(FILES ${SRC_MAIN}) +file(GLOB_RECURSE SRC_MAIN "**.cpp") +source_group(FILES "${SRC_MAIN}") add_library(RDR-Classes MODULE "${SRC_MAIN}") add_compile_definitions(_CRT_SECURE_NO_WARNINGS) diff --git a/network/rlGamerHandle.cpp b/network/rlGamerHandle.cpp new file mode 100644 index 0000000..8bd6e39 --- /dev/null +++ b/network/rlGamerHandle.cpp @@ -0,0 +1,22 @@ +#include "rlGamerHandle.hpp" +#include "rage/datBitBuffer.hpp" + +bool rage::rlGamerHandle::Serialize(rage::datBitBuffer& buf) const +{ + buf.Write(m_Platform, 8); + if (m_Platform != 3) + return false; + buf.Write(m_RockstarId, 64); + buf.Write(m_UnkData, 16); + return true; +} + +bool rage::rlGamerHandle::Deserialize(rage::datBitBuffer& buf) +{ + m_Platform = buf.Read(8); + if (m_Platform != 3) + return false; + m_RockstarId = buf.Read(64); + m_UnkData = buf.Read(16); + return true; +} diff --git a/network/rlGamerHandle.hpp b/network/rlGamerHandle.hpp index 4c19087..62c9d23 100644 --- a/network/rlGamerHandle.hpp +++ b/network/rlGamerHandle.hpp @@ -4,22 +4,27 @@ namespace rage { + class datBitBuffer; + #pragma pack(push,8) class rlGamerHandle { public: - uint64_t m_rockstar_id; //0x0000 - uint8_t m_platform; //0x0008 - uint8_t unk_0009; //0x0009 + uint64_t m_RockstarId; // 0x00 + uint16_t m_UnkData; // 0x08 + uint8_t m_Platform; // 0x0A inline rlGamerHandle() = default; inline rlGamerHandle(uint64_t rockstar_id) : - m_rockstar_id(rockstar_id), - m_platform(3), - unk_0009(0) + m_RockstarId(rockstar_id), + m_Platform(3), + m_UnkData(0) { } + + bool Serialize(rage::datBitBuffer& buf) const; + bool Deserialize(rage::datBitBuffer& buf); }; //Size: 0x0010 static_assert(sizeof(rlGamerHandle) == 0x10); #pragma pack(pop) diff --git a/rage/datBitBuffer.hpp b/rage/datBitBuffer.hpp index 95317da..b59eaf9 100644 --- a/rage/datBitBuffer.hpp +++ b/rage/datBitBuffer.hpp @@ -151,7 +151,7 @@ namespace rage inline bool WriteQword(uint64_t value, int size) { if (size <= 32) - return WriteDword(value, size); + return WriteDword(static_cast(value), size); int low = (int)(value) & 0xFFFFFFFF; int high = (int)((uint64_t)value >> 32);