summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalkierian <malkierian@gmail.com>2025-07-21 22:19:04 -0700
committerGitHub <noreply@github.com>2025-07-21 22:19:04 -0700
commit35ad68578e6df5c51acd77546691c7ee98d14ac5 (patch)
tree8a128e55edfe9dc87c619ae9b377896fc61f0612
parent5066fbf82c541ce3bf861a52e9892f5a3719f59e (diff)
Prevent empty randomizer blocks from triggering the rando version flow. (#5689)
Clear SpoilerLog CVar when unsupported spoiler log is discovered on load.
-rw-r--r--soh/soh/Enhancements/randomizer/randomizer.cpp2
-rw-r--r--soh/soh/SaveManager.cpp10
2 files changed, 12 insertions, 0 deletions
diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp
index 581861158..ac1716fc3 100644
--- a/soh/soh/Enhancements/randomizer/randomizer.cpp
+++ b/soh/soh/Enhancements/randomizer/randomizer.cpp
@@ -406,6 +406,8 @@ bool Randomizer::SpoilerFileExists(const char* spoilerFileName) {
"The spoiler file located at\n" + std::string(spoilerFileName) +
"\nwas made by a version that doesn't match the currently running version.\n" +
"Loading for this file has been cancelled.");
+ CVarClear(CVAR_GENERAL("SpoilerLog"));
+ Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
}
// Update cache
diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp
index b62dbfee6..2e2f05f72 100644
--- a/soh/soh/SaveManager.cpp
+++ b/soh/soh/SaveManager.cpp
@@ -1111,6 +1111,7 @@ void SaveManager::LoadFile(int fileNum) {
std::ifstream input(fileName);
try {
+ bool deleteRando = false;
saveBlock = nlohmann::json::object();
input >> saveBlock;
if (!saveBlock.contains("version")) {
@@ -1122,6 +1123,10 @@ void SaveManager::LoadFile(int fileNum) {
for (auto& block : saveBlock["sections"].items()) {
std::string sectionName = block.key();
if (sectionName == "randomizer") {
+ if (block.value()["data"].empty()) {
+ deleteRando = true;
+ continue;
+ }
bool hasStats = saveBlock["sections"].contains("sohStats");
if (block.value()["data"].contains("aat0") || !hasStats) { // Rachael rando data
SohGui::RegisterPopup(
@@ -1201,6 +1206,11 @@ void SaveManager::LoadFile(int fileNum) {
assert(false);
break;
}
+ if (deleteRando) {
+ saveBlock["sections"].erase(saveBlock["sections"].find("randomizer"));
+ SaveFile(fileNum);
+ deleteRando = false;
+ }
InitMeta(fileNum);
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnLoadFile>(fileNum);
} catch (const std::exception& e) {