Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Beat Up's battle script to avoid an out-of-bounds array access #2541

Merged
merged 1 commit into from
Dec 27, 2022

Conversation

sphericalice
Copy link

@sphericalice sphericalice commented Dec 27, 2022

Description

Instead of using gBattleCommunication[0] to keep track of the current Beat Up slot for its damage calc, this PR introduces a dedicated field in gBattleStruct, beatUpSlot, which gets initialised to 0 at the start of battle. This fixes #2540, as the damage calculation was being called by AI calculations before the script for Beat Up was ran to set gBattleCommunication[0], leading to an out-of-bounds array access. For an abundance of caution, the incrementing of gBattleStruct->beatUpSlot has also been moved to occur after the damage calculation takes place, so that no shenanigans with - 1 needs to take place. I also overloaded the Cmd_trybeatup battle script command so that it's more clear that Beat Up's effect changes depending on the B_BEAT_UP setting, as before it wasn't clear by looking at that function alone that it was effectively unused when B_BEAT_UP was >= GEN_5.

Discord contact info

Spherical Ice#4683

@AsparagusEduardo AsparagusEduardo merged commit d120f2f into rh-hideout:upcoming Dec 27, 2022
@sphericalice sphericalice deleted the beat-up branch January 5, 2023 23:29
@AsparagusEduardo AsparagusEduardo mentioned this pull request Feb 19, 2023
@AlexOn1ine AlexOn1ine mentioned this pull request Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants