From f7d3969f23100fb63cdd5454b1d911b28f5feda7 Mon Sep 17 00:00:00 2001 From: TakaRikka Date: Mon, 16 Sep 2024 01:23:26 +0000 Subject: [PATCH] fix actor spawner --- .../libtp_c/include/f_op/f_op_actor_mng.h | 3 ++ .../libtp_c/include/f_pc/f_pc_create_req.h | 31 +++++++++++++++++++ .../libtp_c/include/f_pc/f_pc_create_tag.h | 14 +++++++++ external/libtp_c/include/f_pc/f_pc_layer.h | 3 ++ .../libtp_c/include/f_pc/f_pc_stdcreate_req.h | 22 +++++++++++++ .../menu_actor_spawn/src/actor_spawn_menu.cpp | 18 ++++++++--- 6 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 external/libtp_c/include/f_pc/f_pc_create_req.h create mode 100644 external/libtp_c/include/f_pc/f_pc_create_tag.h create mode 100644 external/libtp_c/include/f_pc/f_pc_stdcreate_req.h diff --git a/external/libtp_c/include/f_op/f_op_actor_mng.h b/external/libtp_c/include/f_op/f_op_actor_mng.h index 2c01efdf..38f3018f 100644 --- a/external/libtp_c/include/f_op/f_op_actor_mng.h +++ b/external/libtp_c/include/f_op/f_op_actor_mng.h @@ -272,6 +272,9 @@ LIBTP_DEFINE_FUNC(fopAcM_seenActorAngleY__FPC10fopAc_ac_cPC10fopAc_ac_c, fopAcM_ LIBTP_DEFINE_FUNC(gndCheck__11fopAcM_gc_cFPC4cXyz, fopAcM_gc_c__gndCheck_cXyz_const___, bool, fopAcM_gc_c__gndCheck, (const cXyz*)) +LIBTP_DEFINE_FUNC(fopAcM_CreateAppend__Fv, fopAcM_CreateAppend_void_, + fopAcM_prm_class*, fopAcM_CreateAppend, (void)) + #define tp_fopAcM_gc_c__mGroundY_addr 0x80450cd0 #define tp_fopAcM_gc_c__mGroundY (*(f32*)(tp_fopAcM_gc_c__mGroundY_addr)) diff --git a/external/libtp_c/include/f_pc/f_pc_create_req.h b/external/libtp_c/include/f_pc/f_pc_create_req.h new file mode 100644 index 00000000..383c0aab --- /dev/null +++ b/external/libtp_c/include/f_pc/f_pc_create_req.h @@ -0,0 +1,31 @@ + +#ifndef F_PC_CREATE_REQ_H_ +#define F_PC_CREATE_REQ_H_ + +#include "../SSystem/SComponent/c_phase.h" +#include "f_pc_create_tag.h" +#include "f_pc_method.h" +#include "f_pc_method_tag.h" + +typedef struct base_process_class base_process_class; +typedef struct layer_class layer_class; + +typedef struct create_request_method_class { + cPhs__Handler mpHandler; + process_method_func mpCancel; + process_method_func mpDelete; +} create_request_method_class; + +typedef struct create_request { + create_tag mBase; + s8 mbIsCreating; + s8 mbIsCancelling; + process_method_tag_class mMtdTg; + create_request_method_class* mpCtRqMtd; + void* mpUnk1; + s32 mBsPcId; + struct base_process_class* mpRes; + layer_class* mpLayer; +} create_request; // Size: 0x48 + +#endif diff --git a/external/libtp_c/include/f_pc/f_pc_create_tag.h b/external/libtp_c/include/f_pc/f_pc_create_tag.h new file mode 100644 index 00000000..2ddc7ed6 --- /dev/null +++ b/external/libtp_c/include/f_pc/f_pc_create_tag.h @@ -0,0 +1,14 @@ + +#ifndef F_PC_CREATE_TAG_H_ +#define F_PC_CREATE_TAG_H_ + +#include "../SSystem/SComponent/c_list.h" +#include "../SSystem/SComponent/c_tag.h" + +typedef struct create_tag { + create_tag_class mBase; +} create_tag; + +extern "C" node_list_class g_fpcCtTg_Queue; + +#endif diff --git a/external/libtp_c/include/f_pc/f_pc_layer.h b/external/libtp_c/include/f_pc/f_pc_layer.h index 43cab5d4..3a387b4a 100644 --- a/external/libtp_c/include/f_pc/f_pc_layer.h +++ b/external/libtp_c/include/f_pc/f_pc_layer.h @@ -21,4 +21,7 @@ typedef struct layer_class { } counts; } layer_class; +LIBTP_DEFINE_FUNC(fpcLy_CurrentLayer__Fv, fpcLy_CurrentLayer_void_, + layer_class*, fpcLy_CurrentLayer, (void)) + #endif diff --git a/external/libtp_c/include/f_pc/f_pc_stdcreate_req.h b/external/libtp_c/include/f_pc/f_pc_stdcreate_req.h new file mode 100644 index 00000000..5b3dba1d --- /dev/null +++ b/external/libtp_c/include/f_pc/f_pc_stdcreate_req.h @@ -0,0 +1,22 @@ +#ifndef F_PC_STDCREATE_H_ +#define F_PC_STDCREATE_H_ + +#include "f_pc_create_req.h" + +typedef struct layer_class layer_class; + +typedef int (*stdCreateFunc)(void*, void*); + +typedef struct standard_create_request_class { + /* 0x00 */ create_request mBase; + /* 0x48 */ request_of_phase_process_class unk_0x48; + /* 0x50 */ s16 mLoadID; + /* 0x54 */ void* unk_0x54; + /* 0x58 */ stdCreateFunc unk_0x58; + /* 0x5C */ void* unk_0x5C; +} standard_create_request_class; + +LIBTP_DEFINE_FUNC(fpcSCtRq_Request__FP11layer_classsPFPvPv_iPvPv, fpcSCtRq_Request_layer_class____short__int_____void____void_____void____void___, + int, fpcSCtRq_Request, (layer_class*, s16, stdCreateFunc, void*, void*)) + +#endif \ No newline at end of file diff --git a/modules/menus/menu_actor_spawn/src/actor_spawn_menu.cpp b/modules/menus/menu_actor_spawn/src/actor_spawn_menu.cpp index dc1be7de..a625e936 100644 --- a/modules/menus/menu_actor_spawn/src/actor_spawn_menu.cpp +++ b/modules/menus/menu_actor_spawn/src/actor_spawn_menu.cpp @@ -3,6 +3,7 @@ #include "settings.h" #include "libtp_c/include/d/com/d_com_inf_game.h" #include "libtp_c/include/f_op/f_op_actor_mng.h" +#include "libtp_c/include/f_pc/f_pc_stdcreate_req.h" #include "libtp_c/include/m_Do/m_Do_printf.h" #include "gz_flags.h" #include "pos_settings.h" @@ -57,10 +58,19 @@ KEEP_FUNC ActorSpawnMenu::ActorSpawnMenu(ActorSpawnData& data) ActorSpawnMenu::~ActorSpawnMenu() {} -void actorFastCreateAtLink(short id, uint32_t parameters, int8_t subtype) { - fopAcM_create(id, parameters, &dComIfGp_getPlayer()->current.pos, - dComIfGp_getPlayer()->current.roomNo, &dComIfGp_getPlayer()->current.angle, - nullptr, subtype); +void actorFastCreateAtLink(s16 id, u32 parameters, s8 subtype) { + fopAcM_prm_class* appen = fopAcM_CreateAppend(); + if (appen != NULL) { + appen->mParameter = parameters; + appen->mPos = dComIfGp_getPlayer()->current.pos; + appen->mAngle = dComIfGp_getPlayer()->current.angle; + appen->mEnemyNo = 0xFFFF; + appen->mSubtype = subtype; + appen->mRoomNo = dComIfGp_getPlayer()->current.roomNo; + + layer_class* curLayer = fpcLy_CurrentLayer(); + fpcSCtRq_Request(curLayer, id, nullptr, nullptr, appen); + } } void ActorSpawnMenu::loadActorName(s16& i_procName) {