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.
This commit is contained in:
kichikuou
2026-06-10 17:17:08 +09:00
parent ec9bd95dc9
commit 32024bc805
+1 -7
View File
@@ -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