fix: fix chat (#3454)
Some checks failed
Nightly Build / Check Recent Commit (push) Failing after 1s
Nightly Build / Build Nightly (push) Has been skipped
Nightly Build / Recreate Release (push) Has been skipped

This commit is contained in:
Mr-X-GTA 2024-07-27 21:43:45 +02:00 committed by GitHub
parent 665afb1bd5
commit 19fe45bf9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 65 additions and 18 deletions

View File

@ -221,4 +221,8 @@ namespace big::functions
using get_peer_by_security_id = rage::SecurityPeer*(*)(int id);
using set_head_blend_data = void(*)(CPed* ped, CHeadBlendData* data);
using create_chat_guid = void (*)(GUID* guid);
using begin_scaleform = bool (*)(uint32_t* scaleform, const char* method);
}

View File

@ -401,6 +401,12 @@ namespace big
PVOID m_scope_sway_function;
PVOID m_report_myself_sender;
functions::create_chat_guid m_create_chat_guid;
uint32_t* m_game_lifetime;
functions::begin_scaleform m_begin_scaleform;
};
#pragma pack(pop)
static_assert(sizeof(gta_pointers) % 8 == 0, "Pointers are not properly aligned");

View File

@ -11,11 +11,11 @@ namespace big
if (g.session.chat_commands && message[0] == g.session.chat_command_prefix)
command::process(std::string(message + 1), std::make_shared<chat_command_context>(g_player_service->get_self()));
// chat::send_message(message, nullptr, false, is_team);
chat::send_message(message, nullptr, false, is_team);
if (g.session.log_chat_messages)
chat::log_chat(message, g_player_service->get_self(), SpamReason::NOT_A_SPAMMER, is_team);
return g_hooking->get_original<hooks::send_chat_message>()(team_mgr, local_gamer_info, message, is_team);
return true;
}
}

View File

@ -684,9 +684,12 @@ namespace big
case rage::eNetMessage::MsgTextMessage2:
{
char message[256];
char guid[40];
rage::rlGamerHandle handle{};
bool is_team;
buffer.ReadString(message, sizeof(message));
if (msgType == rage::eNetMessage::MsgTextMessage)
buffer.ReadString(guid, sizeof(guid));
gamer_handle_deserialize(handle, buffer);
is_team = buffer.Read<bool>(1);

View File

@ -1902,6 +1902,33 @@ namespace big
{
g_pointers->m_gta.m_report_myself_sender = ptr.add(1).rip().as<PVOID>();
}
},
// Create Chat GUID
{
"CCG",
"48 89 5C 24 08 48 89 6C 24 18 48 89 74 24 20 57 41 56 41 57 48 83 EC 20 33",
[](memory::handle ptr)
{
g_pointers->m_gta.m_create_chat_guid = ptr.as<functions::create_chat_guid>();
}
},
// Game Lifetime
{
"GL",
"8B 05 ? ? ? ? 89 ? 48 8D 4D C8",
[](memory::handle ptr)
{
g_pointers->m_gta.m_game_lifetime = ptr.add(2).rip().as<uint32_t*>();
}
},
// Begin Scaleform Movie Method
{
"BS",
"48 83 EC 38 4C 8B C2 8B 51 04",
[](memory::handle ptr)
{
g_pointers->m_gta.m_begin_scaleform = ptr.as<functions::begin_scaleform>();
}
}
>(); // don't leave a trailing comma at the end

View File

@ -186,12 +186,11 @@ namespace big::chat
inline void render_chat(const char* msg, const char* player_name, bool is_team)
{
int scaleform = GRAPHICS::REQUEST_SCALEFORM_MOVIE("MULTIPLAYER_CHAT");
const auto chat_data = *g_pointers->m_gta.m_chat_data;
while (!GRAPHICS::HAS_SCALEFORM_MOVIE_LOADED(scaleform))
script::get_current()->yield();
if (!g_pointers->m_gta.m_begin_scaleform(&chat_data->m_scaleform, "ADD_MESSAGE"))
return;
GRAPHICS::BEGIN_SCALEFORM_MOVIE_METHOD(scaleform, "ADD_MESSAGE");
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(player_name); // player name
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_LITERAL_STRING(msg); // content
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_TEXTURE_NAME_STRING(HUD::GET_FILENAME_FOR_AUDIO_CONVERSATION(is_team ? "MP_CHAT_TEAM" : "MP_CHAT_ALL")); // scope
@ -199,19 +198,20 @@ namespace big::chat
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT((int)HudColor::HUD_COLOUR_PURE_WHITE); // eHudColour
GRAPHICS::END_SCALEFORM_MOVIE_METHOD();
GRAPHICS::BEGIN_SCALEFORM_MOVIE_METHOD(scaleform, "SET_FOCUS");
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(1); // VISIBLE_STATE_DEFAULT
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(0); // scopeType (unused)
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(0); // scope (unused)
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(player_name); // player
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT((int)HudColor::HUD_COLOUR_PURE_WHITE); // eHudColour
GRAPHICS::END_SCALEFORM_MOVIE_METHOD();
if (!chat_data->m_chat_open && !chat_data->m_timer_two)
{
if (g_pointers->m_gta.m_begin_scaleform(&chat_data->m_scaleform, "SET_FOCUS"))
{
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(1); // VISIBLE_STATE_DEFAULT
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(0); // scopeType (unused)
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT(0); // scope (unused)
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_PLAYER_NAME_STRING(player_name); // player
GRAPHICS::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT((int)HudColor::HUD_COLOUR_PURE_WHITE); // eHudColour
GRAPHICS::END_SCALEFORM_MOVIE_METHOD();
}
}
GRAPHICS::DRAW_SCALEFORM_MOVIE_FULLSCREEN(scaleform, 255, 255, 255, 255, 0);
// fix broken scaleforms, when chat alrdy opened
if (const auto chat_data = *g_pointers->m_gta.m_chat_data; chat_data && (chat_data->m_chat_open || chat_data->m_timer_two))
HUD::CLOSE_MP_TEXT_CHAT();
chat_data->m_timer_one = *g_pointers->m_gta.m_game_lifetime;
}
inline void draw_chat(const std::string& message, const std::string& sender, bool is_team)
@ -265,9 +265,16 @@ namespace big::chat
if (!*g_pointers->m_gta.m_is_session_started)
return;
GUID guid;
g_pointers->m_gta.m_create_chat_guid(&guid);
char guid_str[40];
std::sprintf(guid_str, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
packet msg{};
msg.write_message(rage::eNetMessage::MsgTextMessage);
msg.m_buffer.WriteString(message.c_str(), 256);
msg.m_buffer.WriteString(guid_str, 40);
gamer_handle_serialize(g_player_service->get_self()->get_net_data()->m_gamer_handle, msg.m_buffer);
msg.write<bool>(is_team, 1);