From 528318e60aee8ba5391ae4b2353a7d0cdd8303e2 Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 9 May 2022 09:53:14 -0700 Subject: [PATCH] Clear hooks on lua shutdown --- src/pc/lua/smlua.c | 1 + src/pc/lua/smlua_hooks.c | 2 +- src/pc/lua/smlua_hooks.h | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pc/lua/smlua.c b/src/pc/lua/smlua.c index d748f319..ed09391a 100644 --- a/src/pc/lua/smlua.c +++ b/src/pc/lua/smlua.c @@ -183,6 +183,7 @@ void smlua_shutdown(void) { audio_custom_shutdown(); smlua_cobject_allowlist_shutdown(); smlua_cpointer_allowlist_shutdown(); + smlua_clear_hooks(); lua_State* L = gLuaState; if (L != NULL) { lua_close(L); diff --git a/src/pc/lua/smlua_hooks.c b/src/pc/lua/smlua_hooks.c index c5d588a0..fc1f3c18 100644 --- a/src/pc/lua/smlua_hooks.c +++ b/src/pc/lua/smlua_hooks.c @@ -977,7 +977,7 @@ int smlua_hook_on_sync_table_change(lua_State* L) { // misc // ////////// -static void smlua_clear_hooks(void) { +void smlua_clear_hooks(void) { for (int i = 0; i < HOOK_MAX; i++) { struct LuaHookedEvent* hooked = &sHookedEvents[i]; for (int j = 0; j < hooked->count; j++) { diff --git a/src/pc/lua/smlua_hooks.h b/src/pc/lua/smlua_hooks.h index 0796f51c..cbc2a4ba 100644 --- a/src/pc/lua/smlua_hooks.h +++ b/src/pc/lua/smlua_hooks.h @@ -88,6 +88,7 @@ u32 smlua_get_action_interaction_type(struct MarioState* m); bool smlua_call_chat_command_hook(char* command); void smlua_display_chat_commands(void); +void smlua_clear_hooks(void); void smlua_bind_hooks(void); #endif