summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Leggett <chris@leggett.dev>2023-12-18 17:31:29 -0500
committerGitHub <noreply@github.com>2023-12-18 17:31:29 -0500
commitbb4fb221880801352f92eae89af23c931e085eba (patch)
treef2c3b2b39196a2ca1fc9aca8cfb61eea7fec0c6d
parent4978c3b34fbe820b47f36210b0c54f76d0bfccba (diff)
Fixes error noise when seed generation fails (#3527)
-rw-r--r--soh/soh/Enhancements/randomizer/3drando/menu.cpp35
-rw-r--r--soh/soh/Enhancements/randomizer/3drando/menu.hpp2
-rw-r--r--soh/soh/Enhancements/randomizer/3drando/rando_main.cpp3
3 files changed, 14 insertions, 26 deletions
diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp
index e01098c7d..adc0a9040 100644
--- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp
+++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp
@@ -21,28 +21,28 @@ std::vector<std::string> presetEntries;
Rando::Option* currentSetting;
} // namespace
-std::string GenerateRandomizer(std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks,
- std::string seedString) {
- auto ctx = Rando::Context::GetInstance();
+bool GenerateRandomizer(std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks,
+ std::string seedInput) {
+ const auto ctx = Rando::Context::GetInstance();
srand(time(NULL));
// if a blank seed was entered, make a random one
- if (seedString.empty()) {
- seedString = std::to_string(rand() % 0xFFFFFFFF);
- } else if (seedString.rfind("seed_testing_count", 0) == 0 && seedString.length() > 18) {
+ if (seedInput.empty()) {
+ seedInput = std::to_string(rand() % 0xFFFFFFFF);
+ } else if (seedInput.rfind("seed_testing_count", 0) == 0 && seedInput.length() > 18) {
int count;
try {
- count = std::stoi(seedString.substr(18), nullptr);
+ count = std::stoi(seedInput.substr(18), nullptr);
} catch (std::invalid_argument &e) {
count = 1;
} catch (std::out_of_range &e) {
count = 1;
}
Playthrough::Playthrough_Repeat(excludedLocations, enabledTricks, count);
- return "";
+ return false; // TODO: Not sure if this is correct but I don't think we support this functionality yet anyway.
}
- ctx->GetSettings()->SetSeedString(seedString);
+ ctx->GetSettings()->SetSeedString(seedInput);
uint32_t seedHash = boost::hash_32<std::string>{}(ctx->GetSettings()->GetSeedString());
ctx->GetSettings()->SetSeed(seedHash & 0xFFFFFFFF);
@@ -52,10 +52,10 @@ std::string GenerateRandomizer(std::set<RandomizerCheck> excludedLocations, std:
printf("\n\nFailed to generate after 5 tries.\nPress B to go back to the menu.\nA different seed might be "
"successful.");
SPDLOG_DEBUG("\nRANDOMIZATION FAILED COMPLETELY. PLZ FIX\n");//RANDOTODO print seed for reproduction purposes
- return "";
+ return false;
} else {
printf("\n\nError %d with fill.\nPress Select to exit or B to go back to the menu.\n", ret);
- return "";
+ return false;
}
}
@@ -66,16 +66,5 @@ std::string GenerateRandomizer(std::set<RandomizerCheck> excludedLocations, std:
}
ctx->GetOption(RSK_KEYSANITY).RestoreDelayedOption();
}
- std::ostringstream fileNameStream;
- for (int i = 0; i < ctx->hashIconIndexes.size(); i++) {
- if (i) {
- fileNameStream << '-';
- }
- if (ctx->hashIconIndexes[i] < 10) {
- fileNameStream << '0';
- }
- fileNameStream << std::to_string(ctx->hashIconIndexes[i]);
- }
- std::string fileName = fileNameStream.str();
- return "./Randomizer/" + fileName + ".json";
+ return true;
} \ No newline at end of file
diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.hpp b/soh/soh/Enhancements/randomizer/3drando/menu.hpp
index 77228e835..f9393d90e 100644
--- a/soh/soh/Enhancements/randomizer/3drando/menu.hpp
+++ b/soh/soh/Enhancements/randomizer/3drando/menu.hpp
@@ -25,4 +25,4 @@
// #define CYAN "\x1b[36m"
// #define WHITE "\x1b[37m"
-std::string GenerateRandomizer(std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks, std::string seedInput); \ No newline at end of file
+bool GenerateRandomizer(std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks, std::string seedInput); \ No newline at end of file
diff --git a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp
index 833a6fc42..0de9cd8e9 100644
--- a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp
+++ b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp
@@ -17,11 +17,10 @@ void RandoMain::GenerateRando(std::set<RandomizerCheck> excludedLocations, std::
// std::string settingsFileName = "./randomizer/latest_settings.json";
// CVarSetString("gLoadedPreset", settingsFileName.c_str());
- std::string fileName = LUS::Context::GetPathRelativeToAppDirectory(GenerateRandomizer(excludedLocations, enabledTricks, seedString).c_str());
+ Rando::Context::GetInstance()->SetSeedGenerated(GenerateRandomizer(excludedLocations, enabledTricks, seedString));
CVarSave();
CVarLoad();
- Rando::Context::GetInstance()->SetSeedGenerated();
Rando::Context::GetInstance()->SetSpoilerLoaded(false);
Rando::Context::GetInstance()->SetPlandoLoaded(false);
} \ No newline at end of file