refactor: hooking restructure (#311)

This commit is contained in:
Yimura 2022-07-03 01:05:33 +02:00 committed by GitHub
parent 6624060398
commit 034affd0a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 472 additions and 451 deletions

View File

@ -189,59 +189,6 @@ namespace big
return nullptr; return nullptr;
} }
HRESULT hooks::swapchain_present(IDXGISwapChain *this_, UINT sync_interval, UINT flags)
{
TRY_CLAUSE
{
if (g_running)
{
g_renderer->on_present();
}
return g_hooking->m_swapchain_hook.get_original<decltype(&swapchain_present)>(swapchain_present_index)(this_, sync_interval, flags);
} EXCEPT_CLAUSE
return NULL;
}
HRESULT hooks::swapchain_resizebuffers(IDXGISwapChain * this_, UINT buffer_count, UINT width, UINT height, DXGI_FORMAT new_format, UINT swapchain_flags)
{
TRY_CLAUSE
{
if (g_running)
{
g_renderer->pre_reset();
auto result = g_hooking->m_swapchain_hook.get_original<decltype(&swapchain_resizebuffers)>(swapchain_resizebuffers_index)
(this_, buffer_count, width, height, new_format, swapchain_flags);
if (SUCCEEDED(result))
{
g_renderer->post_reset();
}
return result;
}
return g_hooking->m_swapchain_hook.get_original<decltype(&swapchain_resizebuffers)>(swapchain_resizebuffers_index)
(this_, buffer_count, width, height, new_format, swapchain_flags);
} EXCEPT_CLAUSE
return NULL;
}
LRESULT hooks::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
TRY_CLAUSE
{
if (g_running)
{
g_renderer->wndproc(hwnd, msg, wparam, lparam);
}
return CallWindowProcW(g_hooking->m_og_wndproc, hwnd, msg, wparam, lparam);
} EXCEPT_CLAUSE
return NULL;
}
BOOL hooks::set_cursor_pos(int x, int y) BOOL hooks::set_cursor_pos(int x, int y)
{ {
TRY_CLAUSE TRY_CLAUSE

View File

@ -0,0 +1,21 @@
#include "hooking.hpp"
#include "renderer.hpp"
#include "script.hpp"
namespace big
{
HRESULT hooks::swapchain_present(IDXGISwapChain* this_, UINT sync_interval, UINT flags)
{
TRY_CLAUSE
{
if (g_running)
{
g_renderer->on_present();
}
return g_hooking->m_swapchain_hook.get_original<decltype(&swapchain_present)>(swapchain_present_index)(this_, sync_interval, flags);
} EXCEPT_CLAUSE
return NULL;
}
}

View File

@ -0,0 +1,32 @@
#include "hooking.hpp"
#include "renderer.hpp"
#include "script.hpp"
namespace big
{
HRESULT hooks::swapchain_resizebuffers(IDXGISwapChain* this_, UINT buffer_count, UINT width, UINT height, DXGI_FORMAT new_format, UINT swapchain_flags)
{
TRY_CLAUSE
{
if (g_running)
{
g_renderer->pre_reset();
const auto result = g_hooking->m_swapchain_hook.get_original<decltype(&swapchain_resizebuffers)>(swapchain_resizebuffers_index)
(this_, buffer_count, width, height, new_format, swapchain_flags);
if (SUCCEEDED(result))
{
g_renderer->post_reset();
}
return result;
}
return g_hooking->m_swapchain_hook.get_original<decltype(&swapchain_resizebuffers)>(swapchain_resizebuffers_index)
(this_, buffer_count, width, height, new_format, swapchain_flags);
} EXCEPT_CLAUSE
return NULL;
}
}

View File

@ -0,0 +1,21 @@
#include "hooking.hpp"
#include "renderer.hpp"
#include "script.hpp"
namespace big
{
LRESULT hooks::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
TRY_CLAUSE
{
if (g_running)
{
g_renderer->wndproc(hwnd, msg, wparam, lparam);
}
return CallWindowProcW(g_hooking->m_og_wndproc, hwnd, msg, wparam, lparam);
} EXCEPT_CLAUSE
return NULL;
}
}

View File

@ -1,398 +1,398 @@
#include "hooking.hpp" #include "hooking.hpp"
#include "gta_util.hpp" #include "gta_util.hpp"
namespace big namespace big
{ {
void format_string(std::string_view player_name, std::string_view protection_type, bool should_log, bool should_notify) void format_string(std::string_view player_name, std::string_view protection_type, bool should_log, bool should_notify)
{ {
if (should_log) if (should_log)
LOG(WARNING) << "BLOCKED_SCRIPT_EVENT From: " << player_name << " Event Type: " << protection_type; LOG(WARNING) << "BLOCKED_SCRIPT_EVENT From: " << player_name << " Event Type: " << protection_type;
if (should_notify) if (should_notify)
g_notification_service->push_warning("Script Event Protection", g_notification_service->push_warning("Script Event Protection",
fmt::format("From: {}\nEvent Type: {}", player_name.data(), protection_type.data()) fmt::format("From: {}\nEvent Type: {}", player_name.data(), protection_type.data())
); );
} }
bool hooks::scripted_game_event(CScriptedGameEvent* scripted_game_event, CNetGamePlayer* player) bool hooks::scripted_game_event(CScriptedGameEvent* scripted_game_event, CNetGamePlayer* player)
{ {
const auto args = scripted_game_event->m_args; const auto args = scripted_game_event->m_args;
const auto hash = static_cast<eRemoteEvent>(args[0]); const auto hash = static_cast<eRemoteEvent>(args[0]);
const auto player_name = player->get_name(); const auto player_name = player->get_name();
const auto& notify = g->notifications.script_event_handler; const auto& notify = g->notifications.script_event_handler;
switch (hash) switch (hash)
{ {
case eRemoteEvent::Bounty: case eRemoteEvent::Bounty:
if (g->protections.script_events.bounty) if (g->protections.script_events.bounty)
{ {
format_string(player_name, "Bounty", notify.bounty.log, notify.bounty.notify); format_string(player_name, "Bounty", notify.bounty.log, notify.bounty.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::CeoBan: case eRemoteEvent::CeoBan:
if (g->protections.script_events.ceo_ban) if (g->protections.script_events.ceo_ban)
{ {
format_string(player_name, "Ceo Ban", notify.ceo_ban.log, notify.ceo_ban.notify); format_string(player_name, "Ceo Ban", notify.ceo_ban.log, notify.ceo_ban.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::CeoKick: case eRemoteEvent::CeoKick:
if (g->protections.script_events.ceo_kick) if (g->protections.script_events.ceo_kick)
{ {
format_string(player_name, "Ceo Kick", notify.ceo_kick.log, notify.ceo_kick.notify); format_string(player_name, "Ceo Kick", notify.ceo_kick.log, notify.ceo_kick.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::CeoMoney: case eRemoteEvent::CeoMoney:
if (g->protections.script_events.ceo_money) if (g->protections.script_events.ceo_money)
{ {
format_string(player_name, "Ceo Money", notify.ceo_money.log, notify.ceo_money.notify); format_string(player_name, "Ceo Money", notify.ceo_money.log, notify.ceo_money.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::ClearWantedLevel: case eRemoteEvent::ClearWantedLevel:
if (g->protections.script_events.clear_wanted_level) if (g->protections.script_events.clear_wanted_level)
{ {
format_string(player_name, "Clear Wanted Level", notify.clear_wanted_level.log, notify.clear_wanted_level.notify); format_string(player_name, "Clear Wanted Level", notify.clear_wanted_level.log, notify.clear_wanted_level.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::Crash: case eRemoteEvent::Crash:
if (g->protections.script_events.crash) if (g->protections.script_events.crash)
{ {
format_string(player_name, "TSE Crash", notify.crash.log, notify.crash.notify); format_string(player_name, "TSE Crash", notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::FakeDeposit: case eRemoteEvent::FakeDeposit:
if (g->protections.script_events.fake_deposit) if (g->protections.script_events.fake_deposit)
{ {
format_string(player_name, "Fake Deposit", notify.fake_deposit.log, notify.fake_deposit.notify); format_string(player_name, "Fake Deposit", notify.fake_deposit.log, notify.fake_deposit.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::ForceMission: case eRemoteEvent::ForceMission:
if (g->protections.script_events.force_mission) if (g->protections.script_events.force_mission)
{ {
format_string(player_name, "Force Mission", notify.force_mission.log, notify.force_mission.notify); format_string(player_name, "Force Mission", notify.force_mission.log, notify.force_mission.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::GtaBanner: case eRemoteEvent::GtaBanner:
if (g->protections.script_events.gta_banner) if (g->protections.script_events.gta_banner)
{ {
format_string(player_name, "GTA Banner", notify.gta_banner.log, notify.gta_banner.notify); format_string(player_name, "GTA Banner", notify.gta_banner.log, notify.gta_banner.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::MCTeleport: case eRemoteEvent::MCTeleport:
if (g->protections.script_events.mc_teleport) if (g->protections.script_events.mc_teleport)
{ {
format_string(player_name, "MC Teleport", notify.mc_teleport.log, notify.mc_teleport.notify); format_string(player_name, "MC Teleport", notify.mc_teleport.log, notify.mc_teleport.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::NetworkBail: case eRemoteEvent::NetworkBail:
if (g->protections.script_events.network_bail) if (g->protections.script_events.network_bail)
{ {
format_string(player_name, "Network Bail", notify.network_bail.log, notify.network_bail.notify); format_string(player_name, "Network Bail", notify.network_bail.log, notify.network_bail.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::PersonalVehicleDestroyed: case eRemoteEvent::PersonalVehicleDestroyed:
if (g->protections.script_events.personal_vehicle_destroyed) if (g->protections.script_events.personal_vehicle_destroyed)
{ {
format_string(player_name, "Personal Vehicle Destroyed", notify.personal_vehicle_destroyed.log, notify.personal_vehicle_destroyed.notify); format_string(player_name, "Personal Vehicle Destroyed", notify.personal_vehicle_destroyed.log, notify.personal_vehicle_destroyed.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::RemoteOffradar: case eRemoteEvent::RemoteOffradar:
if (g->protections.script_events.remote_off_radar) if (g->protections.script_events.remote_off_radar)
{ {
format_string(player_name, "Off Radar", notify.remote_off_radar.log, notify.remote_off_radar.notify); format_string(player_name, "Off Radar", notify.remote_off_radar.log, notify.remote_off_radar.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::RotateCam: case eRemoteEvent::RotateCam:
if (g->protections.script_events.crash && args[2] == 537560473) { if (g->protections.script_events.crash && args[2] == 537560473) {
format_string(player_name, "Crash - Rotate Cam", notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - Rotate Cam", notify.crash.log, notify.crash.notify);
return true; return true;
} }
if (g->protections.script_events.rotate_cam) if (g->protections.script_events.rotate_cam)
{ {
if (CNetworkPlayerMgr* player_mgr = gta_util::get_network_player_mgr(); player_mgr != nullptr) if (CNetworkPlayerMgr* player_mgr = gta_util::get_network_player_mgr(); player_mgr != nullptr)
if (args[2] == player_mgr->m_local_net_player->m_player_id) if (args[2] == player_mgr->m_local_net_player->m_player_id)
format_string(player_name, "Rotate Cam", notify.rotate_cam.log, notify.rotate_cam.notify); format_string(player_name, "Rotate Cam", notify.rotate_cam.log, notify.rotate_cam.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SendToCayo: case eRemoteEvent::SendToCayo:
if (args[2] == 0 && args[3] == 0 && args[4] == 3 && args[5] == 1 && args[6] == 0) if (args[2] == 0 && args[3] == 0 && args[4] == 3 && args[5] == 1 && args[6] == 0)
{ {
if (g->protections.script_events.send_to_island) if (g->protections.script_events.send_to_island)
{ {
format_string(player_name, "Send to Cayo Beach", notify.send_to_island.log, notify.send_to_island.notify); format_string(player_name, "Send to Cayo Beach", notify.send_to_island.log, notify.send_to_island.notify);
return true; return true;
} }
} }
else else
{ {
format_string(player_name, "TSE Freeze", notify.tse_freeze.log, notify.tse_freeze.notify); format_string(player_name, "TSE Freeze", notify.tse_freeze.log, notify.tse_freeze.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SendToCutscene: case eRemoteEvent::SendToCutscene:
if (g->protections.script_events.send_to_cutscene) if (g->protections.script_events.send_to_cutscene)
{ {
format_string(player_name, "Send to Cutscene", notify.send_to_cutscene.log, notify.send_to_cutscene.notify); format_string(player_name, "Send to Cutscene", notify.send_to_cutscene.log, notify.send_to_cutscene.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SendToIsland: case eRemoteEvent::SendToIsland:
if (g->protections.script_events.send_to_island) if (g->protections.script_events.send_to_island)
{ {
format_string(player_name, "Send to Island", notify.send_to_island.log, notify.send_to_island.notify); format_string(player_name, "Send to Island", notify.send_to_island.log, notify.send_to_island.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SoundSpam: case eRemoteEvent::SoundSpam:
if (g->protections.script_events.sound_spam) if (g->protections.script_events.sound_spam)
{ {
format_string(player_name, "Sound Spamn", notify.sound_spam.log, notify.sound_spam.notify); format_string(player_name, "Sound Spamn", notify.sound_spam.log, notify.sound_spam.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::Spectate: case eRemoteEvent::Spectate:
if (g->protections.script_events.spectate) if (g->protections.script_events.spectate)
{ {
format_string(player_name, "Spectate", notify.spectate.log, notify.spectate.notify); format_string(player_name, "Spectate", notify.spectate.log, notify.spectate.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::Teleport: case eRemoteEvent::Teleport:
if (g->protections.script_events.force_teleport) if (g->protections.script_events.force_teleport)
{ {
format_string(player_name, "Apartment Invite", notify.force_teleport.log, notify.force_teleport.notify); format_string(player_name, "Apartment Invite", notify.force_teleport.log, notify.force_teleport.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::TransactionError: case eRemoteEvent::TransactionError:
if (g->protections.script_events.transaction_error) if (g->protections.script_events.transaction_error)
{ {
format_string(player_name, "Transaction Error", notify.transaction_error.log, notify.transaction_error.notify); format_string(player_name, "Transaction Error", notify.transaction_error.log, notify.transaction_error.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::VehicleKick: case eRemoteEvent::VehicleKick:
if (g->protections.script_events.vehicle_kick) if (g->protections.script_events.vehicle_kick)
{ {
format_string(player_name, "Vehicle Kick", notify.vehicle_kick.log, notify.vehicle_kick.notify); format_string(player_name, "Vehicle Kick", notify.vehicle_kick.log, notify.vehicle_kick.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::Unknown1: case eRemoteEvent::Unknown1:
if (g->protections.script_events.crash && args[2] >= 32) { if (g->protections.script_events.crash && args[2] >= 32) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::Unknown2: case eRemoteEvent::Unknown2:
if (g->protections.script_events.crash && (args[2] >= 62 || args[3] >= 32)) { if (g->protections.script_events.crash && (args[2] >= 62 || args[3] >= 32)) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::Unknown3: case eRemoteEvent::Unknown3:
if (g->protections.script_events.crash && args[2] >= 62) { if (g->protections.script_events.crash && args[2] >= 62) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::Unknown4: case eRemoteEvent::Unknown4:
case eRemoteEvent::Unknown5: case eRemoteEvent::Unknown5:
if (g->protections.script_events.crash && args[2] >= 20) { if (g->protections.script_events.crash && args[2] >= 20) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::Unknown6: case eRemoteEvent::Unknown6:
if (g->protections.script_events.crash) { if (g->protections.script_events.crash) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SEC3: case eRemoteEvent::SEC3:
if ( if (
g->protections.script_events.crash && g->protections.script_events.crash &&
( (
(args[2] <= 115831 || args[2] >= 9999449) || (args[2] <= 115831 || args[2] >= 9999449) ||
(args[3] <= -1 || args[3] >= 1) || (args[3] <= -1 || args[3] >= 1) ||
(args[4] <= -1 || args[4] >= 3) || (args[4] <= -1 || args[4] >= 3) ||
(args[5] <= -1 || args[5] >= 101) || (args[5] <= -1 || args[5] >= 101) ||
(args[6] <= -1 || args[6] >= 3) || (args[6] <= -1 || args[6] >= 3) ||
(args[7] <= -1 || args[7] >= 1) (args[7] <= -1 || args[7] >= 1)
) )
) { ) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SEC6: case eRemoteEvent::SEC6:
if ( if (
g->protections.script_events.crash && g->protections.script_events.crash &&
( (
(args[2] <= -1 || args[2] >= 1) || (args[2] <= -1 || args[2] >= 1) ||
(args[3] <= -2 || args[3] >= 0) || (args[3] <= -2 || args[3] >= 0) ||
(args[4] <= 3 || args[4] >= 5) || (args[4] <= 3 || args[4] >= 5) ||
(args[5] <= 172 || args[5] >= 174) || (args[5] <= 172 || args[5] >= 174) ||
(args[6] <= 20 || args[6] >= 510) || (args[6] <= 20 || args[6] >= 510) ||
(args[7] <= 62 || args[7] >= 64) || (args[7] <= 62 || args[7] >= 64) ||
(args[11] <= -1 || args[11] >= 1) || (args[11] <= -1 || args[11] >= 1) ||
(args[12] <= -1 || args[12] >= 1) || (args[12] <= -1 || args[12] >= 1) ||
(args[13] <= -1 || args[13] >= 1) (args[13] <= -1 || args[13] >= 1)
) )
) { ) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SEC7: case eRemoteEvent::SEC7:
if (g->protections.script_events.crash) { if (g->protections.script_events.crash) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SEC8: case eRemoteEvent::SEC8:
if (g->protections.script_events.crash) { if (g->protections.script_events.crash) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SEC9: case eRemoteEvent::SEC9:
if ( if (
g->protections.script_events.crash && g->protections.script_events.crash &&
( (
(args[2] <= -1986324736 || args[2] >= 1747413822) || (args[2] <= -1986324736 || args[2] >= 1747413822) ||
(args[2] > -9999999 || args[2] < 77777777) || (args[2] > -9999999 || args[2] < 77777777) ||
(args[3] <= -1986324736 || args[3] >= 1777712108) || (args[3] <= -1986324736 || args[3] >= 1777712108) ||
(args[3] > -9999999 || args[3] < 77777777) || (args[3] > -9999999 || args[3] < 77777777) ||
(args[4] <= -1673857408 || args[4] >= 1780088064) || (args[4] <= -1673857408 || args[4] >= 1780088064) ||
(args[4] > -9999999 || args[4] < 77777777) || (args[4] > -9999999 || args[4] < 77777777) ||
(args[6] <= (0LL - 2588888790LL) || args[6] >= 2100146067) (args[6] <= (0LL - 2588888790LL) || args[6] >= 2100146067)
) )
) { ) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SEC10: case eRemoteEvent::SEC10:
if (g->protections.script_events.crash) { if (g->protections.script_events.crash) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SEC11: case eRemoteEvent::SEC11:
if (g->protections.script_events.crash) { if (g->protections.script_events.crash) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SEC12: case eRemoteEvent::SEC12:
if ( if (
g->protections.script_events.crash && g->protections.script_events.crash &&
( (
(args[2] <= -1 || args[2] >= 50) || (args[2] <= -1 || args[2] >= 50) ||
(args[3] <= -1 || args[3] >= 50) (args[3] <= -1 || args[3] >= 50)
) )
) { ) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SEC13: case eRemoteEvent::SEC13:
if (g->protections.script_events.crash) { if (g->protections.script_events.crash) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::Spaghettios: case eRemoteEvent::Spaghettios:
if (g->protections.script_events.crash) { if (g->protections.script_events.crash) {
format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify); format_string(player_name, "Crash - #" + std::to_string(args[0]), notify.crash.log, notify.crash.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::ForceMission2: case eRemoteEvent::ForceMission2:
if (g->protections.script_events.force_mission) if (g->protections.script_events.force_mission)
{ {
format_string(player_name, "Force Mission", notify.force_mission.log, notify.force_mission.notify); format_string(player_name, "Force Mission", notify.force_mission.log, notify.force_mission.notify);
return true; return true;
} }
break; break;
case eRemoteEvent::SHKick: case eRemoteEvent::SHKick:
if (g->protections.script_events.network_bail) if (g->protections.script_events.network_bail)
{ {
format_string(player_name, "Network Bail", notify.network_bail.log, notify.network_bail.notify); format_string(player_name, "Network Bail", notify.network_bail.log, notify.network_bail.notify);
return true; return true;
} }
} }
if (g->debug.script_event_logging) if (g->debug.script_event_logging)
{ {
LOG(INFO) << "== Begin of Script Event =="; LOG(INFO) << "== Begin of Script Event ==";
LOG(INFO) << "Player: " << player->get_name(); LOG(INFO) << "Player: " << player->get_name();
LOG(INFO) << "Hash/Arg #0: " << (int)hash; LOG(INFO) << "Hash/Arg #0: " << (int)hash;
for (std::size_t i = 1; i < sizeof(args); i++) for (std::size_t i = 1; i < sizeof(args); i++)
LOG(INFO) << "Arg #" << i << ": " << args[i]; LOG(INFO) << "Arg #" << i << ": " << args[i];
LOG(INFO) << "== End of Script Event =="; LOG(INFO) << "== End of Script Event ==";
} }
return false; return false;
} }
} }