From b9b40805f7f63d0a6cb3c33e55ac420710acef70 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Mon, 4 Apr 2022 00:33:50 +0200 Subject: [PATCH] Fix misc 9 (#1183) * Fix typo `tranform` -> `transform` * (may be controversial) `indexes` (noun) -> `indices`, both are correct but `indices` prevails in the repo currently, and seems prefered in technical contexts * Fixup one `@bug` * Fix typo `relfect` -> `reflect` * Rename and `@bug` `DemoTreLgt_OverrideLimbDraw` * Fixup `PLAYER_AP_` to `ARROW_` type conversion * `posModel` -> `modelPos` * `effSpawnPosModel` -> `effSpawnModelPos` * Gohma decay bug: Verified that timers do not prevent UB access * Reorder summation in a more meaningful way Co-authored-by: JoshDuMan <40190173+JoshDuMan@users.noreply.github.com> --- include/z64.h | 2 +- src/code/z_parameter.c | 6 ++--- src/code/z_player_lib.c | 6 ++--- src/code/z_skin_awb.c | 2 +- .../actors/ovl_Arrow_Fire/z_arrow_fire.c | 12 +++++----- .../actors/ovl_Arrow_Ice/z_arrow_ice.c | 12 +++++----- .../actors/ovl_Arrow_Light/z_arrow_light.c | 12 +++++----- .../ovl_Bg_Mizu_Water/z_bg_mizu_water.c | 4 ++-- .../actors/ovl_Boss_Goma/z_boss_goma.c | 8 +++---- src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c | 24 +++++++++---------- .../actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c | 9 +++++-- .../actors/ovl_En_Bom_Chu/z_en_bom_chu.c | 18 +++++++------- .../actors/ovl_En_Bubble/z_en_bubble.c | 6 ++--- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 4 ++-- src/overlays/actors/ovl_En_Mag/z_en_mag.c | 20 ++++++++-------- src/overlays/actors/ovl_En_Mb/z_en_mb.c | 4 ++-- src/overlays/actors/ovl_En_Ossan/z_en_ossan.c | 4 ++-- .../ovl_Item_Etcetera/z_item_etcetera.c | 6 ++--- .../actors/ovl_player_actor/z_player.c | 2 +- 19 files changed, 83 insertions(+), 78 deletions(-) diff --git a/include/z64.h b/include/z64.h index 658ca1476a..ae1d62d461 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1403,7 +1403,7 @@ typedef enum { /* 16 */ F_B8 } FloorID; -// All arrays pointed in this struct are indexed by "map indexes" +// All arrays pointed in this struct are indexed by "map indices" // In dungeons, the map index corresponds to the dungeon index (which also indexes keys, items, etc) // In overworld areas, the map index corresponds to the overworld area index (spot 00, 01, etc) typedef struct { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index c4f70d8818..18d77312a1 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -2345,7 +2345,7 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { { 255, 255, 150 }, { 255, 255, 50 }, }; - static s16 sMagicBorderIndexes[] = { 0, 1, 1, 0 }; + static s16 sMagicBorderIndices[] = { 0, 1, 1, 0 }; static s16 sMagicBorderRatio = 2; static s16 sMagicBorderStep = 1; MessageContext* msgCtx = &globalCtx->msgCtx; @@ -2410,7 +2410,7 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { case 3: case 4: case 6: - temp = sMagicBorderIndexes[sMagicBorderStep]; + temp = sMagicBorderIndices[sMagicBorderStep]; borderChangeR = ABS(sMagicBorderR - sMagicBorderColors[temp][0]) / sMagicBorderRatio; borderChangeG = ABS(sMagicBorderG - sMagicBorderColors[temp][1]) / sMagicBorderRatio; borderChangeB = ABS(sMagicBorderB - sMagicBorderColors[temp][2]) / sMagicBorderRatio; @@ -2475,7 +2475,7 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { } } - temp = sMagicBorderIndexes[sMagicBorderStep]; + temp = sMagicBorderIndices[sMagicBorderStep]; borderChangeR = ABS(sMagicBorderR - sMagicBorderColors[temp][0]) / sMagicBorderRatio; borderChangeG = ABS(sMagicBorderG - sMagicBorderColors[temp][1]) / sMagicBorderRatio; borderChangeB = ABS(sMagicBorderB - sMagicBorderColors[temp][2]) / sMagicBorderRatio; diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 1b75efbedf..2c7b07c6a2 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -804,7 +804,7 @@ s32 func_8008F2F8(GlobalContext* globalCtx) { return var + 1; } -u8 sEyeMouthIndexes[][2] = { +u8 sEyeMouthIndices[][2] = { { 0, 0 }, { 1, 0 }, { 2, 0 }, { 0, 0 }, { 1, 0 }, { 2, 0 }, { 4, 0 }, { 5, 1 }, { 7, 2 }, { 0, 2 }, { 3, 0 }, { 4, 0 }, { 2, 2 }, { 1, 1 }, { 0, 2 }, { 0, 0 }, }; @@ -868,7 +868,7 @@ void Player_DrawImpl(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTabl OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 1721); if (eyeIndex < 0) { - eyeIndex = sEyeMouthIndexes[face][0]; + eyeIndex = sEyeMouthIndices[face][0]; } #ifndef AVOID_UB @@ -878,7 +878,7 @@ void Player_DrawImpl(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTabl #endif if (mouthIndex < 0) { - mouthIndex = sEyeMouthIndexes[face][1]; + mouthIndex = sEyeMouthIndices[face][1]; } #ifndef AVOID_UB diff --git a/src/code/z_skin_awb.c b/src/code/z_skin_awb.c index c531d74a11..13ceafa91d 100644 --- a/src/code/z_skin_awb.c +++ b/src/code/z_skin_awb.c @@ -141,7 +141,7 @@ s32 func_800A698C(Skin* skin, SkinLimb** skeleton, MtxF* limbMatrices, u8 parent } /** - * Recursively applies matrix tranformations to each limb + * Recursively applies matrix transformations to each limb */ s32 Skin_ApplyAnimTransformations(Skin* skin, MtxF* limbMatrices, Actor* actor, s32 setTranslation) { s32 i; diff --git a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index 003d58b546..b519b13cb1 100644 --- a/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -193,7 +193,7 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { GlobalContext* globalCtx = globalCtx2; u32 stateFrames; EnArrow* arrow; - Actor* tranform; + Actor* transform; stateFrames = globalCtx->state.frames; arrow = (EnArrow*)this->actor.parent; @@ -201,14 +201,14 @@ void ArrowFire_Draw(Actor* thisx, GlobalContext* globalCtx2) { if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { if (1) {} - tranform = (arrow->hitFlags & 2) ? &this->actor : &arrow->actor; + transform = (arrow->hitFlags & 2) ? &this->actor : &arrow->actor; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_arrow_fire.c", 618); - Matrix_Translate(tranform->world.pos.x, tranform->world.pos.y, tranform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_TO_RAD(tranform->shape.rot.y), MTXMODE_APPLY); - Matrix_RotateX(BINANG_TO_RAD(tranform->shape.rot.x), MTXMODE_APPLY); - Matrix_RotateZ(BINANG_TO_RAD(tranform->shape.rot.z), MTXMODE_APPLY); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateY(BINANG_TO_RAD(transform->shape.rot.y), MTXMODE_APPLY); + Matrix_RotateX(BINANG_TO_RAD(transform->shape.rot.x), MTXMODE_APPLY); + Matrix_RotateZ(BINANG_TO_RAD(transform->shape.rot.z), MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); // Draw red effect over the screen when arrow hits diff --git a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 6a0209ded8..bc728b0e0f 100644 --- a/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -192,7 +192,7 @@ void ArrowIce_Update(Actor* thisx, GlobalContext* globalCtx) { void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { ArrowIce* this = (ArrowIce*)thisx; s32 pad; - Actor* tranform; + Actor* transform; u32 stateFrames = globalCtx->state.frames; EnArrow* arrow = (EnArrow*)this->actor.parent; @@ -200,14 +200,14 @@ void ArrowIce_Draw(Actor* thisx, GlobalContext* globalCtx) { if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { if (1) {} - tranform = (arrow->hitFlags & 2) ? &this->actor : &arrow->actor; + transform = (arrow->hitFlags & 2) ? &this->actor : &arrow->actor; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_arrow_ice.c", 610); - Matrix_Translate(tranform->world.pos.x, tranform->world.pos.y, tranform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_TO_RAD(tranform->shape.rot.y), MTXMODE_APPLY); - Matrix_RotateX(BINANG_TO_RAD(tranform->shape.rot.x), MTXMODE_APPLY); - Matrix_RotateZ(BINANG_TO_RAD(tranform->shape.rot.z), MTXMODE_APPLY); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateY(BINANG_TO_RAD(transform->shape.rot.y), MTXMODE_APPLY); + Matrix_RotateX(BINANG_TO_RAD(transform->shape.rot.x), MTXMODE_APPLY); + Matrix_RotateZ(BINANG_TO_RAD(transform->shape.rot.z), MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); // Draw blue effect over the screen when arrow hits diff --git a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index d6645e1960..f8a743e893 100644 --- a/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -192,20 +192,20 @@ void ArrowLight_Draw(Actor* thisx, GlobalContext* globalCtx) { s32 pad; u32 stateFrames = globalCtx->state.frames; EnArrow* arrow = (EnArrow*)this->actor.parent; - Actor* tranform; + Actor* transform; if (1) {} if ((arrow != NULL) && (arrow->actor.update != NULL) && (this->timer < 255)) { if (1) {} - tranform = (arrow->hitFlags & 2) ? &this->actor : &arrow->actor; + transform = (arrow->hitFlags & 2) ? &this->actor : &arrow->actor; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_arrow_light.c", 598); - Matrix_Translate(tranform->world.pos.x, tranform->world.pos.y, tranform->world.pos.z, MTXMODE_NEW); - Matrix_RotateY(BINANG_TO_RAD(tranform->shape.rot.y), MTXMODE_APPLY); - Matrix_RotateX(BINANG_TO_RAD(tranform->shape.rot.x), MTXMODE_APPLY); - Matrix_RotateZ(BINANG_TO_RAD(tranform->shape.rot.z), MTXMODE_APPLY); + Matrix_Translate(transform->world.pos.x, transform->world.pos.y, transform->world.pos.z, MTXMODE_NEW); + Matrix_RotateY(BINANG_TO_RAD(transform->shape.rot.y), MTXMODE_APPLY); + Matrix_RotateX(BINANG_TO_RAD(transform->shape.rot.x), MTXMODE_APPLY); + Matrix_RotateZ(BINANG_TO_RAD(transform->shape.rot.z), MTXMODE_APPLY); Matrix_Scale(0.01f, 0.01f, 0.01f, MTXMODE_APPLY); // Draw yellow effect over the screen when arrow hits diff --git a/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c b/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c index 0847b78df9..86fc609877 100644 --- a/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c +++ b/src/overlays/actors/ovl_Bg_Mizu_Water/z_bg_mizu_water.c @@ -44,7 +44,7 @@ const ActorInit Bg_Mizu_Water_InitVars = { static f32 sUnused1 = 0; static f32 sUnused2 = 110.0f; -static u32 sWaterBoxIndexes[] = { 2, 3, 5, 7, 12, 20, 21, 22 }; +static u32 sWaterBoxIndices[] = { 2, 3, 5, 7, 12, 20, 21, 22 }; static InitChainEntry sInitChain[] = { ICHAIN_VEC3F(scale, 1, ICHAIN_STOP), @@ -84,7 +84,7 @@ void BgMizuWater_SetWaterBoxesHeight(WaterBox* waterBoxes, s16 height) { u32 i; for (i = 0; i < 8; i++) { - waterBoxes[sWaterBoxIndexes[i]].ySurface = height; + waterBoxes[sWaterBoxIndices[i]].ySurface = height; } } diff --git a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c index b250f81e26..2ff3f3abff 100644 --- a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c +++ b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c @@ -1026,8 +1026,8 @@ void BossGoma_Defeated(BossGoma* this, GlobalContext* globalCtx) { for (i = 0; i < 4; i++) { //! @bug this 0-indexes into this->defeatedLimbPositions which is initialized with - // this->defeatedLimbPositions[limb], but limb is 1-indexed in skelanime callbacks, this means effects - // should spawn at this->defeatedLimbPositions[0] too, which is uninitialized, so map origin? + //! this->defeatedLimbPositions[limb], but limb is 1-indexed in skelanime callbacks, this means effects + //! should spawn at this->defeatedLimbPositions[0] too, which is uninitialized, so map origin? j = (s16)(Rand_ZeroOne() * (BOSSGOMA_LIMB_MAX - 1)); if (this->defeatedLimbPositions[j].y < 10000.0f) { pos.x = Rand_CenteredFloat(20.0f) + this->defeatedLimbPositions[j].x; @@ -1083,8 +1083,8 @@ void BossGoma_Defeated(BossGoma* this, GlobalContext* globalCtx) { for (i = 0; i < 4; i++) { BossGoma_ClearPixels(sClearPixelTableFirstPass, this->decayingProgress); - //! @bug this allows this->decayingProgress = 0x100 = 256 which is out of bounds when accessing - // sClearPixelTableFirstPass, though timers may prevent this from ever happening? + //! @bug this allows this->decayingProgress = 0x100 = 256 which + //! is out of bounds when accessing sClearPixelTableFirstPass if (this->decayingProgress < 0x100) { this->decayingProgress++; } diff --git a/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c b/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c index 8b132280b4..056e0373a7 100644 --- a/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c +++ b/src/overlays/actors/ovl_Demo_Gj/z_demo_gj.c @@ -251,7 +251,7 @@ void DemoGj_InitCommon(DemoGj* this, GlobalContext* globalCtx, CollisionHeader* } // TODO: find a better name -s32 DemoGj_InitSetIndexes(DemoGj* this, GlobalContext* globalCtx, s32 updateMode, s32 drawConfig, +s32 DemoGj_InitSetIndices(DemoGj* this, GlobalContext* globalCtx, s32 updateMode, s32 drawConfig, CollisionHeader* header) { if (!DemoGj_IsSceneInvalid()) { this->updateMode = updateMode; @@ -565,7 +565,7 @@ void DemoGj_CheckIfTransformedIntoGanon(DemoGj* this) { } void DemoGj_InitRubblePile1(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 1, 2, &gGanonsCastleRubble2Col); + DemoGj_InitSetIndices(this, globalCtx, 1, 2, &gGanonsCastleRubble2Col); } void func_8097A000(DemoGj* this, GlobalContext* globalCtx) { @@ -630,7 +630,7 @@ void DemoGj_DrawRotatedRubble2(DemoGj* this, GlobalContext* globalCtx) { } void DemoGj_InitRubblePile2(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 2, 3, &gGanonsCastleRubble3Col); + DemoGj_InitSetIndices(this, globalCtx, 2, 3, &gGanonsCastleRubble3Col); } void func_8097A238(DemoGj* this, GlobalContext* globalCtx) { @@ -695,7 +695,7 @@ void DemoGj_DrawRotatedRubble3(DemoGj* this, GlobalContext* globalCtx) { } void DemoGj_InitRubblePile3(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 3, 4, &gGanonsCastleRubble4Col); + DemoGj_InitSetIndices(this, globalCtx, 3, 4, &gGanonsCastleRubble4Col); } void func_8097A474(DemoGj* this, GlobalContext* globalCtx) { @@ -743,7 +743,7 @@ void DemoGj_DrawRotatedRubble4(DemoGj* this, GlobalContext* globalCtx) { } void DemoGj_InitRubblePile4(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 4, 5, &gGanonsCastleRubble5Col); + DemoGj_InitSetIndices(this, globalCtx, 4, 5, &gGanonsCastleRubble5Col); } void func_8097A644(DemoGj* this, GlobalContext* globalCtx) { @@ -791,7 +791,7 @@ void DemoGj_DrawRotatedRubble5(DemoGj* this, GlobalContext* globalCtx) { } void DemoGj_InitRubblePile5(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 5, 6, &gGanonsCastleRubble6Col); + DemoGj_InitSetIndices(this, globalCtx, 5, 6, &gGanonsCastleRubble6Col); } void func_8097A814(DemoGj* this, GlobalContext* globalCtx) { @@ -839,7 +839,7 @@ void DemoGj_DrawRotatedRubble6(DemoGj* this, GlobalContext* globalCtx) { } void DemoGj_InitRubblePile6(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 6, 7, &gGanonsCastleRubble7Col); + DemoGj_InitSetIndices(this, globalCtx, 6, 7, &gGanonsCastleRubble7Col); } void func_8097A9E4(DemoGj* this, GlobalContext* globalCtx) { @@ -887,7 +887,7 @@ void DemoGj_DrawRotatedRubble7(DemoGj* this, GlobalContext* globalCtx) { } void DemoGj_InitRubblePile7(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 7, 8, &gGanonsCastleRubbleTallCol); + DemoGj_InitSetIndices(this, globalCtx, 7, 8, &gGanonsCastleRubbleTallCol); } void func_8097ABB4(DemoGj* this, GlobalContext* globalCtx) { @@ -952,7 +952,7 @@ void DemoGj_DrawRotatedRubbleTall(DemoGj* this, GlobalContext* globalCtx) { } void DemoGj_InitRubbleAroundArena(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 0, 1, &gGanonsCastleRubbleAroundArenaCol); + DemoGj_InitSetIndices(this, globalCtx, 0, 1, &gGanonsCastleRubbleAroundArenaCol); } // func_8097ADF0 @@ -969,7 +969,7 @@ void DemoGj_DrawRubbleAroundArena(DemoGj* this, GlobalContext* globalCtx) { // Inits the three cylinders with `sCylinderInit1` void DemoGj_InitDestructableRubble1(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 15, 0, NULL); + DemoGj_InitSetIndices(this, globalCtx, 15, 0, NULL); DemoGj_InitCylinder(this, globalCtx, &this->cylinders[0], &sCylinderInit1); DemoGj_InitCylinder(this, globalCtx, &this->cylinders[1], &sCylinderInit1); DemoGj_InitCylinder(this, globalCtx, &this->cylinders[2], &sCylinderInit1); @@ -1102,7 +1102,7 @@ void DemoGj_DrawDestructableRubble1(DemoGj* this, GlobalContext* globalCtx) { // Inits the three cylinders with `sCylinderInit2` void DemoGj_InitDestructableRubble2(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 16, 0, NULL); + DemoGj_InitSetIndices(this, globalCtx, 16, 0, NULL); DemoGj_InitCylinder(this, globalCtx, &this->cylinders[0], &sCylinderInit2); DemoGj_InitCylinder(this, globalCtx, &this->cylinders[1], &sCylinderInit2); DemoGj_InitCylinder(this, globalCtx, &this->cylinders[2], &sCylinderInit2); @@ -1233,7 +1233,7 @@ void DemoGj_DemoGj_InitDestructableRubble2(DemoGj* this, GlobalContext* globalCt // Inits the first cylinder (only that one) with `sCylinderInit3` void DemoGj_InitDestructableRubbleTall(DemoGj* this, GlobalContext* globalCtx) { - DemoGj_InitSetIndexes(this, globalCtx, 17, 0, NULL); + DemoGj_InitSetIndices(this, globalCtx, 17, 0, NULL); DemoGj_InitCylinder(this, globalCtx, &this->cylinders[0], &sCylinderInit3); } diff --git a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c index cccf95bf1d..df23706c60 100644 --- a/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c +++ b/src/overlays/actors/ovl_Demo_Tre_Lgt/z_demo_tre_lgt.c @@ -131,7 +131,7 @@ void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx) { sActionFuncs[this->action](this, globalCtx); } -s32 DemoTreLgt_PostLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, s32 limbIndex, void* thisx) { +s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, s32 limbIndex, void* thisx) { s32 pad; DemoTreLgt* this = (DemoTreLgt*)thisx; @@ -147,6 +147,11 @@ s32 DemoTreLgt_PostLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, } CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_tre_lgt.c", 448); + + //! @bug missing return + // If the return value ends up being false (0), the limb won't draw (meaning no limb at all will draw). + // In MQ Debug, `Graph_CloseDisps` has the last instruction writing to v0 before this function ends. + // That instruction sets v0 to a non-NULL pointer, which is "true", so the limbs get drawn. } void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx) { @@ -161,7 +166,7 @@ void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx) { func_80093D84(gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 0); - SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, DemoTreLgt_PostLimbDraw, NULL, 1, thisx); + SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, DemoTreLgt_OverrideLimbDraw, NULL, 1, thisx); CLOSE_DISPS(gfxCtx, "../z_demo_tre_lgt.c", 476); } diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index 75ce9f09de..24e42290f5 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -357,17 +357,17 @@ void EnBomChu_WaitForKill(EnBomChu* this, GlobalContext* globalCtx) { /** * Transform coordinates from model space to world space, according to current orientation. - * `posModel` is expected to already be at world scale (1/100 compared to model scale) + * `modelPos` is expected to already be at world scale (1/100 compared to model scale) */ -void EnBomChu_ModelToWorld(EnBomChu* this, Vec3f* posModel, Vec3f* dest) { - f32 x = posModel->x + this->visualJitter; +void EnBomChu_ModelToWorld(EnBomChu* this, Vec3f* modelPos, Vec3f* dest) { + f32 x = modelPos->x + this->visualJitter; - dest->x = this->actor.world.pos.x + (this->axisLeft.x * x) + (this->axisUp.x * posModel->y) + - (this->axisForwards.x * posModel->z); - dest->y = this->actor.world.pos.y + (this->axisLeft.y * x) + (this->axisUp.y * posModel->y) + - (this->axisForwards.y * posModel->z); - dest->z = this->actor.world.pos.z + (this->axisLeft.z * x) + (this->axisUp.z * posModel->y) + - (this->axisForwards.z * posModel->z); + dest->x = this->actor.world.pos.x + (this->axisLeft.x * x) + (this->axisUp.x * modelPos->y) + + (this->axisForwards.x * modelPos->z); + dest->y = this->actor.world.pos.y + (this->axisLeft.y * x) + (this->axisUp.y * modelPos->y) + + (this->axisForwards.y * modelPos->z); + dest->z = this->actor.world.pos.z + (this->axisLeft.z * x) + (this->axisUp.z * modelPos->y) + + (this->axisForwards.z * modelPos->z); } void EnBomChu_SpawnRipples(EnBomChu* this, GlobalContext* globalCtx, f32 y) { diff --git a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c index 1a453a9396..2ac6c3e0e4 100644 --- a/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c +++ b/src/overlays/actors/ovl_En_Bubble/z_en_bubble.c @@ -170,7 +170,7 @@ s32 func_809CC020(EnBubble* this) { return true; } -void EnBubble_Vec3fNormalizedRelfect(Vec3f* vec1, Vec3f* vec2, Vec3f* ret) { +void EnBubble_Vec3fNormalizedReflect(Vec3f* vec1, Vec3f* vec2, Vec3f* ret) { f32 norm; Math3D_Vec3fReflect(vec1, vec2, ret); @@ -237,7 +237,7 @@ void EnBubble_Fly(EnBubble* this, GlobalContext* globalCtx) { sp60.x = COLPOLY_GET_NORMAL(poly->normal.x); sp60.y = COLPOLY_GET_NORMAL(poly->normal.y); sp60.z = COLPOLY_GET_NORMAL(poly->normal.z); - EnBubble_Vec3fNormalizedRelfect(&sp54, &sp60, &sp54); + EnBubble_Vec3fNormalizedReflect(&sp54, &sp60, &sp54); this->bounceDirection = sp54; bounceCount = this->bounceCount; this->bounceCount = ++bounceCount; @@ -256,7 +256,7 @@ void EnBubble_Fly(EnBubble* this, GlobalContext* globalCtx) { } else if ((this->actor.bgCheckFlags & BGCHECKFLAG_WATER) && sp54.y < 0.0f) { sp60.x = sp60.z = 0.0f; sp60.y = 1.0f; - EnBubble_Vec3fNormalizedRelfect(&sp54, &sp60, &sp54); + EnBubble_Vec3fNormalizedReflect(&sp54, &sp60, &sp54); this->bounceDirection = sp54; bounceCount = this->bounceCount; this->bounceCount = ++bounceCount; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index f31b259fb9..791211be5c 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -3803,13 +3803,13 @@ s32 EnHorse_OverrideLimbDraw(Actor* thisx, GlobalContext* globalCtx, s32 limbInd gEponaEyeHalfTex, gEponaEyeClosedTex, }; - static u8 eyeBlinkIndexes[] = { 0, 1, 2, 1 }; + static u8 eyeBlinkIndices[] = { 0, 1, 2, 1 }; EnHorse* this = (EnHorse*)thisx; s32 drawOriginalLimb = true; OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_horse.c", 8582); if (limbIndex == 13 && this->type == HORSE_EPONA) { - u8 index = eyeBlinkIndexes[this->blinkTimer]; + u8 index = eyeBlinkIndices[this->blinkTimer]; gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(eyeTextures[index])); } else if (this->type == HORSE_HNI && this->stateFlags & ENHORSE_FLAG_18 && limbIndex == 30) { diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 1216cae853..8f079cee00 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -373,10 +373,10 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { static s16 textAlpha = 0; static s16 textFadeDirection = 0; static s16 textFadeTimer = 0; - static u8 noControllerFontIndexes[] = { + static u8 noControllerFontIndices[] = { 0x17, 0x18, 0x0C, 0x18, 0x17, 0x1D, 0x1B, 0x18, 0x15, 0x15, 0x0E, 0x1B, }; - static u8 pressStartFontIndexes[] = { + static u8 pressStartFontIndices[] = { 0x19, 0x1B, 0x0E, 0x1C, 0x1C, 0x1C, 0x1D, 0x0A, 0x1B, 0x1D, }; static void* effectMaskTextures[] = { @@ -487,8 +487,8 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, textAlpha); rectLeft = VREG(19) + 1; - for (i = 0; i < ARRAY_COUNT(noControllerFontIndexes); i++) { - EnMag_DrawCharTexture(&gfx, font->fontBuf + noControllerFontIndexes[i] * FONT_CHAR_TEX_SIZE, rectLeft, + for (i = 0; i < ARRAY_COUNT(noControllerFontIndices); i++) { + EnMag_DrawCharTexture(&gfx, font->fontBuf + noControllerFontIndices[i] * FONT_CHAR_TEX_SIZE, rectLeft, YREG(10) + 172); rectLeft += VREG(21); if (i == 1) { @@ -501,8 +501,8 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { gDPSetPrimColor(gfx++, 0, 0, 100, 255, 255, textAlpha); rectLeft = VREG(19); - for (i = 0; i < ARRAY_COUNT(noControllerFontIndexes); i++) { - EnMag_DrawCharTexture(&gfx, font->fontBuf + noControllerFontIndexes[i] * FONT_CHAR_TEX_SIZE, rectLeft, + for (i = 0; i < ARRAY_COUNT(noControllerFontIndices); i++) { + EnMag_DrawCharTexture(&gfx, font->fontBuf + noControllerFontIndices[i] * FONT_CHAR_TEX_SIZE, rectLeft, YREG(10) + 171); rectLeft += VREG(21); if (i == 1) { @@ -523,8 +523,8 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { gDPSetPrimColor(gfx++, 0, 0, 0, 0, 0, textAlpha); rectLeft = YREG(7) + 1; - for (i = 0; i < ARRAY_COUNT(pressStartFontIndexes); i++) { - EnMag_DrawCharTexture(&gfx, font->fontBuf + pressStartFontIndexes[i] * FONT_CHAR_TEX_SIZE, rectLeft, + for (i = 0; i < ARRAY_COUNT(pressStartFontIndices); i++) { + EnMag_DrawCharTexture(&gfx, font->fontBuf + pressStartFontIndices[i] * FONT_CHAR_TEX_SIZE, rectLeft, YREG(10) + 172); rectLeft += YREG(8); if (i == 4) { @@ -537,8 +537,8 @@ void EnMag_DrawInner(Actor* thisx, GlobalContext* globalCtx, Gfx** gfxp) { gDPSetPrimColor(gfx++, 0, 0, YREG(4), YREG(5), YREG(6), textAlpha); rectLeft = YREG(7); - for (i = 0; i < ARRAY_COUNT(pressStartFontIndexes); i++) { - EnMag_DrawCharTexture(&gfx, font->fontBuf + pressStartFontIndexes[i] * FONT_CHAR_TEX_SIZE, rectLeft, + for (i = 0; i < ARRAY_COUNT(pressStartFontIndices); i++) { + EnMag_DrawCharTexture(&gfx, font->fontBuf + pressStartFontIndices[i] * FONT_CHAR_TEX_SIZE, rectLeft, YREG(10) + 171); rectLeft += YREG(8); if (i == 4) { diff --git a/src/overlays/actors/ovl_En_Mb/z_en_mb.c b/src/overlays/actors/ovl_En_Mb/z_en_mb.c index ec8a25147f..797ee5523d 100644 --- a/src/overlays/actors/ovl_En_Mb/z_en_mb.c +++ b/src/overlays/actors/ovl_En_Mb/z_en_mb.c @@ -1448,7 +1448,7 @@ void EnMb_Update(Actor* thisx, GlobalContext* globalCtx) { void EnMb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { static Vec3f unused = { 1100.0f, -700.0f, 0.0f }; static Vec3f feetPos = { 0.0f, 0.0f, 0.0f }; - static Vec3f effSpawnPosModel = { 0.0f, -8000.0f, 0.0f }; + static Vec3f effSpawnModelPos = { 0.0f, -8000.0f, 0.0f }; static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; s32 bodyPart = -1; EnMb* this = (EnMb*)thisx; @@ -1456,7 +1456,7 @@ void EnMb_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec if (this->actor.params == ENMB_TYPE_CLUB) { if (limbIndex == ENMB_LIMB_LHAND) { - Matrix_MultVec3f(&effSpawnPosModel, &this->effSpawnPos); + Matrix_MultVec3f(&effSpawnModelPos, &this->effSpawnPos); if (this->attack > ENMB_ATTACK_NONE) { EnMb_ClubUpdateAttackCollider(&this->actor, globalCtx); } diff --git a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c index ed4f061877..8f6341890c 100644 --- a/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c +++ b/src/overlays/actors/ovl_En_Ossan/z_en_ossan.c @@ -548,7 +548,7 @@ void EnOssan_UpdateCameraDirection(EnOssan* this, GlobalContext* globalCtx, f32 Camera_SetCameraData(GET_ACTIVE_CAM(globalCtx), 0xC, NULL, NULL, cameraFaceAngle, 0, 0); } -s32 EnOssan_TryGetObjBankIndexes(EnOssan* this, GlobalContext* globalCtx, s16* objectIds) { +s32 EnOssan_TryGetObjBankIndices(EnOssan* this, GlobalContext* globalCtx, s16* objectIds) { if (objectIds[1] != OBJECT_ID_MAX) { this->objBankIndex2 = Object_GetIndex(&globalCtx->objectCtx, objectIds[1]); if (this->objBankIndex2 < 0) { @@ -616,7 +616,7 @@ void EnOssan_Init(Actor* thisx, GlobalContext* globalCtx) { return; } - if (EnOssan_TryGetObjBankIndexes(this, globalCtx, objectIds) == 0) { + if (EnOssan_TryGetObjBankIndices(this, globalCtx, objectIds) == 0) { Actor_Kill(&this->actor); osSyncPrintf(VT_COL(RED, WHITE)); osSyncPrintf("予備バンクが無いよ!!(%s)\n", sShopkeeperPrintName[this->actor.params]); diff --git a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c index ed3cd907d0..b538768def 100644 --- a/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c +++ b/src/overlays/actors/ovl_Item_Etcetera/z_item_etcetera.c @@ -40,8 +40,8 @@ static s16 sObjectIds[] = { OBJECT_GI_RUPY, OBJECT_GI_RUPY, OBJECT_GI_HEARTS, OBJECT_GI_KEY, }; -// Indexes passed to the item table in z_draw.c -static s16 sDrawItemIndexes[] = { +// Indices passed to the item table in z_draw.c +static s16 sDrawItemIndices[] = { GID_BOTTLE, GID_LETTER_RUTO, GID_SHIELD_HYLIAN, GID_QUIVER_40, GID_SCALE_SILVER, GID_SCALE_GOLDEN, GID_KEY_SMALL, GID_ARROW_FIRE, GID_RUPEE_GREEN, GID_RUPEE_BLUE, GID_RUPEE_RED, GID_RUPEE_PURPLE, GID_HEART_PIECE, GID_KEY_SMALL, @@ -71,7 +71,7 @@ void ItemEtcetera_Init(Actor* thisx, GlobalContext* globalCtx) { } else { this->objBankIndex = objBankIndex; } - this->giDrawId = sDrawItemIndexes[type]; + this->giDrawId = sDrawItemIndices[type]; this->getItemId = sGetItemIds[type]; this->futureActionFunc = func_80B85824; this->drawFunc = ItemEtcetera_Draw; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 56ba108e18..983c85f4bc 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -2152,7 +2152,7 @@ s32 func_80834380(GlobalContext* globalCtx, Player* this, s32* itemPtr, s32* typ if (this->stateFlags1 & PLAYER_STATE1_23) { *typePtr = ARROW_NORMAL_HORSE; } else { - *typePtr = this->heldItemActionParam - 6; + *typePtr = ARROW_NORMAL + (this->heldItemActionParam - PLAYER_AP_BOW); } } else { *itemPtr = ITEM_SLINGSHOT;