Unify rlGamerHandle code and fix chat inaccuracies. (#2883)

This commit is contained in:
gir489 2024-03-27 16:43:31 -04:00 committed by GitHub
parent 659cffa6f7
commit cde9c23323
5 changed files with 16 additions and 38 deletions

View File

@ -3,7 +3,7 @@ include(FetchContent)
FetchContent_Declare(
gtav_classes
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
GIT_TAG 09a586011a296cf8ce3ffb9c15db7ce474ea4363
GIT_TAG a3031a89788141f292a83d18587277e04d367c4a
GIT_PROGRESS TRUE
CONFIGURE_COMMAND ""
BUILD_COMMAND ""

View File

@ -9,14 +9,6 @@
namespace big
{
inline void gamer_handle_serialize(rage::rlGamerHandle& hnd, rage::datBitBuffer& buf)
{
constexpr int PC_PLATFORM = 3;
buf.Write<uint8_t>(PC_PLATFORM, 8);
buf.WriteInt64(*(int64_t*)&hnd.m_rockstar_id, 64);
buf.Write<uint8_t>(hnd.unk_0009, 8);
}
bool hooks::send_chat_message(void* team_mgr, rage::rlGamerInfo* local_gamer_info, char* message, bool is_team)
{
if (g.session.chat_commands && message[0] == g.session.chat_command_prefix)

View File

@ -19,12 +19,11 @@
inline void gamer_handle_deserialize(rage::rlGamerHandle& hnd, rage::datBitBuffer& buf)
{
constexpr int PC_PLATFORM = 3;
if ((hnd.m_platform = buf.Read<uint8_t>(8)) != PC_PLATFORM)
if ((hnd.m_platform = buf.Read<uint8_t>(sizeof(hnd.m_platform))) != rage::rlPlatforms::PC)
return;
buf.ReadInt64((int64_t*)&hnd.m_rockstar_id, 64);
hnd.unk_0009 = buf.Read<uint8_t>(8);
buf.ReadPeerId(&hnd.m_rockstar_id);
hnd.m_padding = buf.Read<uint8_t>(sizeof(hnd.m_padding));
}
inline bool is_kick_instruction(rage::datBitBuffer& buffer)
@ -107,8 +106,10 @@ namespace big
case rage::eNetMessage::MsgTextMessage2:
{
char message[256];
buffer.ReadString(message, 256);
rage::rlGamerHandle handle{};
bool is_team;
buffer.ReadString(message, sizeof(message));
gamer_handle_deserialize(handle, buffer);
buffer.ReadBool(&is_team);
if (player->is_spammer)
@ -146,15 +147,8 @@ namespace big
if (msgType == rage::eNetMessage::MsgTextMessage && g_pointers->m_gta.m_chat_data && player->get_net_data())
{
rage::rlGamerHandle temp{};
gamer_handle_deserialize(temp, buffer);
g_pointers->m_gta.m_handle_chat_message(*g_pointers->m_gta.m_chat_data,
nullptr,
&player->get_net_data()->m_gamer_handle,
message,
is_team);
return true;
buffer.Seek(0);
return g_hooking->get_original<hooks::receive_net_message>()(netConnectionManager, a2, frame); // Call original function since we can't seem to handle it
}
}
break;

View File

@ -16,12 +16,14 @@
namespace
{
inline void gamer_handle_serialize(rage::rlGamerHandle& hnd, rage::datBitBuffer& buf)
static void gamer_handle_serialize(rage::rlGamerHandle& hnd, rage::datBitBuffer& buf)
{
constexpr int PC_PLATFORM = 3;
buf.Write<uint8_t>(PC_PLATFORM, 8);
buf.WriteInt64(*(int64_t*)&hnd.m_rockstar_id, 64);
buf.Write<uint8_t>(hnd.unk_0009, 8);
buf.Write<uint8_t>(hnd.m_platform, sizeof(hnd.m_platform));
if (hnd.m_platform == rage::rlPlatforms::PC)
{
buf.WriteQWord(hnd.m_rockstar_id, sizeof(hnd.m_rockstar_id));
buf.Write<uint8_t>(hnd.m_padding, sizeof(hnd.m_padding));
}
}
static const char* spam_texts[] =

View File

@ -24,16 +24,6 @@
namespace big::session
{
static void gamer_handle_serialize(rage::rlGamerHandle& hnd, rage::datBitBuffer& buf)
{
buf.Write<uint8_t>(*reinterpret_cast<uint8_t*>(&hnd.m_platform), 8);
if (*reinterpret_cast<uint8_t*>(&hnd.m_platform) == 3)
{
buf.WriteInt64(*(int64_t*)&hnd.m_rockstar_id, 64);
buf.Write<uint8_t>(*reinterpret_cast<uint8_t*>(reinterpret_cast<__int64>(&hnd) + 9), 8);
}
}
inline bool join_type(eSessionType session)
{
SCRIPT::REQUEST_SCRIPT_WITH_NAME_HASH("pausemenu_multiplayer"_J);