From 09d09071c2dcf94180cf55cd4886c58c8329f8b7 Mon Sep 17 00:00:00 2001 From: Cuyler36 Date: Wed, 29 Oct 2025 23:09:03 -0400 Subject: [PATCH] ac_haniwa: refactor --- include/ac_haniwa.h | 2 +- src/actor/ac_haniwa.c | 55 +++-- src/actor/ac_haniwa_move.c_inc | 353 ++++++++++++++++++--------------- 3 files changed, 216 insertions(+), 194 deletions(-) diff --git a/include/ac_haniwa.h b/include/ac_haniwa.h index fb250757..1cbb18d0 100644 --- a/include/ac_haniwa.h +++ b/include/ac_haniwa.h @@ -13,7 +13,7 @@ extern "C" { typedef struct actor_haniwa_s HANIWA_ACTOR; -typedef void (*HANIWA_ACTOR_PROC)(ACTOR*, GAME*); +typedef void (*HANIWA_ACTOR_PROC)(HANIWA_ACTOR*, GAME*); enum haniwa_msg { aHNW_MSG_NO_OWNER, diff --git a/src/actor/ac_haniwa.c b/src/actor/ac_haniwa.c index 5b24b831..8c80ed49 100644 --- a/src/actor/ac_haniwa.c +++ b/src/actor/ac_haniwa.c @@ -31,36 +31,40 @@ static void aHNW_actor_dt(ACTOR* actor, GAME* game); static void aHNW_actor_init(ACTOR* actor, GAME* game); static void aHNW_actor_draw(ACTOR* actor, GAME* game); +// clang-format off ACTOR_PROFILE Haniwa_Profile = { - mAc_PROFILE_HANIWA, ACTOR_PART_BG, ACTOR_STATE_NONE, ACTOR_PROP_HANIWA0, ACTOR_OBJ_BANK_12, + mAc_PROFILE_HANIWA, + ACTOR_PART_BG, + ACTOR_STATE_NONE, + ACTOR_PROP_HANIWA0, + ACTOR_OBJ_BANK_12, sizeof(HANIWA_ACTOR), - - &aHNW_actor_ct, &aHNW_actor_dt, &aHNW_actor_init, (mActor_proc)&none_proc1, NULL + &aHNW_actor_ct, + &aHNW_actor_dt, + &aHNW_actor_init, + mActor_NONE_PROC1, + NULL, }; +// clang-format on static ClObjPipeData_c AcHaniwaCoInfoData = { { 57, 32, ClObj_TYPE_PIPE }, { 1 }, { 20, 30, 0, { 0, 0, 0 } } }; -static StatusData_c AcHaniwaStatusData = { 0, 20, 30, 0, 254 }; +static StatusData_c AcHaniwaStatusData = { 0, 20, 30, 0, MASSTYPE_HEAVY }; /* TODO: ct, dt, & draw are in their own TU */ static void aHNW_actor_ct(ACTOR* actor, GAME* game) { HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - ClObjPipe_c* pipe; cKF_SkeletonInfo_R_c* keyframe = &haniwa->common_actor_class.anime.keyframe; - GAME_PLAY* play = (GAME_PLAY*)game; cKF_SkeletonInfo_R_ct(keyframe, &cKF_bs_r_hnw, NULL, haniwa->keyframe_work_area, haniwa->keyframe_morph_area); - - pipe = &haniwa->common_actor_class.col_pipe; - ClObjPipe_ct(game, pipe); - ClObjPipe_set5(game, pipe, actor, &AcHaniwaCoInfoData); - CollisionCheck_Status_set3(&haniwa->common_actor_class.actor_class.status_data, &AcHaniwaStatusData); - { - Object_Bank_c* bank = &play->object_exchange.banks[actor->data_bank_id]; - haniwa->bank_ram_start = bank->ram_start; + ClObjPipe_c* pipe = &haniwa->common_actor_class.col_pipe; + ClObjPipe_ct(game, pipe); + ClObjPipe_set5(game, pipe, actor, &AcHaniwaCoInfoData); + CollisionCheck_Status_set3(&haniwa->common_actor_class.actor_class.status_data, &AcHaniwaStatusData); } + haniwa->bank_ram_start = ((GAME_PLAY*)game)->object_exchange.banks[actor->data_bank_id].ram_start; haniwa->common_actor_class.anime.anime_no = 2; haniwa->house_idx = actor->npc_id - ACTOR_PROP_HANIWA0; actor->talk_distance = 43.0f; @@ -68,10 +72,9 @@ static void aHNW_actor_ct(ACTOR* actor, GAME* game) { static void aHNW_actor_dt(ACTOR* actor, GAME* game) { HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; if (haniwa->playing_save_bgm) { - mBGMPsComp_delete_ps_demo(0x41, 0x168); + mBGMPsComp_delete_ps_demo(BGM_ENTER_HOUSE, 0x168); } cKF_SkeletonInfo_R_dt(&haniwa->common_actor_class.anime.keyframe); @@ -89,31 +92,27 @@ static void aHNW_actor_draw(ACTOR* actor, GAME* game) { HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; cKF_SkeletonInfo_R_c* keyframe = &haniwa->common_actor_class.anime.keyframe; GRAPH* g = game->graph; - Mtx* m; - - m = GRAPH_ALLOC_TYPE(g, Mtx, keyframe->skeleton->num_shown_joints); + Mtx* m = GRAPH_ALLOC_TYPE(g, Mtx, keyframe->skeleton->num_shown_joints); if (m != NULL) { - Gfx* gfx; int house_idx = haniwa->house_idx; + _texture_z_light_fog_prim(g); - OPEN_DISP(g); - gfx = NOW_POLY_OPA_DISP; + OPEN_POLY_OPA_DISP(g); - gSPSegment(gfx++, G_MWO_SEGMENT_B, hnw_tmem_txt); + gSPSegment(POLY_OPA_DISP++, ANIME_4_TXT_SEG, hnw_tmem_txt); if (mPr_NullCheckPersonalID(&Save_Get(homes[house_idx]).ownerID) != TRUE && Common_Get(player_no) == mHS_get_pl_no(house_idx)) { - gDPSetPrimColor(gfx++, 0, 128, 255, 255, 255, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 128, 255, 255, 255, 255); } else { - gDPSetPrimColor(gfx++, 0, 128, 255, 255, 255, 255); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 128, 255, 255, 255, 255); } - gSPDisplayList(gfx++, hnw_tex_model); + gSPDisplayList(POLY_OPA_DISP++, hnw_tex_model); - SET_POLY_OPA_DISP(gfx); - CLOSE_DISP(g); + CLOSE_POLY_OPA_DISP(g); cKF_Si3_draw_R_SV(game, keyframe, m, NULL, NULL, actor); } diff --git a/src/actor/ac_haniwa_move.c_inc b/src/actor/ac_haniwa_move.c_inc index 1682eecd..0aaecf6d 100644 --- a/src/actor/ac_haniwa_move.c_inc +++ b/src/actor/ac_haniwa_move.c_inc @@ -1,4 +1,36 @@ -static void aHNW_setupAction(ACTOR* actor, GAME* game, int action); +#ifdef __INTELLISENSE__ +#include "ac_haniwa.h" + +#include "m_play.h" +#include "m_bgm.h" +#include "m_rcp.h" +#include "m_name_table.h" +#include "m_house.h" +#include "m_font.h" +#include "m_msg.h" +#include "m_choice.h" +#include "m_demo.h" +#include "m_player.h" +#include "m_player_lib.h" +#include "m_clip.h" +#include "m_event.h" +#include "ac_intro_demo.h" +#include "ac_my_house.h" +#include "m_needlework_ovl.h" +#include "m_npc.h" +#include "m_submenu.h" +#include "m_field_info.h" +#include "m_common_data.h" + +static void aHNW_actor_draw(ACTOR* actor, GAME* game); + +extern cKF_Skeleton_R_c cKF_bs_r_hnw; +extern cKF_Animation_R_c cKF_ba_r_hnw_move; +extern u8 hnw_tmem_txt[]; +extern u16 hnw_face[]; +#endif + +static void aHNW_setupAction(HANIWA_ACTOR* haniwa, GAME* game, int action); static int aHNW_set_save_permission() { u32 player_no = Common_Get(player_no); @@ -20,18 +52,17 @@ static int aHNW_set_save_permission() { return res; } -static void aHNW_search_player(ACTOR* actor) { - chase_angle(&actor->shape_info.rotation.y, actor->player_angle_y, 0x0600); +static void aHNW_search_player(HANIWA_ACTOR* haniwa) { + chase_angle(&((ACTOR*)haniwa)->shape_info.rotation.y, ((ACTOR*)haniwa)->player_angle_y, 0x0600); } -static void aHNW_search_front(ACTOR* actor, int house_idx) { +static void aHNW_search_front(HANIWA_ACTOR* haniwa, int house_idx) { s16 target_angle[mHS_HOUSE_NUM] = { 8000, -8000, 8000, -8000 }; - chase_angle(&actor->shape_info.rotation.y, target_angle[house_idx], 0x0600); + chase_angle(&haniwa->common_actor_class.actor_class.shape_info.rotation.y, target_angle[house_idx], 0x0600); } -static int aHNW_check_keep_item(ACTOR* actor) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; +static int aHNW_check_keep_item(HANIWA_ACTOR* haniwa) { Haniwa_Item_c* haniwa_item = Save_Get(homes[haniwa->house_idx]).haniwa.items; int i; int res = FALSE; @@ -52,7 +83,7 @@ static void aHNW_set_proceeds_str(Haniwa_c* haniwa) { u8 str[7]; mFont_UnintToString(str, 7, haniwa->bells, 6, TRUE, FALSE, TRUE); - mMsg_Set_free_str(mMsg_Get_base_window_p(), 0, str, 7); + mMsg_SET_FREE_STR(mMsg_FREE_STR0, str, sizeof(str)); } static int aHNW_check_handOver_proceeds(Haniwa_c* haniwa) { @@ -79,26 +110,24 @@ static int aHNW_check_handOver_proceeds(Haniwa_c* haniwa) { u8 str[5]; mFont_UnintToString(str, 5, num_30k_bell_bags, 5, TRUE, FALSE, TRUE); - mMsg_Set_free_str(mMsg_Get_base_window_p(), 1, str, 5); + mMsg_SET_FREE_STR(mMsg_FREE_STR1, str, sizeof(str)); } } return handOver; } -static int aHNW_check_house_door(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; +static int aHNW_check_house_door(ACTOR* actor, GAME_PLAY* play) { int res = FALSE; - GAME_PLAY* play = (GAME_PLAY*)game; if (Common_Get(reset_flag) == TRUE) { ACTOR* talk_actor = mDemo_Get_talk_actor(); if (talk_actor == NULL && chkTrigger(BUTTON_A)) { - PLAYER_ACTOR* player = get_player_actor_withoutCheck(play); + ACTOR* playerx = GET_PLAYER_ACTOR_ACTOR(play); - if (mDemo_Check_DiffAngle_forTalk((actor->player_angle_y - player->actor_class.shape_info.rotation.y) - - -0x8000) == TRUE) { + if (mDemo_Check_DiffAngle_forTalk((actor->player_angle_y - playerx->shape_info.rotation.y) + + DEG2SHORT_ANGLE2(180.0f)) == TRUE) { Common_Set(reset_type, 4); } } @@ -119,14 +148,13 @@ static int aHNW_check_house_door(ACTOR* actor, GAME* game) { return res; } -static void aHNW_wait(ACTOR* actor, GAME* game) { - if (actor->player_distance_xz < 80.0f) { - aHNW_setupAction(actor, game, aHNW_ACTION_DANCE); +static void aHNW_wait(HANIWA_ACTOR* haniwa, GAME* game) { + if (haniwa->common_actor_class.actor_class.player_distance_xz < 80.0f) { + aHNW_setupAction(haniwa, game, aHNW_ACTION_DANCE); } } -static int aHNW_decide_msg_idx_dance(ACTOR* actor) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; +static int aHNW_decide_msg_idx_dance(HANIWA_ACTOR* haniwa) { Haniwa_c* house_haniwa; int house_idx = haniwa->house_idx; int player_is_owner = Common_Get(player_no) == mHS_get_pl_no(haniwa->house_idx); @@ -168,7 +196,7 @@ static void aHNW_set_talk_info_dance(ACTOR* actor) { HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; int house_idx = haniwa->house_idx; Haniwa_c* house_haniwa = &Save_Get(homes[house_idx]).haniwa; - int msg_idx = aHNW_decide_msg_idx_dance(actor); + int msg_idx = aHNW_decide_msg_idx_dance(haniwa); switch (msg_idx) { case aHNW_MSG_PROCEEDS: { @@ -185,7 +213,7 @@ static void aHNW_set_talk_info_dance(ACTOR* actor) { mDemo_Set_msg_num(msg_no[msg_idx]); } -static void aHNW_dance(ACTOR* actor, GAME* game) { +static void aHNW_dance(HANIWA_ACTOR* haniwa, GAME* game) { static int next_act_idx[aHNW_MSG_NUM] = { aHNW_ACTION_TALK_END_WAIT, /* aHNW_MSG_NO_OWNER */ aHNW_ACTION_CHECK_PROCEEDS, /* aHNW_MSG_PROCEEDS */ @@ -194,22 +222,23 @@ static void aHNW_dance(ACTOR* actor, GAME* game) { aHNW_ACTION_TALK_END_WAIT /* aHNW_MSG_NEED_FRIEND */ }; - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; + ACTOR* actorx = (ACTOR*)haniwa; - if (actor->player_distance_xz > 90.0f) { - aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); + if (((ACTOR*)haniwa)->player_distance_xz > 90.0f) { + aHNW_setupAction(haniwa, game, aHNW_ACTION_WAIT); } else { - if (mDemo_Check(mDemo_TYPE_TALK, (ACTOR*)haniwa) == TRUE && mDemo_Check_ListenAble() == FALSE) { - int msg_idx = aHNW_decide_msg_idx_dance(actor); + if (mDemo_Check(mDemo_TYPE_TALK, actorx) == TRUE && mDemo_Check_ListenAble() == FALSE) { + int msg_idx = aHNW_decide_msg_idx_dance(haniwa); + mDemo_Set_ListenAble(); - aHNW_setupAction(actor, game, next_act_idx[msg_idx]); - } else if (aHNW_check_house_door((ACTOR*)haniwa, game) == FALSE) { - mDemo_Request(mDemo_TYPE_TALK, (ACTOR*)haniwa, &aHNW_set_talk_info_dance); + aHNW_setupAction(haniwa, game, next_act_idx[msg_idx]); + } else if (aHNW_check_house_door(actorx, (GAME_PLAY*)game) == FALSE) { + mDemo_Request(mDemo_TYPE_TALK, actorx, &aHNW_set_talk_info_dance); } } } -static void aHNW_check_proceeds(ACTOR* actor, GAME* game) { +static void aHNW_check_proceeds(HANIWA_ACTOR* haniwa, GAME* game) { static int msg_no[aHNW_HANDOVER_NUM] = { 0x0936, /* aHNW_HANDOVER_YES */ 0x0937 /* aHNW_HANDOVER_NO */ @@ -220,8 +249,6 @@ static void aHNW_check_proceeds(ACTOR* actor, GAME* game) { aHNW_ACTION_TALK_END_WAIT /* aHNW_HANDOVER_NO */ }; - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9)) { int house_idx = haniwa->house_idx; Haniwa_c* house_haniwa = &Save_Get(homes[house_idx]).haniwa; @@ -234,20 +261,19 @@ static void aHNW_check_proceeds(ACTOR* actor, GAME* game) { handover_state = aHNW_HANDOVER_NO; } - mMsg_Set_continue_msg_num(mMsg_Get_base_window_p(), msg_no[handover_state]); - aHNW_setupAction(actor, game, next_act_idx[handover_state]); + mMsg_SET_CONTINUE_MSG_NUM(msg_no[handover_state]); + aHNW_setupAction(haniwa, game, next_act_idx[handover_state]); mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); } } -static void aHNW_talk_with_master(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; +static void aHNW_talk_with_master(HANIWA_ACTOR* haniwa, GAME* game) { mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9) && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { int action = -1; - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + switch (mChoice_GET_CHOSENUM()) { case mChoice_CHOICE0: { action = aHNW_ACTION_SAVE_CHECK; break; @@ -272,19 +298,18 @@ static void aHNW_talk_with_master(ACTOR* actor, GAME* game) { if (action != -1) { mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); - aHNW_setupAction(actor, game, action); + aHNW_setupAction(haniwa, game, action); } } } -static void aHNW_talk_with_master2(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; +static void aHNW_talk_with_master2(HANIWA_ACTOR* haniwa, GAME* game) { mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9) && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { int action = -1; - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + switch (mChoice_GET_CHOSENUM()) { case mChoice_CHOICE0: { action = aHNW_ACTION_ROOF_CHECK; break; @@ -309,25 +334,23 @@ static void aHNW_talk_with_master2(ACTOR* actor, GAME* game) { if (action != -1) { mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); - aHNW_setupAction(actor, game, action); + aHNW_setupAction(haniwa, game, action); } } } -static void aHNW_talk_end_wait(ACTOR* actor, GAME* game) { - if (mDemo_Check(mDemo_TYPE_TALK, actor) == FALSE) { - aHNW_setupAction(actor, game, aHNW_ACTION_DANCE); +static void aHNW_talk_end_wait(HANIWA_ACTOR* haniwa, GAME* game) { + if (mDemo_Check(mDemo_TYPE_TALK, (ACTOR*)haniwa) == FALSE) { + aHNW_setupAction(haniwa, game, aHNW_ACTION_DANCE); } } -static void aHNW_menu_open_wait(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; +static void aHNW_menu_open_wait(HANIWA_ACTOR* haniwa, GAME* game) { mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); if (mMsg_Check_main_wait(msg_win) == TRUE) { int submenu_type = haniwa->submenu_type; - Submenu* submenu = &play->submenu; + Submenu* submenu = &((GAME_PLAY*)game)->submenu; int arg1 = haniwa->house_idx; switch (submenu_type) { @@ -349,25 +372,23 @@ static void aHNW_menu_open_wait(ACTOR* actor, GAME* game) { mMsg_ChangeMsgData(msg_win, 0x0927); mMsg_Set_ForceNext(msg_win); - aHNW_setupAction(actor, game, aHNW_ACTION_MENU_END_WAIT); + aHNW_setupAction(haniwa, game, aHNW_ACTION_MENU_END_WAIT); } } -static void aHNW_menu_end_wait(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; - Submenu* submenu = &play->submenu; +static void aHNW_menu_end_wait(HANIWA_ACTOR* haniwa, GAME* game) { + Submenu* submenu = &((GAME_PLAY*)game)->submenu; Submenu_Item_c* item; if (submenu->open_flag == FALSE) { - if (mMsg_Check_not_series_main_wait(mMsg_Get_base_window_p()) == TRUE) { - aHNW_setupAction(actor, game, aHNW_ACTION_TALK_WITH_MASTER); + if (mMsg_CHECK_NOT_SERIES_MAIN_WAIT() == TRUE) { + aHNW_setupAction(haniwa, game, aHNW_ACTION_TALK_WITH_MASTER); switch (haniwa->submenu_type) { case mSM_OVL_NEEDLEWORK: { Submenu_Item_c* item = submenu->item_p; if (item->item == RSV_NO) { Save_Get(homes[haniwa->house_idx]).door_original = mNW_get_image_no(submenu, item->slot_no); - sAdo_SysTrgStart(0x461); + sAdo_SysTrgStart(NA_SE_461); } break; @@ -379,17 +400,15 @@ static void aHNW_menu_end_wait(ACTOR* actor, GAME* game) { } } -static void aHNW_talk_with_guest(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - +static void aHNW_talk_with_guest(HANIWA_ACTOR* haniwa, GAME* game) { if (mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 0)) { mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); if (mMsg_Check_MainNormalContinue(msg_win) == TRUE) { int action = -1; - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + switch (mChoice_GET_CHOSENUM()) { case mChoice_CHOICE0: { - if (aHNW_check_keep_item(actor) == FALSE) { + if (aHNW_check_keep_item(haniwa) == FALSE) { mMsg_Set_continue_msg_num(msg_win, 0x092C); action = aHNW_ACTION_TALK_END_WAIT; } else { @@ -407,46 +426,44 @@ static void aHNW_talk_with_guest(ACTOR* actor, GAME* game) { if (action != -1) { mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 0, 0); - aHNW_setupAction(actor, game, action); + aHNW_setupAction(haniwa, game, action); } } } } -static void aHNW_menu_open_wait_for_guest(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; +static void aHNW_menu_open_wait_for_guest(HANIWA_ACTOR* haniwa, GAME* game) { mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); if (mMsg_Check_main_wait(msg_win) == TRUE) { - mSM_open_submenu(&play->submenu, mSM_OVL_INVENTORY, 3, haniwa->house_idx); + Submenu* submenu = &((GAME_PLAY*)game)->submenu; + + mSM_open_submenu(submenu, mSM_OVL_INVENTORY, mSM_IV_OPEN_HANIWA_TAKE, haniwa->house_idx); mMsg_ChangeMsgData(msg_win, 0x092B); - aHNW_setupAction(actor, game, aHNW_ACTION_MENU_END_WAIT_FOR_GUEST); + aHNW_setupAction(haniwa, game, aHNW_ACTION_MENU_END_WAIT_FOR_GUEST); } } -static void aHNW_menu_end_wait_for_guest(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; +static void aHNW_menu_end_wait_for_guest(HANIWA_ACTOR* haniwa, GAME* game) { + Submenu* submenu = &((GAME_PLAY*)game)->submenu; - if (play->submenu.open_flag == FALSE && mMsg_Check_not_series_main_wait(mMsg_Get_base_window_p()) == TRUE) { - aHNW_setupAction(actor, game, aHNW_ACTION_TALK_END_WAIT); + if (!submenu->open_flag && mMsg_CHECK_NOT_SERIES_MAIN_WAIT() == TRUE) { + aHNW_setupAction(haniwa, game, aHNW_ACTION_TALK_END_WAIT); } } -static void aHNW_save_check(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; +static void aHNW_save_check(HANIWA_ACTOR* haniwa, GAME* game) { mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); int order_value = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); int action = -1; if (order_value && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + switch (mChoice_GET_CHOSENUM()) { case mChoice_CHOICE0: { action = aHNW_ACTION_SAVE_END_WAIT; mBGMPsComp_scene_mode(13); - mDemo_Set_talk_return_demo_wait(1); - mPlib_Set_able_force_speak_label(actor); + mDemo_Set_talk_return_demo_wait(TRUE); + mPlib_Set_able_force_speak_label((ACTOR*)haniwa); break; } @@ -458,19 +475,18 @@ static void aHNW_save_check(ACTOR* actor, GAME* game) { if (action != -1) { mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); - aHNW_setupAction(actor, game, action); + aHNW_setupAction(haniwa, game, action); } } } -static void aHNW_roof_check(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; +static void aHNW_roof_check(HANIWA_ACTOR* haniwa, GAME* game) { mMsg_Window_c* msg_win = mMsg_Get_base_window_p(); int order_value = mDemo_Get_OrderValue(mDemo_ORDER_NPC0, 9); int action = -1; if (order_value && mMsg_Check_MainNormalContinue(msg_win) == TRUE) { - switch (mChoice_Get_ChoseNum(mChoice_Get_base_window_p())) { + switch (mChoice_GET_CHOSENUM()) { case mChoice_CHOICE0: { action = aHNW_ACTION_MENU_OPEN_WAIT; haniwa->submenu_type = mSM_OVL_NEEDLEWORK; @@ -492,42 +508,39 @@ static void aHNW_roof_check(ACTOR* actor, GAME* game) { if (action != -1) { mDemo_Set_OrderValue(mDemo_ORDER_NPC0, 9, 0); - aHNW_setupAction(actor, game, action); + aHNW_setupAction(haniwa, game, action); } } } -static void aHNW_save_end_wait(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - - if (haniwa->playing_save_bgm == FALSE && mMsg_Check_MainDisappear(mMsg_Get_base_window_p())) { +static void aHNW_save_end_wait(HANIWA_ACTOR* haniwa, GAME* game) { + if (haniwa->playing_save_bgm == FALSE && mMsg_CHECK_MAINDISAPPEAR()) { haniwa->playing_save_bgm = TRUE; - mBGMPsComp_make_ps_demo(0x41, 0x168); + mBGMPsComp_make_ps_demo(BGM_ENTER_HOUSE, 0x168); } - if (mDemo_Check(mDemo_TYPE_TALK, actor) == FALSE) { - aHNW_setupAction(actor, game, aHNW_ACTION_PL_APPROACH_DOOR); + if (mDemo_Check(mDemo_TYPE_TALK, (ACTOR*)haniwa) == FALSE) { + aHNW_setupAction(haniwa, game, aHNW_ACTION_PL_APPROACH_DOOR); aHNW_set_save_permission(); } } -static void aHNW_pl_approach_door(ACTOR* actor, GAME* game) { +static void aHNW_pl_approach_door(HANIWA_ACTOR* haniwa, GAME* game) { static f32 chk_posX[mHS_HOUSE_NUM] = { 2095.0f, 2385.0f, 2095.0f, 2385.0f }; static f32 chk_val[mHS_HOUSE_NUM] = { 1.0f, -1.0f, 1.0f, -1.0f }; - static xyz_t goal_pos[mHS_HOUSE_NUM][2] = { { { 2098.0f, 0.0f, 1540.0f }, { 2110.0f, 0.0f, 1474.0f } }, - { { 2382.0f, 0.0f, 1540.0f }, { 2369.0f, 0.0f, 1474.0f } }, - { { 2098.0f, 0.0f, 1820.0f }, { 2110.0f, 0.0f, 1755.0f } }, - { { 2382.0f, 0.0f, 1820.0f }, { 2369.0f, 0.0f, 1755.0f } } }; + static xyz_t goal_pos[mHS_HOUSE_NUM][2] = { + { { 2098.0f, 0.0f, 1540.0f }, { 2110.0f, 0.0f, 1474.0f } }, + { { 2382.0f, 0.0f, 1540.0f }, { 2369.0f, 0.0f, 1474.0f } }, + { { 2098.0f, 0.0f, 1820.0f }, { 2110.0f, 0.0f, 1755.0f } }, + { { 2382.0f, 0.0f, 1820.0f }, { 2369.0f, 0.0f, 1755.0f } }, + }; - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; - PLAYER_ACTOR* player = get_player_actor_withoutCheck((GAME_PLAY*)game); + ACTOR* playerx = GET_PLAYER_ACTOR_GAME_ACTOR(game); haniwa->door_approach_frame++; - - if (player != NULL) { + if (playerx != NULL) { int house_idx = haniwa->house_idx; - int stage = ((chk_posX[house_idx] - player->actor_class.world.position.x) * chk_val[house_idx]) <= 0.0f; + int stage = ((chk_posX[house_idx] - playerx->world.position.x) * chk_val[house_idx]) <= 0.0f; xyz_t* goal = goal_pos[house_idx] + stage; if (haniwa->player_approach_door_stage != stage && @@ -538,112 +551,123 @@ static void aHNW_pl_approach_door(ACTOR* actor, GAME* game) { mPlib_Set_goal_player_demo_walk(goal->x, goal->z, 3.0f); if (haniwa->door_approach_frame > 160) { + mActor_name_t house_item = HOUSE0 + haniwa->house_idx; MY_HOUSE_ACTOR* house_actor = (MY_HOUSE_ACTOR*)Actor_info_fgName_search( - &play->actor_info, HOUSE0 + haniwa->house_idx, ACTOR_PART_ITEM); + &((GAME_PLAY*)game)->actor_info, house_item, ACTOR_PART_ITEM); if (house_actor != NULL) { house_actor->structure_class.actor_class.world.angle.z = 1; - aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); + aHNW_setupAction(haniwa, game, aHNW_ACTION_WAIT); } - } else if (stage == 1 && search_position_distanceXZ(goal, &player->actor_class.world.position) < 3.0f) { - aHNW_setupAction(actor, game, aHNW_ACTION_DOOR_OPEN_WAIT); + } else if (stage == 1 && search_position_distanceXZ(goal, &playerx->world.position) < 3.0f) { + aHNW_setupAction(haniwa, game, aHNW_ACTION_DOOR_OPEN_WAIT); } } } -static void aHNW_door_open_wait(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; +static void aHNW_door_open_wait(HANIWA_ACTOR* haniwa, GAME* game) { + mActor_name_t house_item = HOUSE0 + haniwa->house_idx; MY_HOUSE_ACTOR* house_actor = - (MY_HOUSE_ACTOR*)Actor_info_fgName_search(&play->actor_info, HOUSE0 + haniwa->house_idx, ACTOR_PART_ITEM); + (MY_HOUSE_ACTOR*)Actor_info_fgName_search(&((GAME_PLAY*)game)->actor_info, house_item, ACTOR_PART_ITEM); if (house_actor != NULL) { house_actor->structure_class.request_type = 6; // TODO: this is probably an enum - if (house_actor != get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->get_door_label_proc(gamePT)) { - aHNW_setupAction(actor, game, aHNW_ACTION_DOOR_OPEN_TIMER); + if (house_actor != GET_PLAYER_ACTOR_NOW()->get_door_label_proc(gamePT)) { + aHNW_setupAction(haniwa, game, aHNW_ACTION_DOOR_OPEN_TIMER); haniwa->door_approach_frame = 0; } else { - aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); + aHNW_setupAction(haniwa, game, aHNW_ACTION_WAIT); } } } -static void aHNW_door_open_timer(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - GAME_PLAY* play = (GAME_PLAY*)game; +static void aHNW_door_open_timer(HANIWA_ACTOR* haniwa, GAME* game) { + mActor_name_t house_item = HOUSE0 + haniwa->house_idx; MY_HOUSE_ACTOR* house_actor = - (MY_HOUSE_ACTOR*)Actor_info_fgName_search(&play->actor_info, HOUSE0 + haniwa->house_idx, ACTOR_PART_ITEM); + (MY_HOUSE_ACTOR*)Actor_info_fgName_search(&((GAME_PLAY*)game)->actor_info, house_item, ACTOR_PART_ITEM); if (house_actor != NULL) { - if (house_actor == get_player_actor_withoutCheck((GAME_PLAY*)gamePT)->get_door_label_proc(gamePT)) { - aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); + if (house_actor == GET_PLAYER_ACTOR_NOW()->get_door_label_proc(gamePT)) { + aHNW_setupAction(haniwa, game, aHNW_ACTION_WAIT); } else { haniwa->door_approach_frame++; if (haniwa->door_approach_frame > 80) { house_actor->structure_class.actor_class.world.angle.z = 1; - aHNW_setupAction(actor, game, aHNW_ACTION_WAIT); + aHNW_setupAction(haniwa, game, aHNW_ACTION_WAIT); } } } } -static void aHNW_menu_open_wait_init(ACTOR* actor, GAME* game) { - mMsg_request_main_disappear_wait_type1(mMsg_Get_base_window_p()); +static void aHNW_menu_open_wait_init(HANIWA_ACTOR* haniwa, GAME* game) { + mMsg_REQUEST_MAIN_DISAPPEAR_WAIT_TYPE1(); } -static void aHNW_menu_end_wait_init(ACTOR* actor, GAME* game) { - mMsg_request_main_appear_wait_type1(mMsg_Get_base_window_p()); +static void aHNW_menu_end_wait_init(HANIWA_ACTOR* haniwa, GAME* game) { + mMsg_REQUEST_MAIN_APPEAR_WAIT_TYPE1(); } -static void aHNW_talk_with_guest_init(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; +static void aHNW_talk_with_guest_init(HANIWA_ACTOR* haniwa, GAME* game) { + PersonalID_c* pid_p = &Save_Get(homes[haniwa->house_idx]).ownerID; + u8* name_p = pid_p->player_name; - mMsg_Set_free_str(mMsg_Get_base_window_p(), 2, Save_Get(homes[haniwa->house_idx]).ownerID.player_name, - PLAYER_NAME_LEN); + mMsg_SET_FREE_STR(mMsg_FREE_STR2, name_p, PLAYER_NAME_LEN); } -static void aHNW_pl_approach_door_init(ACTOR* actor, GAME* game) { - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; - +static void aHNW_pl_approach_door_init(HANIWA_ACTOR* haniwa, GAME* game) { game->pad_initialized = FALSE; haniwa->player_approach_door_stage = -1; haniwa->door_approach_frame = 0; } -typedef void (*HANIWA_PROC)(ACTOR*, GAME*); +typedef void (*HANIWA_PROC)(HANIWA_ACTOR*, GAME*); -static void aHNW_init_proc(ACTOR* actor, GAME* game, int action) { +static void aHNW_init_proc(HANIWA_ACTOR* actor, GAME* game, int action) { + // clang-format off static HANIWA_PROC init_proc[aHNW_ACTION_NUM] = { - (HANIWA_PROC)&none_proc1, (HANIWA_PROC)&none_proc1, (HANIWA_PROC)&none_proc1, (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1, (HANIWA_PROC)&none_proc1, &aHNW_menu_open_wait_init, &aHNW_menu_end_wait_init, - &aHNW_talk_with_guest_init, &aHNW_menu_open_wait_init, &aHNW_menu_end_wait_init, (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1, (HANIWA_PROC)&none_proc1, &aHNW_pl_approach_door_init, (HANIWA_PROC)&none_proc1, - (HANIWA_PROC)&none_proc1 + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + &aHNW_menu_open_wait_init, + &aHNW_menu_end_wait_init, + &aHNW_talk_with_guest_init, + &aHNW_menu_open_wait_init, + &aHNW_menu_end_wait_init, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, + &aHNW_pl_approach_door_init, + (HANIWA_PROC)&none_proc1, + (HANIWA_PROC)&none_proc1, }; + // clang-format on (*init_proc[action])(actor, game); } -static void aHNW_setupAction(ACTOR* actor, GAME* game, int action) { - static HANIWA_PROC process[aHNW_ACTION_NUM] = { &aHNW_wait, - &aHNW_dance, - &aHNW_check_proceeds, - &aHNW_talk_with_master, - &aHNW_talk_with_master2, - &aHNW_talk_end_wait, - &aHNW_menu_open_wait, - &aHNW_menu_end_wait, - &aHNW_talk_with_guest, - &aHNW_menu_open_wait_for_guest, - &aHNW_menu_end_wait_for_guest, - &aHNW_roof_check, - &aHNW_save_check, - &aHNW_save_end_wait, - &aHNW_pl_approach_door, - &aHNW_door_open_wait, - &aHNW_door_open_timer }; - - HANIWA_ACTOR* haniwa = (HANIWA_ACTOR*)actor; +static void aHNW_setupAction(HANIWA_ACTOR* haniwa, GAME* game, int action) { + static HANIWA_PROC process[aHNW_ACTION_NUM] = { + &aHNW_wait, + &aHNW_dance, + &aHNW_check_proceeds, + &aHNW_talk_with_master, + &aHNW_talk_with_master2, + &aHNW_talk_end_wait, + &aHNW_menu_open_wait, + &aHNW_menu_end_wait, + &aHNW_talk_with_guest, + &aHNW_menu_open_wait_for_guest, + &aHNW_menu_end_wait_for_guest, + &aHNW_roof_check, + &aHNW_save_check, + &aHNW_save_end_wait, + &aHNW_pl_approach_door, + &aHNW_door_open_wait, + &aHNW_door_open_timer, + }; int house_idx = haniwa->house_idx; int animation_state = haniwa->common_actor_class.anime.anime_no; @@ -682,7 +706,7 @@ static void aHNW_setupAction(ACTOR* actor, GAME* game, int action) { } haniwa->common_actor_class.anime.anime_no = 0; - aHNW_init_proc(actor, game, action); + aHNW_init_proc(haniwa, game, action); if (no_owner && action < aHNW_ACTION_CHECK_PROCEEDS) { haniwa->common_actor_class.anime.keyframe.frame_control.mode = cKF_FRAMECONTROL_STOP; } else { @@ -698,7 +722,7 @@ static void aHNW_common_process(ACTOR* actor, GAME* game) { f32 target; if (no_owner == FALSE && keyframe->frame_control.mode == cKF_FRAMECONTROL_STOP) { - aHNW_setupAction((ACTOR*)haniwa, game, haniwa->common_actor_class.act); + aHNW_setupAction(haniwa, game, haniwa->common_actor_class.act); keyframe->frame_control.mode = cKF_FRAMECONTROL_REPEAT; } else if (no_owner && haniwa->common_actor_class.act < 2 && keyframe->frame_control.speed <= 0.1f) { keyframe->frame_control.mode = cKF_FRAMECONTROL_STOP; @@ -707,9 +731,9 @@ static void aHNW_common_process(ACTOR* actor, GAME* game) { } if (no_owner == FALSE || haniwa->common_actor_class.act >= aHNW_ACTION_CHECK_PROCEEDS) { - aHNW_search_player((ACTOR*)haniwa); + aHNW_search_player(haniwa); } else { - aHNW_search_front((ACTOR*)haniwa, house_idx); + aHNW_search_front(haniwa, house_idx); } target = haniwa->anim_frame_speed; @@ -729,7 +753,7 @@ static void aHNW_actor_move(ACTOR* actor, GAME* game) { cKF_SkeletonInfo_R_c* keyframe = &haniwa->common_actor_class.anime.keyframe; haniwa->common_actor_class.anime.state = cKF_SkeletonInfo_R_play(keyframe); - (*haniwa->action_proc)((ACTOR*)haniwa, game); + (*haniwa->action_proc)(haniwa, game); aHNW_common_process(actor, game); CollisionCheck_Uty_ActorWorldPosSetPipeC(actor, &haniwa->common_actor_class.col_pipe); CollisionCheck_setOC(game, &play->collision_check, &haniwa->common_actor_class.col_pipe.collision_obj); @@ -743,8 +767,7 @@ static void aHNW_actor_init(ACTOR* actor, GAME* game) { mFI_SetFG_common((mActor_name_t)(house_idx + DUMMY_HANIWA0), actor->world.position, FALSE); actor->mv_proc = &aHNW_actor_move; actor->dw_proc = &aHNW_actor_draw; - aHNW_setupAction((ACTOR*)haniwa, game, - aHNW_ACTION_WAIT); // weird that we have to re-cast to ACTOR so fequently for matches + aHNW_setupAction(haniwa, game, aHNW_ACTION_WAIT); haniwa->common_actor_class.anime.keyframe.morph_counter = 0.0f; aHNW_actor_move(actor, game); }