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

Save migration #3081

Closed
wants to merge 52 commits into from
Closed

Conversation

Bassoonian
Copy link
Collaborator

@Bassoonian Bassoonian commented Jun 27, 2023

Implements @tustin2121's save migrations (https://github.com/pret/pokeemerald/wiki/How-to-Support-Savefile-Backwards-Compatibility) into RHH alongside a python script (run through makefile shenanigans) that will automatically compare versions and take care of the migration code. Big thanks to @PokemonSanFran for their extensive testing!

Description

This PR consists of two major components: the changes to the codebase and the addition of a make_release folder in tools.

Codebase changes

  • Makefile includes a setup for make release. This does NOT automatically initiate a compile at the moment (both because I didn't know how to make it do so and because I'm not sure if it's a good idea).
  • include/config.h now also includes RHH_EXPANSION_VERSION. This allows us to declare internal versions that allow for save migration whenever we push save block changes that make_release can not automatically take care of such as things requiring lookup tables for reordered species names.
  • include/constants/global.h contains a commented out include for versioning.h. Make_release will uncomment this and automatically generate said file.
  • include/save.h up to src/main_menu.c include defines and functions made by Tustin.
  • src/save.c contains a combination of Tustin magic and extra changes to work with make_release. The define SAVE_VERSION does not exist until make_release is run, which effectively dumies out all the save migration code until a first version is defined. This makes the entirety of the save migration optional for the user (until we start enforcing it through expansion-based save block changes, that is).

Make_release

The vast majority of the new files in the make_release folder are the python libraries cxxheaderparser and pcpp. I opted to include these as raw files so users don't need to bother with pip and the only prerequisite is having python3 installed.

The vast majority of the magic happens in the python script make_release.py. I did my best to provide some sort of documentation inside, but it is fairly spaghetti. I would support someone with more coding experiencerewriting/cleaning this up later, but for now it should do the job.

Testing

psf has tested the system considerably, adding fields, removing fields, changing the size of arrays etc. While we have not been able to confirm black on white that everything works through saveblock dumping (please see this PR's discussion on Discord), everything in game appears to migrate just fine with zero side effects.

Discord contact info

bassoonian (Jasper)

@Bassoonian Bassoonian marked this pull request as draft June 27, 2023 10:36
@cfmnephrite
Copy link

Amazing stuff, buddy :O

@Bassoonian Bassoonian marked this pull request as ready for review August 5, 2023 10:28
@Bassoonian
Copy link
Collaborator Author

Ready for review.

@leo60228 leo60228 mentioned this pull request Aug 22, 2023
8 tasks
@Bassoonian
Copy link
Collaborator Author

As mentioned in the Discord server, this PR is up for adoption as I will not continue working on it. I'll leave the branch up on my repo if anyone wishes to continue it.

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