mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-02-21 11:43:37 +01:00
Fix casting bug
This commit is contained in:
parent
5d2a4e02dd
commit
e6684664ba
@ -5756,10 +5756,12 @@ u16 ModifyStatByNature(u8 nature, u16 n, u8 statIndex)
|
|||||||
switch (gNatureStatTable[nature][statIndex - 1])
|
switch (gNatureStatTable[nature][statIndex - 1])
|
||||||
{
|
{
|
||||||
case 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;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
retVal = (u16)(n * 90) / 100; // NOTE: will overflow for n > 728, see above
|
retVal = n * 90;
|
||||||
|
retVal /= 100;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
retVal = n;
|
retVal = n;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user