From f8c5df85ad81a7732afe8f35998042d6959516bf Mon Sep 17 00:00:00 2001 From: Malkierian Date: Mon, 21 Jul 2025 23:44:42 -0700 Subject: [PATCH] Adds Sulu/Spock rando block check (data not empty, but all sub-entries null), and put that and data being empty to the old file flow. Also moves the `SaveFile` call to after everything else is loaded to preserve sohStats block. --- soh/soh/SaveManager.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 2e2f05f72..19ac67372 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -1121,25 +1121,22 @@ void SaveManager::LoadFile(int fileNum) { switch (saveBlock["version"].get()) { case 1: for (auto& block : saveBlock["sections"].items()) { + bool oldVanilla = block.value()["data"].empty() || block.value()["data"].contains("aat0") || + block.value()["data"]["entrances"].empty(); 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 + if (oldVanilla || !hasStats) { // Vanilla "rando" data SohGui::RegisterPopup( "Loading old file", "The file in slot " + std::to_string(fileNum + 1) + - " appears to contain randomizer data, but is a very old format.\n" + + " appears to contain randomizer data, but is a very old format or is empty.\n" + "The randomizer data has been removed, and this file will be treated as a vanilla " - "file.\n" + + "file.\nIf this was a vanilla file, it still is, and you shouldn't see this " + "message again.\n" + "If this was a randomizer file, the file will not work, and should be deleted."); - input.close(); - saveMtx.unlock(); - SaveFile(fileNum); - return; + deleteRando = true; + continue; } s16 major = saveBlock["sections"]["sohStats"]["data"]["buildVersionMajor"]; s16 minor = saveBlock["sections"]["sohStats"]["data"]["buildVersionMinor"]; @@ -1206,6 +1203,7 @@ void SaveManager::LoadFile(int fileNum) { assert(false); break; } + input.close(); if (deleteRando) { saveBlock["sections"].erase(saveBlock["sections"].find("randomizer")); SaveFile(fileNum);