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

Resolve crash during gear selection when BootToMenu is disabled #31

Merged
merged 4 commits into from
Aug 15, 2024

Conversation

Zazsona
Copy link
Contributor

@Zazsona Zazsona commented Aug 15, 2024

Description

This change resolves an issue where the game crashes after selecting a character in "Free Race" and UnlockAllAndBootToMenu is disabled.

This occurs due to the CustomGearCodePatcher setting up the new _unlockedGearModels array with false for all values.
It seems when a save file is loaded, it fails to update the new array, and only writes to the game's original "unlocked gears" memory space. (Presumably, loading the save writes a block of data to memory, starting from a Pointer that isn't updated by the Patcher?)

This failure to update the new array results in all gears remaining locked, so when the player goes to select a gear for the race, the game crashes as there are no gears to display.

Implementation

The crux of the implementation is a little crude - Effectively whenever the game loads the Character Select Menu, we check the vanilla game's unlock memory addresses, and clone their state over to the new array. We then manually unlock any custom gears, as there is of course no way to unlock these otherwise.

The custom gears themselves are also granted unique, arbitrary ExtremeGearModel values in the _gearToGearModel array. This is simply such that custom gears can be unlocked exclusively from the original game's ExtremeGearModel they are based on.

Limitations / Known Issues

  • Gear Shop does not work
    • While the shop can still be accessed, it will always display the "No gears are available for sale" message, even if loading the same save file with Riders Tweakbox disabled shows the save should have access to purchasable gears

Tested Scenarios

I've only tested Single Player functionality, so I'm not sure how these changes would affect Netplay.
Nonetheless, I've tested with both a complete (i.e, all gears unlocked) save file and an incomplete one, alongside zero, one, and two custom gears in both scenarios, and had no issues in Free Race.

Default-only gamemodes such as Survival Mode also work as expected.

@Zazsona
Copy link
Contributor Author

Zazsona commented Aug 15, 2024

Fixes #27!

@Sewer56
Copy link
Owner

Sewer56 commented Aug 15, 2024

I didn't think I'd ever get a PR here, especially given that I haven't worked on this for 2 years at this point.

In any case, seems good, just need to fixup the namespaces, e.g.
from Sewer56.SonicRiders.Structures.Gameplay.ExtremeGear to ExtremeGear, not on my machine but I can't see why full name needs qualified here, other than a namespace conflict. (You can resolve those with using aliases)

…ar to avoid conflict with Sewer56.SonicRiders.Structures.Enums.ExtremeGear
@Zazsona
Copy link
Contributor Author

Zazsona commented Aug 15, 2024

Haha, can't ever rule out some looney like me making Sonic Riders my obsession-of-the-week!

Cheers though! - There was a sneaky namespace conflict between Sewer56.SonicRiders.Structures.Enums and Sewer56.SonicRiders.Structures.Gameplay, as both define an ExtremeGear, but didn't know about using aliases being a thing, so I've slapped one in!

@Sewer56
Copy link
Owner

Sewer56 commented Aug 15, 2024

There's also a missing alias for Sewer56.SonicRiders.Structures.Enums.ExtremeGearModel :p

Hehehe. It happens.
And it's always good to learn something new :p

@Zazsona
Copy link
Contributor Author

Zazsona commented Aug 15, 2024

Whoops! - Good catch!
Those should all be simplified now too!

@Sewer56
Copy link
Owner

Sewer56 commented Aug 15, 2024

Seems good to me, I'll chuck a release when I get to my machine later.

@Sewer56 Sewer56 merged commit 581b047 into Sewer56:master Aug 15, 2024
@Zazsona
Copy link
Contributor Author

Zazsona commented Aug 15, 2024

Perfect, cheers mate!
Certainly no rush from my side, so no worries if you don't get around to doing the release!

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