From d82fa3ccae8682a0e9b07c35a07b12b775be18af Mon Sep 17 00:00:00 2001 From: LagoLunatic Date: Mon, 27 Nov 2023 21:33:08 -0500 Subject: [PATCH] match d_a_swc00 --- configure.py | 2 +- include/d/actor/d_a_swc00.h | 5 ++++ src/d/actor/d_a_swc00.cpp | 54 ++++++++++++++++++------------------- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/configure.py b/configure.py index 7463bac89..cb77b2f90 100644 --- a/configure.py +++ b/configure.py @@ -1302,7 +1302,7 @@ config.libs = [ ActorRel(NonMatching, "d_a_ssk"), ActorRel(NonMatching, "d_a_stone"), ActorRel(NonMatching, "d_a_stone2"), - ActorRel(NonMatching, "d_a_swc00"), + ActorRel(Matching, "d_a_swc00"), ActorRel(NonMatching, "d_a_swhit0"), ActorRel(Matching, "d_a_swtdoor"), ActorRel(NonMatching, "d_a_tag_attention"), diff --git a/include/d/actor/d_a_swc00.h b/include/d/actor/d_a_swc00.h index 8900aecad..bd1bab20a 100644 --- a/include/d/actor/d_a_swc00.h +++ b/include/d/actor/d_a_swc00.h @@ -2,7 +2,12 @@ #define D_A_SWC00_H #include "f_op/f_op_actor.h" +#include "f_op/f_op_actor_mng.h" class swc00_class : public fopAc_ac_c {}; +static inline s32 daSwc00_getSw1No(swc00_class* i_this) { return fopAcM_GetParam(i_this) & 0xFF; } +static inline s32 daSwc00_getSw2No(swc00_class* i_this) { return (fopAcM_GetParam(i_this) >> 8) & 0xFF; } +static inline s32 daSwc00_getType(swc00_class* i_this) { return (fopAcM_GetParam(i_this) >> 0x10) & 0x3; } + #endif /* D_A_SWC00_H */ diff --git a/src/d/actor/d_a_swc00.cpp b/src/d/actor/d_a_swc00.cpp index f9ebdd8b5..608eea78b 100644 --- a/src/d/actor/d_a_swc00.cpp +++ b/src/d/actor/d_a_swc00.cpp @@ -9,48 +9,46 @@ #include "d/d_procname.h" #include "d/d_com_inf_game.h" -static inline s32 getSwBit(u32 param) { - return param & 0xFF; -} +static BOOL daSwc00_Execute(swc00_class* i_this) { + s32 enable_sw = daSwc00_getSw2No(i_this); + fopAc_ac_c* actor = i_this; + if(enable_sw == 0xFF || dComIfGs_isSwitch(enable_sw, fopAcM_GetRoomNo(i_this))) { + s32 swBit = daSwc00_getSw1No(i_this); -static s32 daSwc00_Execute(swc00_class* i_this) { - /* Nonmatching */ - s32 enable_sw = fopAcM_GetParam(i_this) >> 8 & 0xFF; - if(enable_sw == 0xFF || dComIfGs_isSwitch(enable_sw, i_this->current.roomNo)) { - u8 swBit = fopAcM_GetParam(i_this) & 0xFF; + f32 xz_dist2 = fopAcM_searchPlayerDistanceXZ2(i_this); + f32 y_diff = fopAcM_searchPlayerDistanceY(i_this); + if(xz_dist2 < i_this->mScale.x && (-100.0f < y_diff && y_diff < i_this->mScale.y)) { + dComIfGs_onSwitch(swBit, fopAcM_GetRoomNo(i_this)); - f32 xz_dist = fopAcM_searchPlayerDistanceXZ2(i_this); - f32 y_diff = dComIfGp_getPlayer(0)->current.pos.y - i_this->current.pos.y; - if(xz_dist < i_this->mScale.x && (-100.0f < y_diff && y_diff < i_this->mScale.y)) { - dComIfGs_onSwitch(swBit, i_this->current.roomNo); - - if((fopAcM_GetParam(i_this) >> 0x10 & 3) != 0) { - fopAcM_delete(i_this); + if(daSwc00_getType(i_this) != 0) { + fopAcM_delete(actor); } } - else if((fopAcM_GetParam(i_this) >> 0x10 & 3) == 0) { - dComIfGs_offSwitch(swBit, i_this->current.roomNo); + else if(daSwc00_getType(i_this) == 0) { + dComIfGs_offSwitch(swBit, fopAcM_GetRoomNo(i_this)); } } - return 1; + return TRUE; } -static s32 daSwc00_IsDelete(swc00_class* i_this) { - return 1; +static BOOL daSwc00_IsDelete(swc00_class* i_this) { + return TRUE; } -static s32 daSwc00_Delete(swc00_class* i_this) { - return 1; +static BOOL daSwc00_Delete(swc00_class* i_this) { + return TRUE; } -static s32 daSwc00_Create(fopAc_ac_c* i_this) { - fopAcM_SetupActor(i_this, swc00_class); +static s32 daSwc00_Create(fopAc_ac_c* i_actor) { + fopAcM_SetupActor(i_actor, swc00_class); - if(dComIfGs_isSwitch(fopAcM_GetParam(i_this) & 0xFF, i_this->current.roomNo)) { - if((fopAcM_GetParam(i_this) >> 0x10 & 0x3) == 0) { - u32 swBit = getSwBit(fopAcM_GetParam(i_this)); - dComIfGs_offSwitch(swBit, i_this->current.roomNo); + swc00_class* i_this = (swc00_class*)i_actor; + + if(dComIfGs_isSwitch(daSwc00_getSw1No(i_this), fopAcM_GetRoomNo(i_this))) { + if(daSwc00_getType(i_this) == 0) { + s32 swBit = daSwc00_getSw1No(i_this); + dComIfGs_offSwitch(swBit, fopAcM_GetRoomNo(i_this)); } else { return cPhs_ERROR_e;