Rando Versioning (Again) (#5691)

* 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.

* Add check for blank buildVersion in sohStats block for determining old saves.

* clang
This commit is contained in:
Malkierian 2025-07-23 20:45:22 -07:00 committed by GitHub
commit d51e88b972
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1121,25 +1121,24 @@ void SaveManager::LoadFile(int fileNum) {
switch (saveBlock["version"].get<int>()) { switch (saveBlock["version"].get<int>()) {
case 1: case 1:
for (auto& block : saveBlock["sections"].items()) { for (auto& block : saveBlock["sections"].items()) {
bool oldVanilla =
block.value()["data"].empty() || block.value()["data"].contains("aat0") ||
block.value()["data"]["entrances"].empty() ||
SohUtils::IsStringEmpty(saveBlock["sections"]["sohStats"]["data"]["buildVersion"]);
std::string sectionName = block.key(); std::string sectionName = block.key();
if (sectionName == "randomizer") { if (sectionName == "randomizer") {
if (block.value()["data"].empty()) {
deleteRando = true;
continue;
}
bool hasStats = saveBlock["sections"].contains("sohStats"); bool hasStats = saveBlock["sections"].contains("sohStats");
if (block.value()["data"].contains("aat0") || !hasStats) { // Rachael rando data if (oldVanilla || !hasStats) { // Vanilla "rando" data
SohGui::RegisterPopup( SohGui::RegisterPopup(
"Loading old file", "Loading old file",
"The file in slot " + std::to_string(fileNum + 1) + "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 " "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."); "If this was a randomizer file, the file will not work, and should be deleted.");
input.close(); deleteRando = true;
saveMtx.unlock(); continue;
SaveFile(fileNum);
return;
} }
s16 major = saveBlock["sections"]["sohStats"]["data"]["buildVersionMajor"]; s16 major = saveBlock["sections"]["sohStats"]["data"]["buildVersionMajor"];
s16 minor = saveBlock["sections"]["sohStats"]["data"]["buildVersionMinor"]; s16 minor = saveBlock["sections"]["sohStats"]["data"]["buildVersionMinor"];
@ -1206,6 +1205,7 @@ void SaveManager::LoadFile(int fileNum) {
assert(false); assert(false);
break; break;
} }
input.close();
if (deleteRando) { if (deleteRando) {
saveBlock["sections"].erase(saveBlock["sections"].find("randomizer")); saveBlock["sections"].erase(saveBlock["sections"].find("randomizer"));
SaveFile(fileNum); SaveFile(fileNum);