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 taking transformation mask off setting unexpected flags #612

Merged

Conversation

Archez
Copy link
Contributor

@Archez Archez commented May 30, 2024

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 into SET_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 and WEEKEVENTREG_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

@Archez Archez added the rika label May 30, 2024
Copy link
Contributor

@garrettjoecox garrettjoecox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow what a wild ride it was reading that one. Solid find

Copy link
Contributor

@garrettjoecox garrettjoecox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

I like the fix of preserving hardware behavior, it doesn't cause any user issues.

@louist103 louist103 merged commit 6ff53d4 into HarbourMasters:develop-rika May 31, 2024
5 checks passed
@Archez Archez deleted the fix-tansformation-mask-flags branch June 26, 2024 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants