diff --git a/configure.py b/configure.py index a8949d03c18..5c97518748a 100755 --- a/configure.py +++ b/configure.py @@ -1714,7 +1714,7 @@ config.libs = [ ActorRel(MatchingFor(ALL_GCN), "d_a_tag_evtarea"), ActorRel(MatchingFor(ALL_GCN), "d_a_tag_evtmsg"), ActorRel(MatchingFor(ALL_GCN), "d_a_tag_howl"), - ActorRel(NonMatching, "d_a_tag_kmsg"), + ActorRel(MatchingFor(ALL_GCN), "d_a_tag_kmsg"), ActorRel(MatchingFor(ALL_GCN), "d_a_tag_lantern"), ActorRel(MatchingFor(ALL_GCN), "d_a_tag_mist"), ActorRel(MatchingFor(ALL_GCN), "d_a_tag_msg"), diff --git a/include/d/actor/d_a_tag_kmsg.h b/include/d/actor/d_a_tag_kmsg.h index 7b75e3d43cb..7fe9c21a923 100644 --- a/include/d/actor/d_a_tag_kmsg.h +++ b/include/d/actor/d_a_tag_kmsg.h @@ -59,50 +59,46 @@ public: u32 getFlowNodeNo() { u16 rv = home.angle.z; - if (rv == 0xffff) { - return -1; - } - return rv; + return rv == 0xFFFF ? -1 : rv; } u8 getBitSW() { - return home.angle.x; + u16 r31 = home.angle.x; + return (u16)(r31 & 0xFF); } u32 getTalkAngle() { - u32 talkAngle = (fopAcM_GetParam(this) >> 5) & 0x7; - if (talkAngle == 7) { - return 0; - } else { - return talkAngle > 6 ? 6 : talkAngle; - } + u32 talkAngle = (fopAcM_GetParam(this) & 0xE0) >> 5; + return talkAngle == 7 ? 0 : + talkAngle > 6 ? 6 : + talkAngle; } u32 getTalkDis() { - u32 talkDis = fopAcM_GetParam(this) & 0x1f; - if (talkDis == 0x1f) { - return 0; - } else { - return talkDis > 0x13 ? 0x13 : talkDis; - } + u32 talkDis = fopAcM_GetParam(this) & 0x1F; + return talkDis == 0x1F ? 0 : + talkDis > 0x13 ? 0x13 : + talkDis; } f32 getAttnPosOffset() { u32 attnPosOffset = (fopAcM_GetParam(this) & 0xff0000) >> 0x10; - if (attnPosOffset == 0xff) { + if (attnPosOffset == 0xFF) { return G_CM3D_F_INF; - } else { - return attnPosOffset; } + f32 f31 = attnPosOffset; + return f31; } - u32 getChkType() { - return home.angle.x & 0x8000; + u8 getChkType() { + u16 r31 = home.angle.x; + return (bool)(r31 & 0x8000); } f32 getEyePosOffset() { u32 eyeOffset = (fopAcM_GetParam(this) & 0xff00) >> 8; - return (eyeOffset == 0xff) ? 0 : eyeOffset; + f32 f31 = eyeOffset == 0xFF ? 0 : eyeOffset; + return f31; } }; diff --git a/src/d/actor/d_a_tag_kmsg.cpp b/src/d/actor/d_a_tag_kmsg.cpp index f1b81cd1d4f..2737dc370f8 100644 --- a/src/d/actor/d_a_tag_kmsg.cpp +++ b/src/d/actor/d_a_tag_kmsg.cpp @@ -24,12 +24,14 @@ static char* l_resNameList[3] = { }; int daTag_KMsg_c::create() { - attention_info.position = current.pos; - eyePos = attention_info.position; + int r27 = 0; + + eyePos = attention_info.position = current.pos; + fopAcM_ct(this, daTag_KMsg_c); - int rv; + if (getType() == KMSG_TYPE_3) { - rv = dComIfG_resLoad(&mPhase, "Lv6Gate"); + int rv = dComIfG_resLoad(&mPhase, "Lv6Gate"); if (rv != cPhs_COMPLEATE_e) { return rv; } @@ -40,6 +42,22 @@ int daTag_KMsg_c::create() { mFlowNodeNo = getFlowNodeNo(); mEventIdx = -1; + OS_REPORT( + "\t(%s:%d) flowNo:%d, BitSW:%02x, dis:%d, angle:%d, eye:%f, attn:%f, scale:%f,%f,%f<%08x>(%d/%04x)\n", + fopAcM_getProcNameString(this), + getType(), + getFlowNodeNo(), + getBitSW(), + getTalkDis(), + getTalkAngle(), + getEyePosOffset(), + getAttnPosOffset(), + scale.x, scale.y, scale.z, + fopAcM_GetParam(this), + getChkType(), + home.angle.x + ); + if (isDelete()) { return cPhs_ERROR_e; } else { @@ -49,12 +67,11 @@ int daTag_KMsg_c::create() { int daTag_KMsg_c::Delete() { OS_REPORT("|%06d:%x|daTag_KMsg_c -> Delete\n", g_Counter.mCounter0, this); - fopAcM_GetID(this); + fopAcM_RegisterDeleteID(this, "TAG_KMSG"); this->~daTag_KMsg_c(); return 1; } -// NONMATCHING Various issues: stack, getTalkAngle int daTag_KMsg_c::Execute() { bool var_r28 = false; if (home.roomNo == dComIfGp_roomControl_getStayNo()) { @@ -70,11 +87,7 @@ int daTag_KMsg_c::Execute() { attention_info.flags = 0; } } else { -#if VERSION == VERSION_SHIELD_DEBUG attention_info.distances[fopAc_attn_TALK_e] = daNpcT_getDistTableIdx(getTalkDis(), getTalkAngle()); -#else - attention_info.distances[fopAc_attn_TALK_e] = daNpcT_getDistTableIdx(getTalkAngle(), getTalkDis()); -#endif attention_info.distances[fopAc_attn_SPEAK_e] = attention_info.distances[fopAc_attn_TALK_e]; if (getAttnPosOffset() != G_CM3D_F_INF) { attention_info.flags = fopAc_AttnFlag_SPEAK_e | fopAc_AttnFlag_TALK_e; @@ -88,7 +101,9 @@ int daTag_KMsg_c::Execute() { attention_info.flags = 0; } - if (dComIfGp_event_runCheck()) { + // TODO: gameInfo fake match to force reuse of pointer + dComIfG_play_c* play = &g_dComIfG_gameInfo.play; + if (play->getEvent().runCheck()) { if (eventInfo.checkCommandTalk()) { u16 iVar10 = 0; switch (getType()) { @@ -104,7 +119,7 @@ int daTag_KMsg_c::Execute() { } mEventIdx = dComIfGp_getEventManager().getEventIdx(this, l_evtList[iVar10].mEventName, 0xff); - dComIfGp_getEvent().reset(this); + play->getEvent().reset(this); fopAcM_orderChangeEventId(this, mEventIdx, 1, 0xffff); } @@ -146,7 +161,7 @@ int daTag_KMsg_c::Execute() { } else { eventInfo.onCondition(1); if (getType() != KMSG_TYPE_1 && daNpcT_chkDoBtnIsSpeak(this)) { - if (getChkType() != KMSG_TYPE_0) { + if (getChkType()) { dComIfGp_setDoStatusForce(0x80, 2); } else { dComIfGp_setDoStatus(8, 0); @@ -193,9 +208,7 @@ int daTag_KMsg_c::Execute() { lin_chk.OnFrontFlag(); lin_chk.Set(&vec54, &vec60, NULL); if (dComIfG_Bgsp().LineCross(&lin_chk)) { - cXyz vec48; - cXyz vec30 = vec54 - vec60; - vec48 = lin_chk.GetCross() + vec30.norm() * 10.0f; + cXyz vec48 = lin_chk.GetCross() + cXyz(vec54 - vec60).norm() * 10.0f; attention_info.position.x = vec48.x; attention_info.position.z = vec48.z; } @@ -220,11 +233,7 @@ int daTag_KMsg_c::isDelete() { case KMSG_TYPE_2: return 0; case KMSG_TYPE_3: - bool rv = false; - if (getBitSW() != 0xff && dComIfGs_isSwitch(getBitSW(), fopAcM_GetRoomNo(this))) { - rv = true; - } - return rv; + return getBitSW() != 0xff && dComIfGs_isSwitch(getBitSW(), fopAcM_GetRoomNo(this)); case KMSG_TYPE_4: return 0; case KMSG_TYPE_5: