Enemy data is cleared at the start of trainer battles and with setwildbattle, but with #4688 there is a potential to use createmon to set up a complex wild battle without zeroing out said data beforehand, so stray pokemon data from previous battles could leak into such battles and cause problems. This PR just resets enemy mon data after each battle to prevent this from occurring.
It also adds a gBattleStruct != NULL check to the same block so FreeBattleResources and co. are only called once instead of over many frames while gPaletteFade is active
Enemy data is cleared at the start of trainer battles and with setwildbattle, but with #4688 there is a potential to use
createmon
to set up a complex wild battle without zeroing out said data beforehand, so stray pokemon data from previous battles could leak into such battles and cause problems. This PR just resets enemy mon data after each battle to prevent this from occurring.It also adds a
gBattleStruct != NULL
check to the same block soFreeBattleResources
and co. are only called once instead of over many frames while gPaletteFade is active