From bfe369453245d9b59e77f66e2b13dbe7ec61edb0 Mon Sep 17 00:00:00 2001 From: Ethan Roseman Date: Thu, 19 Nov 2020 14:21:59 -0500 Subject: [PATCH] PR comments --- include/common_structs.h | 8 +++++++- src/code_16c8e0.c | 16 ++++++++-------- src/code_17FEB0.c | 6 +++--- src/code_197F40.c | 8 ++++---- src/code_1A5830.c | 1 + 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/common_structs.h b/include/common_structs.h index 2e734b9d30..344e60e75d 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -1198,11 +1198,17 @@ typedef struct Zone { /* 0x28 */ s32 flag; } Zone; // size = 0x2C +typedef struct ActorMovePos { + /* 0x00 */ Vec3f current; + /* 0x0C */ Vec3f goal; + /* 0x18 */ Vec3f end; +} ActorMovePos; // size = 0x20; + typedef struct Actor { /* 0x000 */ s32 flags; /* 0x004 */ char unk_04[4]; /* 0x008 */ struct StaticActorData* staticActorData; - /* 0x00C */ Vec3f movePos[3]; // current, goal, end + /* 0x00C */ ActorMovePos movePos; /* 0x030 */ char unk_30[24]; /* 0x048 */ f32 jumpAccel; /* 0x04C */ f32 moveSpeed; diff --git a/src/code_16c8e0.c b/src/code_16c8e0.c index 6cb843473e..a8bf237eb2 100644 --- a/src/code_16c8e0.c +++ b/src/code_16c8e0.c @@ -6,7 +6,7 @@ void get_dpad_input_radial(f32* angle, f32* magnitude) { f32 stickX; f32 stickY; f32 mag; - f32 sixty = 60.0f; + f32 maxMagnitude = 60.0f; stickX = battleStatus->stickX; stickY = battleStatus->stickY; @@ -16,22 +16,22 @@ void get_dpad_input_radial(f32* angle, f32* magnitude) { stickY = 0.0f; stickX = 0.0f; if (currentButtonsDown & 0x800) { - stickY = sixty; + stickY = maxMagnitude; } if (currentButtonsDown & 0x400) { - stickY = -sixty; + stickY = -maxMagnitude; } if (currentButtonsDown & 0x200) { - stickX = -sixty; + stickX = -maxMagnitude; } if (currentButtonsDown & 0x100) { - stickX = sixty; + stickX = maxMagnitude; } } mag = dist2D(0.0f, 0.0f, stickX, -stickY); - if (mag >= sixty) { - mag = sixty; + if (mag >= maxMagnitude) { + mag = maxMagnitude; } *angle = atan2(0.0f, 0.0f, stickX, -stickY); @@ -79,10 +79,10 @@ INCLUDE_ASM(s32, "code_16c8e0", func_80240AA8); INCLUDE_ASM(s32, "code_16c8e0", delete_actor); void delete_player_actor(Actor* player) { - s32 i; struct ActorPart* partsTable; struct ActorPartMovement* movement; struct DecorationTable* decorationTable; + s32 i; for (i = 0; i < 2; i++) { remove_actor_decoration(player, i); diff --git a/src/code_17FEB0.c b/src/code_17FEB0.c index 73149b4542..0430c715f6 100644 --- a/src/code_17FEB0.c +++ b/src/code_17FEB0.c @@ -2,7 +2,7 @@ HitResult calc_item_check_hit(void) { BattleStatus* battleStatus = BATTLE_STATUS; - f32* pos = &battleStatus->playerActor->movePos; + ActorMovePos* movePos = &battleStatus->playerActor->movePos; s32 actorID = battleStatus->currentTargetID; s8 currentTargetPartS8; u32 currentTargetPart; @@ -23,11 +23,11 @@ HitResult calc_item_check_hit(void) { return HitResult_MISS; } if (actor->stoneStatus == 0xC) { - play_sound_at_position(0x10C, 0, pos[3], pos[4], pos[5]); + play_sound_at_position(0x10C, 0, movePos->goal.x, movePos->goal.y, movePos->goal.z); return HitResult_IMMUNE; } if ((battleStatus->currentAttackElement & 0x80) && (actorPart->eventFlags & 0x10)) { - play_sound_at_position(0xE9, 0, pos[3], pos[4], pos[5]); + play_sound_at_position(0xE9, 0, movePos->goal.x, movePos->goal.y, movePos->goal.z); return HitResult_LANDED_ON_SPIKE; } } else { diff --git a/src/code_197F40.c b/src/code_197F40.c index 616b404ae2..156a76bdd7 100644 --- a/src/code_197F40.c +++ b/src/code_197F40.c @@ -35,7 +35,7 @@ s32 get_nearest_home_index(f32 x, f32 y, f32 z) { } } - return yVal | (xVal * 4); + return yVal | (xVal << 2); } INCLUDE_ASM(void, "code_197F40", set_goal_pos_to_part, f32* goalPos, ActorId target, s32 partIndex); @@ -87,9 +87,9 @@ ApiStatus SetGoalToHome(ScriptInstance* script, s32 isInitialCall) { } actor = get_actor(actorID); - actor->movePos[1].x = actor->homePos.x; - actor->movePos[1].y = actor->homePos.y; - actor->movePos[1].z = actor->homePos.z; + actor->movePos.goal.x = actor->homePos.x; + actor->movePos.goal.y = actor->homePos.y; + actor->movePos.goal.z = actor->homePos.z; return ApiStatus_DONE2; } diff --git a/src/code_1A5830.c b/src/code_1A5830.c index ab2b03b0cb..11280144be 100644 --- a/src/code_1A5830.c +++ b/src/code_1A5830.c @@ -14,6 +14,7 @@ s32 func_80276F50(Actor* actor) { partIt = partIt->nextPart; } } + return ret; }