summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPokeCodec <67983839+PokeCodec@users.noreply.github.com>2020-09-06 15:16:40 -0400
committerPokeCodec <67983839+PokeCodec@users.noreply.github.com>2020-09-06 15:16:40 -0400
commite6684664ba57aa3840d63860a5637c80bb7399a4 (patch)
tree22f38dd7df4bac57a55ce548752e8ba534059ef7 /src
parent5d2a4e02dd9febf57968ddb9754aaf32cdc64065 (diff)
Fix casting bug
Diffstat (limited to 'src')
-rw-r--r--src/pokemon.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pokemon.c b/src/pokemon.c
index 782c22d28..2440f183e 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -5756,10 +5756,12 @@ u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex)
switch (gNatureStatTable[nature][statIndex - 1])
{
case 1:
- 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
+ retVal = n * 110;
+ retVal /= 100;
break;
case -1:
- retVal = (u16)(n * 90) / 100; // NOTE: will overflow for n > 728, see above
+ retVal = n * 90;
+ retVal /= 100;
break;
default:
retVal = n;