TWW: Add save file validation #5819
Open
+103
−71
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.
What is this fixing or adding?
All seeds for TWW use the same game ID. What this means is that when a player loads a new seed with a newly randomized ISO, their old save file will still be there. Assigning each seed a unique game ID, or even just allowing a few more game IDs (see #5186), can help with this, but there is the issue of juggling these extra game save files, as each game ID creates a new .gci file in Dolphin.
This PR does not address this issue. Instead, it's addressing another issue that is related to player experience when playing with multiple TWW seeds. There is currently no save file validation when connecting to the server. Since TWW checks for set flags (in simple terms) to check locations, if a player connects to a save file for a different seed, all the locations checked in that save file will automatically be checked for the current slot, even though the player never checked those locations in that save file. In a worst-case scenario, a player might accidentally open a save file with every location checked and instantly "release" their current slot.
To resolve this, the patcher generates a hash from the seed and slot name, yielding a unique identifier. This identifier is added to the randomized ISO. Upon creating a new save file, the identifier is copied from the ISO to the save file. Thus, whenever a save file is opened, the client can check that the save file and ISO identifiers match. If they do not, the client will automatically disconnect the player from the server, preventing any locations from accidentally being sent.
This change, however, doesn't prevent loading the save state of a different save file from sending locations, as save states will modify the identifier in both the save file and the ISO.
As a bonus, since there is this additional validation, the slot name authentication has been moved up in the task loop, meaning that a player can now connect to the server while on the title screen or file select screen. If they do connect to an invalid save file, the changes in this PR will disconnect them immediately.
Like with #5686, this change requires a version update of the patcher program.
The updated code can be found here: https://github.com/tanjo3/wwrando/tree/ap-add-seed-identifier
How was this tested?
Ran the game, attempted to connect to a valid save file, and an invalid save file. The client properly disconnected me when I tried to connect to the invalid save file. I was able to properly connect and play when I loaded the valid save file.
If this makes graphical changes, please attach screenshots.
N/A