ub fix for OOB access with gActiveBattler

This commit is contained in:
cawtds 2025-04-26 00:21:03 +02:00
parent 66c07f9c33
commit d8c1b55b22

View File

@ -57,6 +57,11 @@ void SetUpBattleVarsAndBirchZigzagoon(void)
gBattleControllerExecFlags = 0;
ClearBattleAnimationVars();
ClearBattleMonForms();
// UB: at the start of a battle CheckMoveLimitations is called with gActiveBattler
// from the previous battle, which can lead to multiple arrays being accessed out of bounds
#ifdef UBFIX
gActiveBattler = 0;
#endif
BattleAI_HandleItemUseBeforeAISetup(0xF);
if (gBattleTypeFlags & BATTLE_TYPE_FIRST_BATTLE)