Skip to content

Commit 35ad685

Browse files
authored
Prevent empty randomizer blocks from triggering the rando version flow. (#5689)
Clear SpoilerLog CVar when unsupported spoiler log is discovered on load.
1 parent 5066fbf commit 35ad685

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

soh/soh/Enhancements/randomizer/randomizer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ bool Randomizer::SpoilerFileExists(const char* spoilerFileName) {
406406
"The spoiler file located at\n" + std::string(spoilerFileName) +
407407
"\nwas made by a version that doesn't match the currently running version.\n" +
408408
"Loading for this file has been cancelled.");
409+
CVarClear(CVAR_GENERAL("SpoilerLog"));
410+
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
409411
}
410412

411413
// Update cache

soh/soh/SaveManager.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ void SaveManager::LoadFile(int fileNum) {
11111111
std::ifstream input(fileName);
11121112

11131113
try {
1114+
bool deleteRando = false;
11141115
saveBlock = nlohmann::json::object();
11151116
input >> saveBlock;
11161117
if (!saveBlock.contains("version")) {
@@ -1122,6 +1123,10 @@ void SaveManager::LoadFile(int fileNum) {
11221123
for (auto& block : saveBlock["sections"].items()) {
11231124
std::string sectionName = block.key();
11241125
if (sectionName == "randomizer") {
1126+
if (block.value()["data"].empty()) {
1127+
deleteRando = true;
1128+
continue;
1129+
}
11251130
bool hasStats = saveBlock["sections"].contains("sohStats");
11261131
if (block.value()["data"].contains("aat0") || !hasStats) { // Rachael rando data
11271132
SohGui::RegisterPopup(
@@ -1201,6 +1206,11 @@ void SaveManager::LoadFile(int fileNum) {
12011206
assert(false);
12021207
break;
12031208
}
1209+
if (deleteRando) {
1210+
saveBlock["sections"].erase(saveBlock["sections"].find("randomizer"));
1211+
SaveFile(fileNum);
1212+
deleteRando = false;
1213+
}
12041214
InitMeta(fileNum);
12051215
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnLoadFile>(fileNum);
12061216
} catch (const std::exception& e) {

0 commit comments

Comments
 (0)