Fix taking transformation mask off setting unexpected flags #612
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The game sets some flags when putting on a transformation mask. These flags are what allow the player to press a button to "skip" the cutscene after the first time. An array tracks the flag for each player form.
The problem is this logic also executes for taking a mask off which leads to
PLAYER_FORM_HUMAN
being passed into the same array. This ends up as a OOB read, causing garbage data to be passed intoSET_WEEKEVENTREG
meaning random flag(s) are potentially set. It's been observed on LInux that this sets a few flags pertaining to learning Goron Lullaby.Checking on console reveals that the OOB value that gets used on console is
0x100A
which translates to two flags being set:WEEKEVENTREG_16_02
andWEEKEVENTREG_16_08
The later of the two appears to be unused. The first however is used by the Gorman Brothers to present or skip a specific text ID that would show on the third day if the player completed the alien quest.
The text is the "I head some garos attacked the milk wagon".
I've opted to add a value to the array that matches console, so these flags will be set when taking a mask off, restoring original behavior with the OOB read.
Alternatively, we could fix the bug by checking for the human form and just not call
SET_WEEKEVENTREG
at all if that is more preferred.Fixes #490
Build Artifacts