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.
This is a WIP example of reworking CVars to solve several issues with them. This is the SoH side of things, for the LUS PR, see Kenix3/libultraship#137.
The issues I am trying to fix:
The changes needed in SoH are less structural, and more just needed as a client of the new interface. They do present an example of the intended interface. This PR reworks the values previously held in
global.sav
to be the new version of CVars. As such, they no longer need to be saved, since they will be saved with the CVars. Let's see what was needed to convert them.GlobalSettings.h
/.cpp
andz64settings.h
z64settings.h
contains a global struct of settings that exist outside of any file-specific data. Data was moved out fromgSaveContext
accordingly.GlobalSettings
is the C++ side of things and manages defaulting and associating the data with CVars.So, to add a new setting and associated CVar you:
z64settings.h
GlobalSettings.cpp
GlobalSettings.cpp
That's it! Now you can use it just like a regular C variable and it'll get saved along with all the other CVars.
Update: made a second commit to show how to convert the existing usage into the new usage.