From 9388aa88855f66ba98c8ae59a50aa99339e272ed Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 9 Mar 2022 18:23:42 -0800 Subject: [PATCH] Show last lua mod to run in crash handler --- src/pc/crash_handler.c | 2 ++ src/pc/crash_handler.h | 1 + src/pc/lua/smlua.c | 2 ++ src/pc/lua/smlua_sync_table.c | 2 ++ 4 files changed, 7 insertions(+) diff --git a/src/pc/crash_handler.c b/src/pc/crash_handler.c index dd8fc2e0..c0a377a6 100644 --- a/src/pc/crash_handler.c +++ b/src/pc/crash_handler.c @@ -463,6 +463,7 @@ static CRASH_HANDLER_TYPE crash_handler(EXCEPTION_POINTERS *ExceptionInfo) { for (int i = 0; i < gModTableCurrent->entryCount; i++) { struct ModListEntry* entry = &gModTableCurrent->entries[i]; if (entry == NULL || !entry->enabled) { continue; } + u8 b = (gPcDebug.lastModRun == entry) ? 0 : 0xFF; crash_handler_set_text(x, y, 0xFF, 0xFF, 200, "%.21s", entry->name); y += 8; } @@ -546,6 +547,7 @@ struct PcDebug gPcDebug = { .id = DEFAULT_ID, .bhvOffset = /* 0x12 */ 0, .debugId = 0x4BE2, + .lastModRun = NULL, }; void crash_handler_init(void) { diff --git a/src/pc/crash_handler.h b/src/pc/crash_handler.h index a082827d..ecf32cc8 100644 --- a/src/pc/crash_handler.h +++ b/src/pc/crash_handler.h @@ -11,6 +11,7 @@ struct PcDebug { u64 id; u64 bhvOffset; u64 debugId; + void* lastModRun; }; extern struct PcDebug gPcDebug; diff --git a/src/pc/lua/smlua.c b/src/pc/lua/smlua.c index 8251bf18..a453cc02 100644 --- a/src/pc/lua/smlua.c +++ b/src/pc/lua/smlua.c @@ -1,5 +1,6 @@ #include "smlua.h" #include "pc/mod_list.h" +#include "pc/crash_handler.h" lua_State* gLuaState = NULL; u8 gLuaInitializingScript = 0; @@ -102,6 +103,7 @@ void smlua_init(void) { LOG_INFO(" %s", entry->path); gLuaLoadingEntry = entry; gLuaActiveEntry = entry; + gPcDebug.lastModRun = gLuaActiveEntry; smlua_load_script(entry->path, entry->remoteIndex); gLuaActiveEntry = NULL; gLuaLoadingEntry = NULL; diff --git a/src/pc/lua/smlua_sync_table.c b/src/pc/lua/smlua_sync_table.c index 10ff62fc..a6860258 100644 --- a/src/pc/lua/smlua_sync_table.c +++ b/src/pc/lua/smlua_sync_table.c @@ -1,4 +1,5 @@ #include "smlua.h" +#include "pc/crash_handler.h" #include "pc/mod_list.h" #include "pc/network/network.h" @@ -152,6 +153,7 @@ static void smlua_sync_table_call_hook(int syncTableIndex, int keyIndex, int pre // call hook struct ModListEntry* prev = gLuaActiveEntry; gLuaActiveEntry = setEntry; + gPcDebug.lastModRun = gLuaActiveEntry; if (0 != lua_pcall(L, 3, 0, 0)) { LOG_LUA("Failed to call the hook_on_changed callback: %s", lua_tostring(L, -1)); smlua_logline();