Skip to content

Commit

Permalink
Actually fix issues with log settings (HarbourMasters#4813)
Browse files Browse the repository at this point in the history
* remove taking settings from a loaded spoiler instead of the imGUI settings

* actually fix most SpoilerLoad issues

* fix vanilla saves making future generations have so settings

* remove extra comment
  • Loading branch information
Pepper0ni authored Jan 6, 2025
1 parent 2f8bb02 commit cb73830
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 87 deletions.
2 changes: 1 addition & 1 deletion soh/soh/Enhancements/randomizer/ShuffleFreestanding.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ShuffleFreestanding.h"

extern "C" {
#include "functions.h";
#include "functions.h"
extern PlayState* gPlayState;
}

Expand Down
7 changes: 2 additions & 5 deletions soh/soh/Enhancements/randomizer/randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1873,11 +1873,8 @@ void GenerateRandomizerImgui(std::string seed = "") {
CVarSetInteger(CVAR_GENERAL("RandoGenerating"), 1);
CVarSave();
auto ctx = Rando::Context::GetInstance();
/*RANDOTODO proper UI for selecting if a spoiler loaded should be used for settings
if (!ctx->IsSpoilerLoaded()) {
// We use the settings from the spoiler rather than CVars.
ctx->GetSettings()->SetAllFromCVar();
}*/
//RANDOTODO proper UI for selecting if a spoiler loaded should be used for settings
ctx->GetSettings()->SetAllFromCVar();

// todo: this efficently when we build out cvar array support
std::set<RandomizerCheck> excludedLocations;
Expand Down
156 changes: 75 additions & 81 deletions soh/soh/Enhancements/randomizer/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2063,102 +2063,96 @@ void Settings::UpdateOptionProperties() {

void Settings::FinalizeSettings(const std::set<RandomizerCheck>& excludedLocations, const std::set<RandomizerTrick>& enabledTricks) {
const auto ctx = Rando::Context::GetInstance();
if (!ctx->IsSpoilerLoaded()) {
for (Option& option : mOptions) {
option.SetContextIndex(option.GetMenuOptionIndex());
}
// If we've loaded a spoiler file, the settings have already been populated, so we
// only need to do things like resolve the starting age or determine MQ dungeons.
// Any logic dependent on cvarSettings should go in this if statement

// if we skip child zelda, we start with zelda's letter, and malon starts
// at the ranch, so we should *not* shuffle the weird egg
if (mOptions[RSK_SKIP_CHILD_ZELDA]) {
mOptions[RSK_SHUFFLE_WEIRD_EGG].SetContextIndex(RO_GENERIC_OFF);
}
for (Option& option : mOptions) {
option.SetContextIndex(option.GetMenuOptionIndex());
}

// if we skip child zelda, we start with zelda's letter, and malon starts
// at the ranch, so we should *not* shuffle the weird egg
if (mOptions[RSK_SKIP_CHILD_ZELDA]) {
mOptions[RSK_SHUFFLE_WEIRD_EGG].SetContextIndex(RO_GENERIC_OFF);
}

// With certain access settings, the seed is only beatable if Starting Age is set to Child.
if (mOptions[RSK_FOREST].Is(RO_CLOSED_FOREST_ON) || (mOptions[RSK_DOOR_OF_TIME].Is(RO_DOOROFTIME_CLOSED) &&
!mOptions[RSK_SHUFFLE_OCARINA])) {
mOptions[RSK_STARTING_AGE].SetContextIndex(RO_AGE_CHILD);
}
// With certain access settings, the seed is only beatable if Starting Age is set to Child.
if (mOptions[RSK_FOREST].Is(RO_CLOSED_FOREST_ON) || (mOptions[RSK_DOOR_OF_TIME].Is(RO_DOOROFTIME_CLOSED) &&
!mOptions[RSK_SHUFFLE_OCARINA])) {
mOptions[RSK_STARTING_AGE].SetContextIndex(RO_AGE_CHILD);
}

if (mOptions[RSK_TRIFORCE_HUNT]) {
mOptions[RSK_GANONS_BOSS_KEY].SetContextIndex(RO_GANON_BOSS_KEY_TRIFORCE_HUNT);
}
if (mOptions[RSK_TRIFORCE_HUNT]) {
mOptions[RSK_GANONS_BOSS_KEY].SetContextIndex(RO_GANON_BOSS_KEY_TRIFORCE_HUNT);
}

// Force 100 GS Shuffle if that's where Ganon's Boss Key is
if (mOptions[RSK_GANONS_BOSS_KEY].Is(RO_GANON_BOSS_KEY_KAK_TOKENS)) {
mOptions[RSK_SHUFFLE_100_GS_REWARD].SetContextIndex(1);
}
// Force 100 GS Shuffle if that's where Ganon's Boss Key is
if (mOptions[RSK_GANONS_BOSS_KEY].Is(RO_GANON_BOSS_KEY_KAK_TOKENS)) {
mOptions[RSK_SHUFFLE_100_GS_REWARD].SetContextIndex(1);
}

// If we only have MQ, set all dungeons to MQ
if (OTRGlobals::Instance->HasMasterQuest() && !OTRGlobals::Instance->HasOriginal()) {
mOptions[RSK_MQ_DUNGEON_RANDOM].SetContextIndex(RO_MQ_DUNGEONS_SET_NUMBER);
mOptions[RSK_MQ_DUNGEON_COUNT].SetContextIndex(12);
mOptions[RSK_MQ_DUNGEON_SET].SetContextIndex(RO_GENERIC_OFF);
}
// If we only have MQ, set all dungeons to MQ
if (OTRGlobals::Instance->HasMasterQuest() && !OTRGlobals::Instance->HasOriginal()) {
mOptions[RSK_MQ_DUNGEON_RANDOM].SetContextIndex(RO_MQ_DUNGEONS_SET_NUMBER);
mOptions[RSK_MQ_DUNGEON_COUNT].SetContextIndex(12);
mOptions[RSK_MQ_DUNGEON_SET].SetContextIndex(RO_GENERIC_OFF);
}

// If we don't have MQ, set all dungeons to Vanilla
if (OTRGlobals::Instance->HasOriginal() && !OTRGlobals::Instance->HasMasterQuest()) {
mOptions[RSK_MQ_DUNGEON_RANDOM].SetContextIndex(RO_MQ_DUNGEONS_NONE);
}
// If we don't have MQ, set all dungeons to Vanilla
if (OTRGlobals::Instance->HasOriginal() && !OTRGlobals::Instance->HasMasterQuest()) {
mOptions[RSK_MQ_DUNGEON_RANDOM].SetContextIndex(RO_MQ_DUNGEONS_NONE);
}

if (mOptions[RSK_MQ_DUNGEON_RANDOM].Is(RO_MQ_DUNGEONS_NONE)) {
mOptions[RSK_MQ_DUNGEON_COUNT].SetContextIndex(0);
mOptions[RSK_MQ_DUNGEON_SET].SetContextIndex(RO_GENERIC_OFF);
}
if (mOptions[RSK_MQ_DUNGEON_RANDOM].Is(RO_MQ_DUNGEONS_NONE)) {
mOptions[RSK_MQ_DUNGEON_COUNT].SetContextIndex(0);
mOptions[RSK_MQ_DUNGEON_SET].SetContextIndex(RO_GENERIC_OFF);
}

// If any of the individual shuffle settings are on, turn on the main Shuffle Entrances option
if (mOptions[RSK_SHUFFLE_DUNGEON_ENTRANCES].IsNot(RO_DUNGEON_ENTRANCE_SHUFFLE_OFF)
|| mOptions[RSK_SHUFFLE_BOSS_ENTRANCES].IsNot(RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF)
|| mOptions[RSK_SHUFFLE_OVERWORLD_ENTRANCES]
|| mOptions[RSK_SHUFFLE_INTERIOR_ENTRANCES].IsNot(RO_INTERIOR_ENTRANCE_SHUFFLE_OFF)
|| mOptions[RSK_SHUFFLE_GROTTO_ENTRANCES] || mOptions[RSK_SHUFFLE_OWL_DROPS]
|| mOptions[RSK_SHUFFLE_WARP_SONGS] || mOptions[RSK_SHUFFLE_OVERWORLD_SPAWNS]) {
mOptions[RSK_SHUFFLE_ENTRANCES].SetContextIndex(RO_GENERIC_ON);
} else {
mOptions[RSK_SHUFFLE_ENTRANCES].SetContextIndex(RO_GENERIC_OFF);
}
// If any of the individual shuffle settings are on, turn on the main Shuffle Entrances option
if (mOptions[RSK_SHUFFLE_DUNGEON_ENTRANCES].IsNot(RO_DUNGEON_ENTRANCE_SHUFFLE_OFF)
|| mOptions[RSK_SHUFFLE_BOSS_ENTRANCES].IsNot(RO_BOSS_ROOM_ENTRANCE_SHUFFLE_OFF)
|| mOptions[RSK_SHUFFLE_OVERWORLD_ENTRANCES]
|| mOptions[RSK_SHUFFLE_INTERIOR_ENTRANCES].IsNot(RO_INTERIOR_ENTRANCE_SHUFFLE_OFF)
|| mOptions[RSK_SHUFFLE_GROTTO_ENTRANCES] || mOptions[RSK_SHUFFLE_OWL_DROPS]
|| mOptions[RSK_SHUFFLE_WARP_SONGS] || mOptions[RSK_SHUFFLE_OVERWORLD_SPAWNS]) {
mOptions[RSK_SHUFFLE_ENTRANCES].SetContextIndex(RO_GENERIC_ON);
} else {
mOptions[RSK_SHUFFLE_ENTRANCES].SetContextIndex(RO_GENERIC_OFF);
}

if (mOptions[RSK_SHUFFLE_DUNGEON_REWARDS].Is(RO_DUNGEON_REWARDS_END_OF_DUNGEON)) {
mOptions[RSK_LINKS_POCKET].SetContextIndex(RO_LINKS_POCKET_DUNGEON_REWARD);
}
if (mOptions[RSK_SHUFFLE_DUNGEON_REWARDS].Is(RO_DUNGEON_REWARDS_END_OF_DUNGEON)) {
mOptions[RSK_LINKS_POCKET].SetContextIndex(RO_LINKS_POCKET_DUNGEON_REWARD);
}

if (!ctx->IsSpoilerLoaded()) {
ctx->AddExcludedOptions();
for (const auto locationKey : ctx->everyPossibleLocation) {
if (const auto location = ctx->GetItemLocation(locationKey); excludedLocations.contains(location->GetRandomizerCheck())) {
location->GetExcludedOption()->SetContextIndex(1);
} else {
location->GetExcludedOption()->SetContextIndex(0);
}
}
// Tricks
ResetTrickOptions();
for (const auto randomizerTrick : enabledTricks) {
mTrickOptions[randomizerTrick].SetContextIndex(1);
}
ctx->AddExcludedOptions();
for (const auto locationKey : ctx->everyPossibleLocation) {
if (const auto location = ctx->GetItemLocation(locationKey); excludedLocations.contains(location->GetRandomizerCheck())) {
location->GetExcludedOption()->SetContextIndex(1);
} else {
location->GetExcludedOption()->SetContextIndex(0);
}
if (!mOptions[RSK_SHUFFLE_KOKIRI_SWORD]) {
if (mOptions[RSK_STARTING_KOKIRI_SWORD]) {
ctx->GetItemLocation(RC_KF_KOKIRI_SWORD_CHEST)->GetExcludedOption()->SetContextIndex(1);
}
}
// Tricks
ResetTrickOptions();
for (const auto randomizerTrick : enabledTricks) {
mTrickOptions[randomizerTrick].SetContextIndex(1);
}
if (!mOptions[RSK_SHUFFLE_KOKIRI_SWORD]) {
if (mOptions[RSK_STARTING_KOKIRI_SWORD]) {
ctx->GetItemLocation(RC_KF_KOKIRI_SWORD_CHEST)->GetExcludedOption()->SetContextIndex(1);
}
if (!mOptions[RSK_SHUFFLE_MASTER_SWORD]) {
if (mOptions[RSK_STARTING_MASTER_SWORD]) {
ctx->GetItemLocation(RC_MASTER_SWORD_PEDESTAL)->GetExcludedOption()->SetContextIndex(1);
}
}
if (!mOptions[RSK_SHUFFLE_MASTER_SWORD]) {
if (mOptions[RSK_STARTING_MASTER_SWORD]) {
ctx->GetItemLocation(RC_MASTER_SWORD_PEDESTAL)->GetExcludedOption()->SetContextIndex(1);
}
if (!mOptions[RSK_SHUFFLE_OCARINA]) {
if (mOptions[RSK_STARTING_OCARINA].IsNot(RO_STARTING_OCARINA_OFF)) {
ctx->GetItemLocation(RC_LW_GIFT_FROM_SARIA)->GetExcludedOption()->SetContextIndex(1);
if (mOptions[RSK_STARTING_OCARINA].Is(RO_STARTING_OCARINA_TIME)) {
ctx->GetItemLocation(RC_HF_OCARINA_OF_TIME_ITEM)->GetExcludedOption()->SetContextIndex(1);
}
}
if (!mOptions[RSK_SHUFFLE_OCARINA]) {
if (mOptions[RSK_STARTING_OCARINA].IsNot(RO_STARTING_OCARINA_OFF)) {
ctx->GetItemLocation(RC_LW_GIFT_FROM_SARIA)->GetExcludedOption()->SetContextIndex(1);
if (mOptions[RSK_STARTING_OCARINA].Is(RO_STARTING_OCARINA_TIME)) {
ctx->GetItemLocation(RC_HF_OCARINA_OF_TIME_ITEM)->GetExcludedOption()->SetContextIndex(1);
}
}
}


if (mOptions[RSK_SHUFFLE_DEKU_STICK_BAG]) {
mOptions[RSK_STARTING_STICKS].SetContextIndex(false);
Expand Down
2 changes: 2 additions & 0 deletions soh/soh/SaveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,8 @@ void SaveManager::Init() {
OTRGlobals::Instance->gRandoContext->ClearItemLocations();
}
}
auto ctx = Rando::Context::GetInstance();
ctx->GetSettings()->CreateOptions();
}

void SaveManager::InitMeta(int fileNum) {
Expand Down

0 comments on commit cb73830

Please sign in to comment.