feat(hooks): replace increment stat with received event handler (#320)
Closes #296
This commit is contained in:
parent
3fdafbab45
commit
a286d84e1b
@ -42,9 +42,7 @@ namespace big
|
||||
|
||||
// Net Array Handler
|
||||
m_net_array_handler_hook("NAH", g_pointers->m_net_array_handler, &hooks::net_array_handler),
|
||||
|
||||
// Increment Stat Event
|
||||
m_increment_stat_hook("ISE", g_pointers->m_increment_stat_event, &hooks::increment_stat_event),
|
||||
|
||||
// Is DLC Present
|
||||
m_is_dlc_present_hook("IDP", g_pointers->m_is_dlc_present, &hooks::is_dlc_present),
|
||||
|
||||
@ -101,8 +99,6 @@ namespace big
|
||||
m_player_has_joined_hook.enable();
|
||||
m_player_has_left_hook.enable();
|
||||
|
||||
m_increment_stat_hook.enable();
|
||||
|
||||
m_received_event_hook.enable();
|
||||
|
||||
m_send_net_info_to_lobby.enable();
|
||||
@ -128,8 +124,6 @@ namespace big
|
||||
|
||||
m_received_event_hook.disable();
|
||||
|
||||
m_increment_stat_hook.disable();
|
||||
|
||||
m_player_has_joined_hook.disable();
|
||||
m_player_has_left_hook.disable();
|
||||
|
||||
|
@ -36,7 +36,6 @@ namespace big
|
||||
static void player_join(CNetworkObjectMgr* _this, CNetGamePlayer* net_player);
|
||||
static void player_leave(CNetworkObjectMgr* _this, CNetGamePlayer* net_player);
|
||||
|
||||
static bool increment_stat_event(CNetworkIncrementStatEvent* net_event_struct, CNetGamePlayer* sender, int64_t a3);
|
||||
static bool is_dlc_present(Hash dlc_hash);
|
||||
|
||||
static void received_event(
|
||||
@ -50,7 +49,10 @@ namespace big
|
||||
rage::datBitBuffer* bit_buffer
|
||||
);
|
||||
|
||||
// these two aren't actually hooks, just helper functions for hooks
|
||||
static bool increment_stat_event(CNetworkIncrementStatEvent* net_event_struct, CNetGamePlayer* sender);
|
||||
static bool scripted_game_event(CScriptedGameEvent* scripted_game_event, CNetGamePlayer* player);
|
||||
|
||||
static bool send_net_info_to_lobby(rage::netPlayerData* player, int64_t a2, int64_t a3, DWORD* a4);
|
||||
static bool receive_net_message(void* netConnectionManager, void* a2, rage::netConnection::InFrame* frame);
|
||||
static void get_network_event_data(__int64 a1, rage::CEventNetwork* net_event);
|
||||
@ -99,8 +101,7 @@ namespace big
|
||||
|
||||
detour_hook m_player_has_joined_hook;
|
||||
detour_hook m_player_has_left_hook;
|
||||
|
||||
detour_hook m_increment_stat_hook;
|
||||
|
||||
detour_hook m_is_dlc_present_hook;
|
||||
|
||||
detour_hook m_received_event_hook;
|
||||
|
@ -2,16 +2,21 @@
|
||||
|
||||
namespace big
|
||||
{
|
||||
bool hooks::increment_stat_event(CNetworkIncrementStatEvent* net_event, CNetGamePlayer* sender, int64_t a3)
|
||||
bool hooks::increment_stat_event(CNetworkIncrementStatEvent* net_event, CNetGamePlayer* sender)
|
||||
{
|
||||
switch (net_event->m_stat)
|
||||
{
|
||||
case RAGE_JOAAT("MPPLY_GAME_EXPLOITS"):
|
||||
case RAGE_JOAAT("MPPLY_BAD_CREW_STATUS"):
|
||||
case RAGE_JOAAT("MPPLY_BAD_CREW_MOTTO"):
|
||||
case RAGE_JOAAT("MPPLY_BAD_CREW_NAME"):
|
||||
case RAGE_JOAAT("MPPLY_BAD_CREW_EMBLEM"):
|
||||
case RAGE_JOAAT("MPPLY_EXPLOITS"):
|
||||
case RAGE_JOAAT("MPPLY_VC_HATE"):
|
||||
case RAGE_JOAAT("MPPLY_GAME_EXPLOITS"):
|
||||
case RAGE_JOAAT("MPPLY_TC_ANNOYINGME"):
|
||||
case RAGE_JOAAT("MPPLY_TC_HATE"):
|
||||
const std::string report = fmt::format("From: {}", sender->get_name());
|
||||
case RAGE_JOAAT("MPPLY_VC_ANNOYINGME"):
|
||||
case RAGE_JOAAT("MPPLY_VC_HATE"):
|
||||
const auto report = fmt::format("From: {}", sender->get_name());
|
||||
|
||||
if (g->notifications.reports.log)
|
||||
LOG(INFO) << "Blocked report; " << report;
|
||||
@ -22,6 +27,6 @@ namespace big
|
||||
return true;
|
||||
}
|
||||
|
||||
return g_hooking->m_increment_stat_hook.get_original<decltype(&increment_stat_event)>()(net_event, sender, a3);
|
||||
return false;
|
||||
}
|
||||
}
|
@ -31,6 +31,20 @@ namespace big
|
||||
|
||||
switch ((RockstarEvent)event_id)
|
||||
{
|
||||
case RockstarEvent::NETWORK_INCREMENT_STAT_EVENT:
|
||||
{
|
||||
const auto increment_stat_event = std::make_unique<CNetworkIncrementStatEvent>();
|
||||
buffer->ReadDword(&increment_stat_event->m_stat, 0x20);
|
||||
buffer->ReadDword(&increment_stat_event->m_amount, 0x20);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
case RockstarEvent::SCRIPT_ENTITY_STATE_CHANGE_EVENT:
|
||||
{
|
||||
uint16_t entity;
|
||||
@ -151,6 +165,8 @@ namespace big
|
||||
|
||||
return;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return g_hooking->m_received_event_hook.get_original<decltype(&received_event)>()(event_manager, source_player, target_player, event_id, event_index, event_handled_bitset, unk, buffer);
|
||||
|
@ -107,12 +107,6 @@ namespace big
|
||||
m_gta_thread_kill = ptr.as<PVOID>();
|
||||
});
|
||||
|
||||
// Increment Stat Event
|
||||
main_batch.add("ISE", "48 83 EC 60 8B 79 30 4C 8B F1", [this](memory::handle ptr)
|
||||
{
|
||||
m_increment_stat_event = ptr.sub(0x15).as<decltype(m_increment_stat_event)>();
|
||||
});
|
||||
|
||||
// Trigger Script Event
|
||||
main_batch.add("TSE", "45 8B F0 41 8B F9 48 8B EA", [this](memory::handle ptr)
|
||||
{
|
||||
|
@ -71,8 +71,6 @@ namespace big
|
||||
functions::get_gameplay_cam_coords* m_get_gamplay_cam_coords;
|
||||
|
||||
functions::give_pickup_rewards* m_give_pickup_rewards{};
|
||||
|
||||
functions::increment_stat_event* m_increment_stat_event{};
|
||||
|
||||
functions::trigger_script_event* m_trigger_script_event{};
|
||||
|
||||
|
Reference in New Issue
Block a user