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

Quest Cleanup #3178

Merged
merged 10 commits into from
Sep 26, 2023
Merged

Quest Cleanup #3178

merged 10 commits into from
Sep 26, 2023

Conversation

Pepe20129
Copy link
Contributor

@Pepe20129 Pepe20129 commented Sep 10, 2023

This PR replaces isMasterQuest, n64ddFlag & isBossRush checks with a new field (questId) and macros.
It also restores authentic n64ddFlag behaviour.
It doesn't change savefiles on disk which still use isMasterQuest & n64ddFlag because I don't think breaking save compatibility for something minor like this is worth it and it could be grouped with future changes to the save format.

Build Artifacts

Copy link
Contributor

@garrettjoecox garrettjoecox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bravo. My main points of initial feedback would be:

Why a macro function instead of just assuming gSaveContext is available? Eg IS_RANDO vs IS_RANDO(gSaveContext)

Even though they won’t be used much, you should use macros for the quest IDs

@Pepe20129
Copy link
Contributor Author

Why a macro function instead of just assuming gSaveContext is available? Eg IS_RANDO vs IS_RANDO(gSaveContext)

I did it because some places like SaveManager::SaveRandomizer use a pointer to the save context so it does IS_RANDO(*saveContext).

Even though they won’t be used much, you should use macros for the quest IDs

I didn't do that because the enum is in file_choose.h and I thought that it may not be the best idea to include it in z64save.h as z64 headers are included almost everywhere. If it's not a big deal I can do it.

@garrettjoecox
Copy link
Contributor

I did it because some places like SaveManager::SaveRandomizer use a pointer to the save context so it does IS_RANDO(*saveContext).

That's fair, though how often do those special cases show up compared to not? Could we just do an inline comparison to the enum for the save manager case?

I didn't do that because the enum is in file_choose.h and I thought that it may not be the best idea to include it in z64save.h as z64 headers are included almost everywhere. If it's not a big deal I can do it.

I'd say just move the enum, no particular reason it needs to stay there right?

soh/include/z64save.h Outdated Show resolved Hide resolved
@Pepe20129
Copy link
Contributor Author

I'd say just move the enum, no particular reason it needs to stay there right?

Moved it.

@Pepe20129
Copy link
Contributor Author

That's fair, though how often do those special cases show up compared to not? Could we just do an inline comparison to the enum for the save manager case?

They're rare so I could just change it to assume gSaveContext and require manual checks when it's not the case

@Pepe20129
Copy link
Contributor Author

Done, the macros no longer take gSaveContext and in the end there was only one place that didn't use it.

Copy link
Contributor

@garrettjoecox garrettjoecox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work again. Dropping an approval but I did have one question around the save manager stuff someone might be able to pipe in on.

@@ -1651,7 +1675,11 @@ void SaveManager::LoadBaseVersion4() {
SaveManager::Instance->LoadArray("randomizerInf", ARRAY_COUNT(gSaveContext.randomizerInf), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.randomizerInf[i]);
});
SaveManager::Instance->LoadData("isMasterQuest", gSaveContext.isMasterQuest);
int isMQ = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't recall how we were supposed to treat changes like this, is it the correct behavior to make this change in LoadV1, LoadV2, LoadV3, and LoadV4? I think so?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so as if this change wasn't made, older save files would not migrate their rando/master quest status correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that's correct. I think we discussed having it be chained loading so loading V1 would mean V1 -> V2, V2 -> V3, V3 -> V4 but decided against it. Instead we have "this is how you load this old version of a save into the current save format"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I feel like maybe the chain load would have been better in the end, but the only other option would be to make a new loader version and settings migrator, which would be overkill for a single thing like this. I'm OK with this method of handling it.

@garrettjoecox garrettjoecox merged commit d63c9d1 into HarbourMasters:develop Sep 26, 2023
@Pepe20129 Pepe20129 deleted the quest_cleanup branch December 22, 2023 18:31
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.

4 participants