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 sometimes receiving items on the titlescreen #3

Merged
merged 1 commit into from
Jul 14, 2024

Conversation

Mysteryem
Copy link
Contributor

@Mysteryem Mysteryem commented Jul 14, 2024

The read_string() function was stripping trailing null characters, however, when setting the stage name, TWW only writes bytes up to and including the null character, so any previously written bytes within the 8 bytes of storage would remain.

E.g. going to Ice Ring Isle Cave will set the stage name to b"MiniHyo\0", writing over all 8 bytes. Going directly from Ice Ring Isle Cave to the title screen will set the stage name to b"sea_T\0", but because this is only 6 bytes, the last two bytes will remain unchanged and the full 8 bytes will be b"sea_T\0o\0", so stripping null characters would return the incorrect bytestring b"sea_T\0o" which the AP Client would not consider to be the title screen in check_ingame().

read_string() has been changed to split the bytes by the first occurrence of a null character. Everything before the first null character will be the string. If there is no null character present, then the string will be considered all the bytes that were read.

The `read_string()` function was stripping trailing null characters, however, when setting the stage name, TWW only writes bytes up to and including the null character, so any previously written bytes within the 8 bytes of storage would remain.

E.g. going to Ice Ring Isle Cave will set the stage name to `b"MiniHyo\0"`, writing over all 8 bytes. Going directly from Ice Ring Isle Cave to the title screen will set the stage name to `b"sea_T\0"`, but because this is only 6 bytes, the last two bytes will remain unchanged and the full 8 bytes will be `b"sea_T\0o\0"`, so stripping null characters would return the incorrect string `b"sea_T\0o"`.

`read_string()` has been changed to split the bytes by the first occurrence of a null character. Everything before the first null character will be the string. If there is no null character present, then the string will be considered all the bytes that were read.
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