From ad47fd3eb383679d9b502323cd8cbdc3434c10ba Mon Sep 17 00:00:00 2001 From: lepelog <25211966+lepelog@users.noreply.github.com> Date: Fri, 5 Dec 2025 10:49:39 +0100 Subject: [PATCH] review --- config/SOUE01/rels/d_t_insectNP/symbols.txt | 2 +- include/d/a/d_a_insect_butterfly.h | 4 +-- include/d/t/d_t_insect.h | 26 ++++++++------ src/REL/d/t/d_t_insect.cpp | 39 +++++++++++---------- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/config/SOUE01/rels/d_t_insectNP/symbols.txt b/config/SOUE01/rels/d_t_insectNP/symbols.txt index 72b3b42e..9c315382 100644 --- a/config/SOUE01/rels/d_t_insectNP/symbols.txt +++ b/config/SOUE01/rels/d_t_insectNP/symbols.txt @@ -33,7 +33,7 @@ finalizeState_End__11dTgInsect_cFv = .text:0x000012D0; // type:function size:0x4 spawnAll__11dTgInsect_cFv = .text:0x000012E0; // type:function size:0x64 spawnInsect__11dTgInsect_cFl = .text:0x00001350; // type:function size:0x530 shouldSpawn__11dTgInsect_cFv = .text:0x00001880; // type:function size:0x140 -someGroundCheck__11dTgInsect_cFRC7mVec3_cl = .text:0x000019C0; // type:function size:0x1E0 +checkValidSpawnLocation__11dTgInsect_cFRC7mVec3_cb = .text:0x000019C0; // type:function size:0x1E0 __dt__11dTgInsect_cFv = .text:0x00001BA0; // type:function size:0xF0 getStateID__80sStateMgr_c<11dTgInsect_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>CFv = .text:0x00001C90; // type:function size:0x10 build__27sFStateFct_c<11dTgInsect_c>FRC12sStateIDIf_c = .text:0x00001CA0; // type:function size:0x60 diff --git a/include/d/a/d_a_insect_butterfly.h b/include/d/a/d_a_insect_butterfly.h index 91688269..14ccfd5d 100644 --- a/include/d/a/d_a_insect_butterfly.h +++ b/include/d/a/d_a_insect_butterfly.h @@ -18,13 +18,13 @@ public: STATE_FUNC_DECLARE(dAcInsectButterfly_c, Dead); void setKillSignal() { - killSignal = 1; + mKillSignal = 1; } private: /* 0x468 */ u8 field_0x468[0xA34-0x468]; /* 0xA34 */ STATE_MGR_DECLARE(dAcInsectButterfly_c); /* 0xA70 */ u8 field_0xA70[0xAC6-0xA70]; - /* 0xAC6 */ u8 killSignal; + /* 0xAC6 */ u8 mKillSignal; }; #endif diff --git a/include/d/t/d_t_insect.h b/include/d/t/d_t_insect.h index 874d5099..36ef7e62 100644 --- a/include/d/t/d_t_insect.h +++ b/include/d/t/d_t_insect.h @@ -12,7 +12,10 @@ extern "C" bool fn_801BB750(nw4r::math::AABB *aabb, f32 f); class dTgInsect_c : public dTg_c { public: enum Subtype { - SUBTYPE_VOLCANIC_LADYBUG = 3, + SUBTYPE_INVALID0, + SUBTYPE_INVALID1, + SUBTYPE_INVALID2, + SUBTYPE_VOLCANIC_LADYBUG, SUBTYPE_GERUDO_DRAGONFLY, SUBTYPE_WOODLAND_RHINO_BEETLE, SUBTYPE_SAND_CICADA, @@ -35,6 +38,12 @@ public: dTgInsect_c() : mStateMgr(*this, sStateID::null) {} virtual ~dTgInsect_c() {} + virtual int doDelete() override; + virtual int draw() override; + virtual int actorCreate() override; + virtual int actorPostCreate() override; + virtual int actorExecute() override; + void setKillSignal() { mKillSignal = 1; } @@ -50,13 +59,13 @@ public: private: /* 0x0FC */ STATE_MGR_DECLARE(dTgInsect_c); /* 0x138 */ dAcRef_c mLinks[16]; - /* 0x1F8 */ u8 unk1F8[16]; - /* 0x208 */ s32 mInsectRespanwTimers[16]; + /* 0x1F8 */ u8 field_0x1f8[16]; + /* 0x208 */ s32 mInsectRespawnTimers[16]; /* 0x248 */ s32 mInsectCount; /* 0x24C */ u8 mRevealed; // used by OBJ_SOIL and OBJ_VSD to signal that the insect should be spawned now /* 0x24D */ u8 mKillSignal; // used by goddess walls to signal that the insects should despawn - /* 0x24E */ u8 unk24E; - /* 0x24F */ u8 unk24F; + /* 0x24E */ u8 field_0x24e; + /* 0x24F */ u8 field_0x24f; /* 0x250 */ u8 mShouldSpawn[16]; /* 0x260 */ mVec3_c mRevealedSpawnPos; /* 0x26C */ dAcRef_c mWarpRef; @@ -79,7 +88,7 @@ private: void spawnInsect(s32 index); bool shouldSpawn(); void spawnAll(); - bool someGroundCheck(const mVec3_c &pos, s32 param_3); + bool checkValidSpawnLocation(const mVec3_c &pos, bool updateRotation); bool isTrialGateType() const { return getSubtype() != SUBTYPE_BUTTERFLY ? false : getSpawnSubtype() == SPAWN_TRIAL_GATE; } @@ -89,11 +98,6 @@ private: bool isGoddessWallType() const { return getSubtype() != SUBTYPE_BUTTERFLY ? false : getSpawnSubtype() == SPAWN_GODDESS_WALL; } - int doDelete() override; - int draw() override; - int actorCreate() override; - int actorPostCreate() override; - int actorExecute() override; }; #endif diff --git a/src/REL/d/t/d_t_insect.cpp b/src/REL/d/t/d_t_insect.cpp index 19fd7333..125387f8 100644 --- a/src/REL/d/t/d_t_insect.cpp +++ b/src/REL/d/t/d_t_insect.cpp @@ -46,13 +46,13 @@ const s32 *useUnused() { } int dTgInsect_c::actorCreate() { - if (getSubtype() == 0) { + if (getSubtype() == SUBTYPE_INVALID0) { return FAILED; } - if (getSubtype() == 1) { + if (getSubtype() == SUBTYPE_INVALID1) { return FAILED; } - if (getSubtype() == 2) { + if (getSubtype() == SUBTYPE_INVALID2) { return FAILED; } mInsectCount = getInsectCount(); @@ -67,7 +67,7 @@ int dTgInsect_c::actorCreate() { mRevealed = 0; mRevealedSpawnPos = mPosition; if (isTrialGateType() || isGossipStoneType() || isGoddessWallType() || isSpawnSubtype(SPAWN_BUG_MINIGAME)) { - unk24E = 1; + field_0x24e = 1; } return SUCCEEDED; } @@ -84,7 +84,7 @@ int dTgInsect_c::actorPostCreate() { || subtype == SUBTYPE_SAND_CICADA || subtype == SUBTYPE_VOLCANIC_LADYBUG || subtype == SUBTYPE_SKY_STAG_BEETLE) { - if (!someGroundCheck(mPosition, 1)) { + if (!checkValidSpawnLocation(mPosition, 1)) { return FAILED; } } @@ -102,7 +102,10 @@ int dTgInsect_c::actorPostCreate() { checkProfile(prof, fProfile::OBJ_SOIL) ) && getSquareDistanceTo(obj->mPosition) < 25) { - if (subtype == 7 || subtype == 0xB || subtype == 8 || subtype == 0xC) { + if (subtype == SUBTYPE_FARON_GRASSHOPPER + || subtype == SUBTYPE_SKYLOFT_MANTIS + || subtype == SUBTYPE_LANAYRU_ANT + || subtype == SUBTYPE_EDLIN_ROLLER) { if (prof == fProfile::OBJ_SOIL && static_cast(obj)->isStateHole()) { return FAILED; } @@ -115,8 +118,8 @@ int dTgInsect_c::actorPostCreate() { mStateMgr.changeState(StateID_WaitCreate); } else { if (isSpawnSubtype(SPAWN_BUG_MINIGAME)) { - for (s32 i = 0; i < 16; i++) { - unk1F8[i] = 0; + for (s32 i = 0; i < (s32)ARRAY_LENGTH(field_0x1f8); i++) { + field_0x1f8[i] = 0; } mStateMgr.changeState(StateID_Wait); } else if (isTrialGateType()) { @@ -180,9 +183,9 @@ void dTgInsect_c::executeState_Wait() { s32 i = 0; for (; i < mInsectCount; i++) { if (!mLinks[i].isLinked()) { - if (mInsectRespanwTimers[i] > 0) { - mInsectRespanwTimers[i]--; - } else if (mInsectRespanwTimers[i] == 0) { + if (mInsectRespawnTimers[i] > 0) { + mInsectRespawnTimers[i]--; + } else if (mInsectRespawnTimers[i] == 0) { nw4r::math::MTX34 mtx; PSMTXTrans(mtx, mPosition.x, mPosition.y, mPosition.z); nw4r::math::MTX34 scale; @@ -194,7 +197,7 @@ void dTgInsect_c::executeState_Wait() { spawnInsect(i); } } else { - mInsectRespanwTimers[i] = 900; + mInsectRespawnTimers[i] = 900; } } } @@ -204,7 +207,7 @@ void dTgInsect_c::executeState_Wait() { void dTgInsect_c::finalizeState_Wait() {} void dTgInsect_c::initializeState_WaitCreate() { if (!isSpawnSubtype(SPAWN_BUG_MINIGAME)) { - unk24F = 1; + field_0x24f = 1; for (s32 i = 0; i < mInsectCount; i++) { mShouldSpawn[i] = shouldSpawn(); } @@ -259,7 +262,7 @@ void dTgInsect_c::executeState_WaitCreate() { } if (insect != nullptr) { mLinks[i].link(insect); - mInsectRespanwTimers[i] = -1; + mInsectRespawnTimers[i] = -1; } } if (isSpawnSubtype(SPAWN_BUG_MINIGAME)) { @@ -363,7 +366,7 @@ void dTgInsect_c::spawnInsect(s32 index) { f32 scaledScale = SCALE_Y * mScale.y; pos.y = mPosition.y + scaledScale * 0.3f; pos.y += cM::rndF(scaledScale * 0.5f); - if (!someGroundCheck(pos, 0)) { + if (!checkValidSpawnLocation(pos, 0)) { return; } } else { @@ -429,7 +432,7 @@ void dTgInsect_c::spawnInsect(s32 index) { } if (ref != nullptr) { mLinks[index].link(ref); - mInsectRespanwTimers[index] = -1; + mInsectRespawnTimers[index] = -1; } return; } @@ -456,7 +459,7 @@ bool dTgInsect_c::shouldSpawn() { } } -bool dTgInsect_c::someGroundCheck(const mVec3_c &pos, s32 updateRotation) { +bool dTgInsect_c::checkValidSpawnLocation(const mVec3_c &pos, bool updateRotation) { mVec3_c tmp = mVec3_c::Ez * (SCALE_X * mScale.x); tmp.rotY(mRotation.y); tmp += pos; @@ -466,7 +469,7 @@ bool dTgInsect_c::someGroundCheck(const mVec3_c &pos, s32 updateRotation) { linChk.Set(&pos, &tmp, nullptr); if (!dBgS::GetInstance()->LineCross(&linChk)) { mAng yRot = mRotation.y + 0x7FFF; - if (updateRotation != 0) { + if (updateRotation) { mRotation.y = yRot; } tmp = mVec3_c::Ez * (SCALE_X * mScale.x);