feat(Debug): Added Script Event Logging

Closes #26
This commit is contained in:
Yimura 2022-01-06 08:47:00 +01:00
parent 624373a2f9
commit 74fdad96fe
3 changed files with 20 additions and 3 deletions

View File

@ -10,6 +10,10 @@ struct globals {
nlohmann::json default_options; nlohmann::json default_options;
nlohmann::json options; nlohmann::json options;
struct debug {
bool script_event_logging = false;
};
struct tunables { struct tunables {
bool disable_phone = false; bool disable_phone = false;
bool no_idle_kick = false; bool no_idle_kick = false;
@ -115,6 +119,7 @@ struct globals {
CPlayer players[32]; CPlayer players[32];
CPlayer selected_player; CPlayer selected_player;
debug debug{};
tunables tunables{}; tunables tunables{};
player player{}; player player{};
protections protections{}; protections protections{};
@ -126,6 +131,8 @@ struct globals {
void from_json(const nlohmann::json& j) 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.bounty = j["protections"]["script_events"]["bounty"];
this->protections.script_events.ceo_ban = j["protections"]["script_events"]["ceo_ban"]; this->protections.script_events.ceo_ban = j["protections"]["script_events"]["ceo_ban"];
this->protections.script_events.ceo_kick = j["protections"]["script_events"]["ceo_kick"]; this->protections.script_events.ceo_kick = j["protections"]["script_events"]["ceo_kick"];
@ -187,6 +194,12 @@ struct globals {
nlohmann::json to_json() nlohmann::json to_json()
{ {
return nlohmann::json{ return nlohmann::json{
{
"debug",
{
{ "script_event_logging", this->debug.script_event_logging }
}
},
{ {
"protections", "protections",
{ {

View File

@ -7,6 +7,8 @@ namespace big
{ {
if (ImGui::BeginTabItem("Debug")) if (ImGui::BeginTabItem("Debug"))
{ {
ImGui::Checkbox("Script Event Logging", &g.debug.script_event_logging);
if (ImGui::Button("Dump entrypoints")) if (ImGui::Button("Dump entrypoints"))
{ {
system::dump_entry_points(); system::dump_entry_points();

View File

@ -115,14 +115,16 @@ namespace big
return true; 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) << "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++) for (int i = 1; i < sizeof(args); i++)
LOG(INFO) << "Arg #" << i << ": " << 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); return g_hooking->m_scripted_game_event_hook.get_original<decltype(&hooks::scripted_game_event)>()(scripted_game_event, player);