rh-hideout / pokeemerald-expansion

Feature branches for the pokeemerald decompilation. See the wiki for more info.
306 stars 815 forks source link

Zero Enemy Data at end of battles #4867

Closed ghoulslash closed 1 week ago

ghoulslash commented 1 week ago

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