Fixed out-of-bounds access in GetFactoryMonFixedIV when generating player rentals in round 8 (if player has 15+ swaps) and in round 9

This commit is contained in:
kaboissonneault
2023-10-04 09:18:02 -04:00
parent 654b6380b1
commit 3a8a82d385

View File

@@ -741,7 +741,14 @@ u8 GetFactoryMonFixedIV(u8 challengeNum, bool8 isLastBattle)
u8 ivSet;
bool8 useHigherIV = isLastBattle ? TRUE : FALSE;
// The Factory has an out-of-bounds access when generating the rental draft for round 9 (challengeNum==8),
// or the "elevated" rentals from round 8 (challengeNum+1==8)
// This happens to land on a number higher than 31, which is interpreted as "random IVs"
#ifdef BUGFIX
if (challengeNum > 7)
#else
if (challengeNum > 8)
#endif
ivSet = 7;
else
ivSet = challengeNum;