op_create_spatial: fix spatial object having no scriptIndex upon creation

This commit is contained in:
phobos2077
2023-06-24 01:58:17 +02:00
parent a5075734cc
commit e1aebb21e4
+4 -1
View File
@@ -198,7 +198,10 @@ void op_create_spatial(OpcodeContext& ctx) {
// this will load appropriate script program and link it to the script instance we just created: // this will load appropriate script program and link it to the script instance we just created:
exec_script_proc(scriptId, start); exec_script_proc(scriptId, start);
ctx.setReturn(fo::func::scr_find_obj_from_program(scriptPtr->program)); fo::GameObject* obj = fo::func::scr_find_obj_from_program(scriptPtr->program);
// set script index because scr_find_obj_from_program() doesn't do it when creating a hidden "spatial" object
obj->scriptIndex = scriptIndex - 1;
ctx.setReturn(obj);
} }
#undef exec_script_proc #undef exec_script_proc