summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPokeCodec <67983839+PokeCodec@users.noreply.github.com>2020-09-05 11:47:24 -0400
committerPokeCodec <67983839+PokeCodec@users.noreply.github.com>2020-09-05 11:47:24 -0400
commita7a64ecba052566b1ae5b530cc6f28ccab191af1 (patch)
treebb5000becf00cc8b1bdd210a95b285e5596b05cb /src
parent16ecbc6446f4e8d308e71aa5e649c69acb8a6b3e (diff)
Fixup ModifyStatByNature
Diffstat (limited to 'src')
-rwxr-xr-xsrc/faraway_island.c23
-rw-r--r--src/pokemon.c18
2 files changed, 19 insertions, 22 deletions
diff --git a/src/faraway_island.c b/src/faraway_island.c
index e3d8444c9..6bfa066c2 100755
--- a/src/faraway_island.c
+++ b/src/faraway_island.c
@@ -181,40 +181,36 @@ u32 GetMewMoveDirection(void)
{
if (ShouldMewMoveEast(mew, 1))
return GetRandomMewDirectionCandidate(2);
- else if (ShouldMewMoveWest(mew, 1))
+ if (ShouldMewMoveWest(mew, 1))
return GetRandomMewDirectionCandidate(2);
- else
- return DIR_NORTH;
+ return DIR_NORTH;
}
if (ShouldMewMoveSouth(mew, 0))
{
if (ShouldMewMoveEast(mew, 1))
return GetRandomMewDirectionCandidate(2);
- else if (ShouldMewMoveWest(mew, 1))
+ if (ShouldMewMoveWest(mew, 1))
return GetRandomMewDirectionCandidate(2);
- else
- return DIR_SOUTH;
+ return DIR_SOUTH;
}
if (ShouldMewMoveEast(mew, 0))
{
if (ShouldMewMoveNorth(mew, 1))
return GetRandomMewDirectionCandidate(2);
- else if (ShouldMewMoveSouth(mew, 1))
+ if (ShouldMewMoveSouth(mew, 1))
return GetRandomMewDirectionCandidate(2);
- else
- return DIR_EAST;
+ return DIR_EAST;
}
if (ShouldMewMoveWest(mew, 0))
{
if (ShouldMewMoveNorth(mew, 1))
return GetRandomMewDirectionCandidate(2);
- else if (ShouldMewMoveSouth(mew, 1))
+ if (ShouldMewMoveSouth(mew, 1))
return GetRandomMewDirectionCandidate(2);
- else
- return DIR_WEST;
+ return DIR_WEST;
}
// If this point is reached, Mew cannot move without getting closer to the player
@@ -315,8 +311,7 @@ static u8 GetValidMewMoveDirection(u8 ignoredDir)
if (count > 1)
return sMewDirectionCandidates[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % count];
- else
- return sMewDirectionCandidates[0];
+ return sMewDirectionCandidates[0];
}
void UpdateFarawayIslandStepCounter(void)
diff --git a/src/pokemon.c b/src/pokemon.c
index 188624d6a..782c22d28 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -5746,25 +5746,27 @@ u8 GetTrainerEncounterMusicId(u16 trainerOpponentId)
u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex)
{
+ u16 retVal;
// Dont modify HP, Accuracy, or Evasion by nature
if (statIndex <= STAT_HP || statIndex > NUM_NATURE_STATS)
{
- // Should just be "return n", but it wouldn't match without this.
- u16 retVal = n;
- retVal++;
- retVal--;
- return retVal;
+ return n;
}
switch (gNatureStatTable[nature][statIndex - 1])
{
case 1:
- return (u16)(n * 110) / 100; // NOTE: will overflow for n > 595 because the intermediate value is cast to u16 before the division. Fix by removing (u16) cast
+ retVal = (u16)(n * 110) / 100; // NOTE: will overflow for n > 595 because the intermediate value is cast to u16 before the division. Fix by removing (u16) cast
+ break;
case -1:
- return (u16)(n * 90) / 100; // NOTE: will overflow for n > 728, see above
+ retVal = (u16)(n * 90) / 100; // NOTE: will overflow for n > 728, see above
+ break;
+ default:
+ retVal = n;
+ break;
}
- return n;
+ return retVal;
}
#define IS_LEAGUE_BATTLE \