Prevent empty randomizer blocks from triggering the rando version flow. (#5689)
Clear SpoilerLog CVar when unsupported spoiler log is discovered on load.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user