feat(Debug): Added Script Event Logging

Closes #26
This commit is contained in:
Yimura 2022-01-06 08:47:00 +01:00
parent b357aaac69
commit 9c4058e9cd
No known key found for this signature in database
GPG Key ID: 3D8FF4397E768682
3 changed files with 20 additions and 3 deletions

View File

@ -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",
{

View File

@ -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();

View File

@ -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<decltype(&hooks::scripted_game_event)>()(scripted_game_event, player);