feat(netMsg): log chat and text messages (#567)

This commit is contained in:
Demae 2022-11-12 03:17:22 +10:30 committed by GitHub
parent 07825f84d6
commit 538919d4ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 10 deletions

View File

@ -183,6 +183,8 @@ namespace big
bool join_queued = false;
rage::rlSessionInfo info;
bool disable_chat_filter = false;
bool log_chat_messages = false;
bool log_text_messages = false;
};
struct settings {
@ -575,6 +577,9 @@ namespace big
this->self.unlimited_oxygen = j["self"]["unlimited_oxygen"];
this->self.no_water_collision = j["self"]["no_water_collision"];
this->session.log_chat_messages = j["session"]["log_chat_messages"];
this->session.log_text_messages = j["session"]["log_text_messages"];
this->settings.dev_dlc = j["settings"]["dev_dlc"];
this->settings.hotkeys.menu_toggle = j["settings"]["hotkeys"]["menu_toggle"];
@ -873,6 +878,12 @@ namespace big
{ "no_water_collision", this->self.no_water_collision },
}
},
{
"session", {
{ "log_chat_messages", this->session.log_chat_messages },
{ "log_text_messages", this->session.log_text_messages },
}
},
{
"settings", {
{ "dev_dlc", this->settings.dev_dlc },

View File

@ -38,7 +38,7 @@ namespace rage
return big::g_pointers->m_read_bitbuf_bool(this, integer, 1);
}
bool ReadPeerId(uint64_t* integer) {
return this->ReadQWord(integer, 0x32);
return this->ReadQWord(integer, 0x40);
}
uint64_t ReadBits(size_t numBits) {
auto const totalBits = (m_flagBits & 1) ? m_maxBit : m_curBit;

View File

@ -43,6 +43,32 @@ namespace big
{
switch (msgType)
{
case rage::eNetMessage::CMsgTextMessage:
{
if (g->session.log_chat_messages)
{
char message[256];
uint64_t unk;
bool is_team;
buffer.ReadString(message, 256);
buffer.ReadQWord(&unk, 64);
buffer.ReadBool(&is_team);
LOG(INFO) << "[CHAT] from " << player->get_name() << ": " << message << (is_team) ? " [TEAM]" : " [ALL]";
}
break;
}
case rage::eNetMessage::CMsgTextMessage2:
{
if (g->session.log_text_messages)
{
char message[256];
uint64_t unk;
buffer.ReadString(message, 256);
buffer.ReadQWord(&unk, 64);
LOG(INFO) << "[TEXT] from " << player->get_name() << ": " << message;
}
break;
}
case rage::eNetMessage::CMsgScriptMigrateHost:
{
if (std::chrono::system_clock::now() - player->m_last_transition_msg_sent < 200ms)
@ -67,11 +93,10 @@ namespace big
buffer.ReadQWord(&session_id, 64);
uint32_t count;
buffer.ReadDword(&count, 6);
pl = nullptr;
for (std::uint32_t i = 0; i < count; i++)
{
uint64_t peer_id;
buffer.ReadQWord((uint64_t*)&peer_id, 64);
buffer.ReadQWord(&peer_id, 64);
for (std::uint32_t i = 0; i < gta_util::get_network()->m_game_session_ptr->m_peer_count; i++)
{
if (gta_util::get_network()->m_game_session_ptr->m_peers[i]->m_peer_data.m_peer_id_2 == peer_id)

View File

@ -54,7 +54,6 @@ namespace big
if (hooks::increment_stat_event(increment_stat_event.get(), source_player))
{
g_pointers->m_send_event_ack(event_manager, source_player, target_player, event_index, event_handled_bitset);
return;
}
buffer->Seek(0);

View File

@ -165,12 +165,6 @@ namespace big
m_read_bitbuf_bool = ptr.add(1).rip().as<decltype(m_read_bitbuf_bool)>();
});
// Read Bitbuffer Array
main_batch.add("RBA", "48 89 5C 24 ? 57 48 83 EC 30 41 8B F8 4C", [this](memory::handle ptr)
{
m_read_bitbuf_array = ptr.as<decltype(m_read_bitbuf_array)>();
});
// Write Bitbuffer WORD/DWORD
main_batch.add("WBD", "48 8B C4 48 89 58 08 48 89 68 10 48 89 70 18 48 89 78 20 41 56 48 83 EC 20 8B EA BF 01", [this](memory::handle ptr)
{

View File

@ -28,5 +28,7 @@ namespace big
components::sub_title("Chat");
ImGui::Checkbox("Disable Filter", &g->session.disable_chat_filter);
ImGui::Checkbox("Log Chat Messages", &g->session.log_chat_messages);
ImGui::Checkbox("Log Text Messages", &g->session.log_text_messages);
}
}