From 32024bc8058b4badd9f2fac034b52473619dc478 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Fri, 5 Jun 2026 09:25:27 +0900 Subject: [PATCH] PartsEngine: Fix "Invalid controller number" error after vm_reset PE_Reset() zeroed the controller stack, leaving it with no default controller. Since PE_Reset() does not clear parts_engine_initialized, the subsequent PE_Init() returns early so the stack stays empty. Reset the stack with ctrl_stack_init() instead, which re-creates the default controller. ctrl_stack_fini() is now unused and removed. --- src/parts/parts.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/parts/parts.c b/src/parts/parts.c index 02475e0..9279277 100644 --- a/src/parts/parts.c +++ b/src/parts/parts.c @@ -40,7 +40,6 @@ struct parts_controller_stack ctrl_stack; bool parts_multi_controller; static void ctrl_stack_init(void); -static void ctrl_stack_fini(void); #define PARTS_PARAMS_INITIALIZER (struct parts_params) { \ .z = 1, \ @@ -1062,7 +1061,7 @@ void PE_Reset(void) { PE_ReleaseAllParts(); PE_ReleaseMessage(); - ctrl_stack_fini(); + ctrl_stack_init(); sact_ModuleFini(); } @@ -2110,11 +2109,6 @@ static void ctrl_stack_init(void) PE_AddController(-1); } -static void ctrl_stack_fini(void) -{ - memset(&ctrl_stack, 0, sizeof(ctrl_stack)); -} - // Adds a new controller to the stack and makes it active. The `index` // parameter specifies the position in the stack at which to insert the new // controller; -1 means "insert directly after the currently active