Clear hooks on lua shutdown

This commit is contained in:
MysterD 2022-05-09 09:53:14 -07:00
parent 679c5963a3
commit 528318e60a
3 changed files with 3 additions and 1 deletions

View File

@ -183,6 +183,7 @@ void smlua_shutdown(void) {
audio_custom_shutdown(); audio_custom_shutdown();
smlua_cobject_allowlist_shutdown(); smlua_cobject_allowlist_shutdown();
smlua_cpointer_allowlist_shutdown(); smlua_cpointer_allowlist_shutdown();
smlua_clear_hooks();
lua_State* L = gLuaState; lua_State* L = gLuaState;
if (L != NULL) { if (L != NULL) {
lua_close(L); lua_close(L);

View File

@ -977,7 +977,7 @@ int smlua_hook_on_sync_table_change(lua_State* L) {
// misc // // misc //
////////// //////////
static void smlua_clear_hooks(void) { void smlua_clear_hooks(void) {
for (int i = 0; i < HOOK_MAX; i++) { for (int i = 0; i < HOOK_MAX; i++) {
struct LuaHookedEvent* hooked = &sHookedEvents[i]; struct LuaHookedEvent* hooked = &sHookedEvents[i];
for (int j = 0; j < hooked->count; j++) { for (int j = 0; j < hooked->count; j++) {

View File

@ -88,6 +88,7 @@ u32 smlua_get_action_interaction_type(struct MarioState* m);
bool smlua_call_chat_command_hook(char* command); bool smlua_call_chat_command_hook(char* command);
void smlua_display_chat_commands(void); void smlua_display_chat_commands(void);
void smlua_clear_hooks(void);
void smlua_bind_hooks(void); void smlua_bind_hooks(void);
#endif #endif