From 74fdad96fe68655e203111787ee1559d308bb8a9 Mon Sep 17 00:00:00 2001 From: Yimura Date: Thu, 6 Jan 2022 08:47:00 +0100 Subject: [PATCH] feat(Debug): Added Script Event Logging Closes #26 --- BigBaseV2/src/core/globals.hpp | 13 +++++++++++++ BigBaseV2/src/gui/window/dbg/debug_debug.cpp | 2 ++ BigBaseV2/src/hooks/script_event_handler.cpp | 8 +++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/BigBaseV2/src/core/globals.hpp b/BigBaseV2/src/core/globals.hpp index 7e832569..fa9b4227 100644 --- a/BigBaseV2/src/core/globals.hpp +++ b/BigBaseV2/src/core/globals.hpp @@ -10,6 +10,10 @@ struct globals { nlohmann::json default_options; nlohmann::json options; + struct debug { + bool script_event_logging = false; + }; + struct tunables { bool disable_phone = false; bool no_idle_kick = false; @@ -115,6 +119,7 @@ struct globals { CPlayer players[32]; CPlayer selected_player; + debug debug{}; tunables tunables{}; player player{}; protections protections{}; @@ -126,6 +131,8 @@ struct globals { void from_json(const nlohmann::json& j) { + this->debug.script_event_logging = j["debug"]["script_event_logging"]; + this->protections.script_events.bounty = j["protections"]["script_events"]["bounty"]; this->protections.script_events.ceo_ban = j["protections"]["script_events"]["ceo_ban"]; this->protections.script_events.ceo_kick = j["protections"]["script_events"]["ceo_kick"]; @@ -187,6 +194,12 @@ struct globals { nlohmann::json to_json() { return nlohmann::json{ + { + "debug", + { + { "script_event_logging", this->debug.script_event_logging } + } + }, { "protections", { diff --git a/BigBaseV2/src/gui/window/dbg/debug_debug.cpp b/BigBaseV2/src/gui/window/dbg/debug_debug.cpp index 82fcb71c..61f462ff 100644 --- a/BigBaseV2/src/gui/window/dbg/debug_debug.cpp +++ b/BigBaseV2/src/gui/window/dbg/debug_debug.cpp @@ -7,6 +7,8 @@ namespace big { if (ImGui::BeginTabItem("Debug")) { + ImGui::Checkbox("Script Event Logging", &g.debug.script_event_logging); + if (ImGui::Button("Dump entrypoints")) { system::dump_entry_points(); diff --git a/BigBaseV2/src/hooks/script_event_handler.cpp b/BigBaseV2/src/hooks/script_event_handler.cpp index 693ef005..8e06e2c9 100644 --- a/BigBaseV2/src/hooks/script_event_handler.cpp +++ b/BigBaseV2/src/hooks/script_event_handler.cpp @@ -115,14 +115,16 @@ namespace big return true; } - if (false) + if (g.debug.script_event_logging) { - LOG(INFO) << "Received Script Event"; + LOG(INFO) << "== Begin of Script Event =="; LOG(INFO) << "Player: " << player->get_name(); - LOG(INFO) << "Hash: " << (int64_t)hash; + LOG(INFO) << "Hash/Arg #0: " << (int)hash; for (int i = 1; i < sizeof(args); i++) LOG(INFO) << "Arg #" << i << ": " << args[i]; + + LOG(INFO) << "== End of Script Event =="; } return g_hooking->m_scripted_game_event_hook.get_original()(scripted_game_event, player);