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

Pokemon Emerald: Fix terra/marine caves bugged internal id #3161

Merged
merged 2 commits into from
Apr 18, 2024

Conversation

Zunawe
Copy link
Collaborator

@Zunawe Zunawe commented Apr 16, 2024

What is this fixing or adding?

Terra and Marine Cave have 8 possible locations each with mutually exclusive internal location ids 1-16. Location id 0 means "no abnormal weather", hence starting at 1. But that means a possible value of 16 would require 5 bits, which is larger than the allotted size in the ROM of 4 bits.

I believe this results in a 1/8 chance that Kyogre is not findable, but nobody has reported that behavior. This was found while using #2995, which crashes when struct.pack is asked to fill a byte with a number that requires 9 bits to store.

How was this tested?

Generated with a check in _set_bytes_le if the value was ever larger than the specified size until I hit the condition. Tried again with the same seed on this branch and it didn't fail. Though I suppose changing the size of the array it picks from affects RNG. Generating a few 20-player multis also didn't encounter the issue with the size check, which should happen 1/8 times.

@Zunawe Zunawe added the is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. label Apr 16, 2024
@github-actions github-actions bot added the waiting-on: peer-review Issue/PR has not been reviewed by enough people yet. label Apr 16, 2024
@Zunawe
Copy link
Collaborator Author

Zunawe commented Apr 16, 2024

In the previous version of this PR before the force push I lost my mind for a moment and forgot that 4 bits can hold values 0-15 and not just values 0-7. It's only this one marine cave id that can trigger the problem.

@Zunawe Zunawe added the affects: release/blocker Issues/PRs that must be addressed before next official release. label Apr 16, 2024
@Berserker66 Berserker66 merged commit 2d3f3fc into ArchipelagoMW:main Apr 18, 2024
15 checks passed
@Zunawe Zunawe deleted the emerald-fix-caves branch May 23, 2024 08:44
qwint pushed a commit to qwint/Archipelago that referenced this pull request Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects: release/blocker Issues/PRs that must be addressed before next official release. is: bug/fix Issues that are reporting bugs or pull requests that are fixing bugs. waiting-on: peer-review Issue/PR has not been reviewed by enough people yet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants