Formatting and whitespace cleanup.

This commit is contained in:
Malkierian 2023-05-13 18:29:05 -07:00
parent 7861b4c092
commit 374301db9b
2 changed files with 215 additions and 221 deletions

View File

@ -196,80 +196,79 @@ void LoadStatsVersion1() {
}); });
SaveManager::Instance->LoadData("playTimer", gSaveContext.sohStats.playTimer); SaveManager::Instance->LoadData("playTimer", gSaveContext.sohStats.playTimer);
SaveManager::Instance->LoadData("pauseTimer", gSaveContext.sohStats.pauseTimer); SaveManager::Instance->LoadData("pauseTimer", gSaveContext.sohStats.pauseTimer);
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("itemTimestamps", ARRAY_COUNT(gSaveContext.sohStats.itemTimestamp), [](size_t i) {
"itemTimestamps", ARRAY_COUNT(gSaveContext.sohStats.itemTimestamp), SaveManager::Instance->LoadData("", gSaveContext.sohStats.itemTimestamp[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.sohStats.itemTimestamp[i]); }); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("sceneTimestamps", ARRAY_COUNT(gSaveContext.sohStats.sceneTimestamps), [](size_t i) {
"sceneTimestamps", ARRAY_COUNT(gSaveContext.sohStats.sceneTimestamps), [](size_t i) { SaveManager::Instance->LoadStruct("", [&i]() {
SaveManager::Instance->LoadStruct("", [&i]() { int scene, room, sceneTime, roomTime, isRoom;
int scene, room, sceneTime, roomTime, isRoom; SaveManager::Instance->LoadData("scene", scene);
SaveManager::Instance->LoadData("scene", scene); SaveManager::Instance->LoadData("room", room);
SaveManager::Instance->LoadData("room", room); SaveManager::Instance->LoadData("sceneTime", sceneTime);
SaveManager::Instance->LoadData("sceneTime", sceneTime); SaveManager::Instance->LoadData("roomTime", roomTime);
SaveManager::Instance->LoadData("roomTime", roomTime); SaveManager::Instance->LoadData("isRoom", isRoom);
SaveManager::Instance->LoadData("isRoom", isRoom); if (scene == 0 && room == 0 && sceneTime == 0 && roomTime == 0 && isRoom == 0) {
if (scene == 0 && room == 0 && sceneTime == 0 && roomTime == 0 && isRoom == 0) { return;
return; }
} gSaveContext.sohStats.sceneTimestamps[i].scene = scene;
gSaveContext.sohStats.sceneTimestamps[i].scene = scene; gSaveContext.sohStats.sceneTimestamps[i].room = room;
gSaveContext.sohStats.sceneTimestamps[i].room = room; gSaveContext.sohStats.sceneTimestamps[i].sceneTime = sceneTime;
gSaveContext.sohStats.sceneTimestamps[i].sceneTime = sceneTime; gSaveContext.sohStats.sceneTimestamps[i].roomTime = roomTime;
gSaveContext.sohStats.sceneTimestamps[i].roomTime = roomTime; gSaveContext.sohStats.sceneTimestamps[i].isRoom = isRoom;
gSaveContext.sohStats.sceneTimestamps[i].isRoom = isRoom;
});
}); });
});
SaveManager::Instance->LoadData("tsIdx", gSaveContext.sohStats.tsIdx); SaveManager::Instance->LoadData("tsIdx", gSaveContext.sohStats.tsIdx);
SaveManager::Instance->LoadArray("counts", ARRAY_COUNT(gSaveContext.sohStats.count), [](size_t i) { SaveManager::Instance->LoadArray("counts", ARRAY_COUNT(gSaveContext.sohStats.count), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.sohStats.count[i]); SaveManager::Instance->LoadData("", gSaveContext.sohStats.count[i]);
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("scenesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.scenesDiscovered), [](size_t i) {
"scenesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.scenesDiscovered), SaveManager::Instance->LoadData("", gSaveContext.sohStats.scenesDiscovered[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.sohStats.scenesDiscovered[i]); }); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("entrancesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.entrancesDiscovered), [](size_t i) {
"entrancesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.entrancesDiscovered), SaveManager::Instance->LoadData("", gSaveContext.sohStats.entrancesDiscovered[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.sohStats.entrancesDiscovered[i]); }); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("locationsSkipped", ARRAY_COUNT(gSaveContext.sohStats.locationsSkipped), [](size_t i) {
"locationsSkipped", ARRAY_COUNT(gSaveContext.sohStats.locationsSkipped), SaveManager::Instance->LoadData("", gSaveContext.sohStats.locationsSkipped[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.sohStats.locationsSkipped[i]); }); });
} }
void SaveStats(SaveContext* saveContext, const std::string& subSection) { void SaveStats(SaveContext* saveContext, const std::string& subSection) {
if (subSection == "all") { if (subSection == "all") {
SaveManager::Instance->SaveData("buildVersion", saveContext->sohStats.buildVersion); std::string buildVersion;
SaveManager::Instance->SaveData("buildVersionMajor", saveContext->sohStats.buildVersionMajor); SaveManager::Instance->LoadData("buildVersion", buildVersion);
SaveManager::Instance->SaveData("buildVersionMinor", saveContext->sohStats.buildVersionMinor); strncpy(gSaveContext.sohStats.buildVersion, buildVersion.c_str(),
SaveManager::Instance->SaveData("buildVersionPatch", saveContext->sohStats.buildVersionPatch); ARRAY_COUNT(gSaveContext.sohStats.buildVersion) - 1);
gSaveContext.sohStats.buildVersion[ARRAY_COUNT(gSaveContext.sohStats.buildVersion) - 1] = 0;
SaveManager::Instance->LoadData("buildVersionMajor", gSaveContext.sohStats.buildVersionMajor);
SaveManager::Instance->LoadData("buildVersionMinor", gSaveContext.sohStats.buildVersionMinor);
SaveManager::Instance->LoadData("buildVersionPatch", gSaveContext.sohStats.buildVersionPatch);
SaveManager::Instance->SaveData("heartPieces", saveContext->sohStats.heartPieces); SaveManager::Instance->LoadData("heartPieces", gSaveContext.sohStats.heartPieces);
SaveManager::Instance->SaveData("heartContainers", saveContext->sohStats.heartContainers); SaveManager::Instance->LoadData("heartContainers", gSaveContext.sohStats.heartContainers);
SaveManager::Instance->SaveArray("dungeonKeys", ARRAY_COUNT(saveContext->sohStats.dungeonKeys), [&](size_t i) { SaveManager::Instance->LoadArray("dungeonKeys", ARRAY_COUNT(gSaveContext.sohStats.dungeonKeys), [](size_t i) {
SaveManager::Instance->SaveData("", saveContext->sohStats.dungeonKeys[i]); SaveManager::Instance->LoadData("", gSaveContext.sohStats.dungeonKeys[i]);
}); });
SaveManager::Instance->SaveData("playTimer", saveContext->sohStats.playTimer); SaveManager::Instance->LoadData("playTimer", gSaveContext.sohStats.playTimer);
SaveManager::Instance->SaveData("pauseTimer", saveContext->sohStats.pauseTimer); SaveManager::Instance->LoadData("pauseTimer", gSaveContext.sohStats.pauseTimer);
SaveManager::Instance->SaveArray( SaveManager::Instance->LoadArray("itemTimestamps", ARRAY_COUNT(gSaveContext.sohStats.itemTimestamp), [](size_t i) {
"itemTimestamps", ARRAY_COUNT(saveContext->sohStats.itemTimestamp), SaveManager::Instance->LoadData("", gSaveContext.sohStats.itemTimestamp[i]);
[&](size_t i) { SaveManager::Instance->SaveData("", saveContext->sohStats.itemTimestamp[i]); }); });
SaveManager::Instance->SaveArray( SaveManager::Instance->LoadArray("sceneTimestamps", ARRAY_COUNT(gSaveContext.sohStats.sceneTimestamps), [](size_t i) {
"sceneTimestamps", ARRAY_COUNT(saveContext->sohStats.sceneTimestamps), [&](size_t i) { SaveManager::Instance->LoadStruct("", [&i]() {
if (saveContext->sohStats.sceneTimestamps[i].scene != 254 && SaveManager::Instance->LoadData("scene", gSaveContext.sohStats.sceneTimestamps[i].scene);
saveContext->sohStats.sceneTimestamps[i].room != 254) { SaveManager::Instance->LoadData("room", gSaveContext.sohStats.sceneTimestamps[i].room);
SaveManager::Instance->SaveStruct("", [&]() { SaveManager::Instance->LoadData("sceneTime", gSaveContext.sohStats.sceneTimestamps[i].sceneTime);
SaveManager::Instance->SaveData("scene", saveContext->sohStats.sceneTimestamps[i].scene); SaveManager::Instance->LoadData("roomTime", gSaveContext.sohStats.sceneTimestamps[i].roomTime);
SaveManager::Instance->SaveData("room", saveContext->sohStats.sceneTimestamps[i].room); SaveManager::Instance->LoadData("isRoom", gSaveContext.sohStats.sceneTimestamps[i].isRoom);
SaveManager::Instance->SaveData("sceneTime", saveContext->sohStats.sceneTimestamps[i].sceneTime);
SaveManager::Instance->SaveData("roomTime", saveContext->sohStats.sceneTimestamps[i].roomTime);
SaveManager::Instance->SaveData("isRoom", saveContext->sohStats.sceneTimestamps[i].isRoom);
});
}
}); });
SaveManager::Instance->SaveData("tsIdx", saveContext->sohStats.tsIdx);
SaveManager::Instance->SaveArray("counts", ARRAY_COUNT(saveContext->sohStats.count), [&](size_t i) {
SaveManager::Instance->SaveData("", saveContext->sohStats.count[i]);
}); });
SaveManager::Instance->SaveArray( SaveManager::Instance->LoadData("tsIdx", gSaveContext.sohStats.tsIdx);
"locationsSkipped", ARRAY_COUNT(saveContext->sohStats.locationsSkipped), SaveManager::Instance->LoadArray("counts", ARRAY_COUNT(gSaveContext.sohStats.count), [](size_t i) {
[&](size_t i) { SaveManager::Instance->SaveData("", saveContext->sohStats.locationsSkipped[i]); }); SaveManager::Instance->LoadData("", gSaveContext.sohStats.count[i]);
});
SaveManager::Instance->LoadArray("locationsSkipped", ARRAY_COUNT(gSaveContext.sohStats.locationsSkipped), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.sohStats.locationsSkipped[i]);
});
} }
if (subSection == "entrances" || subSection == "all") { if (subSection == "entrances" || subSection == "all") {
SaveManager::Instance->SaveArray("entrancesDiscovered", ARRAY_COUNT(saveContext->sohStats.entrancesDiscovered), [&](size_t i) { SaveManager::Instance->SaveArray("entrancesDiscovered", ARRAY_COUNT(saveContext->sohStats.entrancesDiscovered), [&](size_t i) {

View File

@ -124,8 +124,7 @@ void SaveManager::LoadRandomizerVersion1() {
for (int i = 0; i < ARRAY_COUNT(gSaveContext.hintLocations); i++) { for (int i = 0; i < ARRAY_COUNT(gSaveContext.hintLocations); i++) {
SaveManager::Instance->LoadData("hc" + std::to_string(i), gSaveContext.hintLocations[i].check); SaveManager::Instance->LoadData("hc" + std::to_string(i), gSaveContext.hintLocations[i].check);
for (int j = 0; j < ARRAY_COUNT(gSaveContext.hintLocations[i].hintText); j++) { for (int j = 0; j < ARRAY_COUNT(gSaveContext.hintLocations[i].hintText); j++) {
SaveManager::Instance->LoadData("ht" + std::to_string(i) + "-" + std::to_string(j), SaveManager::Instance->LoadData("ht" + std::to_string(i) + "-" + std::to_string(j), gSaveContext.hintLocations[i].hintText[j]);
gSaveContext.hintLocations[i].hintText[j]);
} }
} }
@ -189,13 +188,13 @@ void SaveManager::LoadRandomizerVersion2() {
SaveManager::Instance->LoadData("destination", gSaveContext.entranceOverrides[i].destination); SaveManager::Instance->LoadData("destination", gSaveContext.entranceOverrides[i].destination);
SaveManager::Instance->LoadData("blueWarp", gSaveContext.entranceOverrides[i].blueWarp); SaveManager::Instance->LoadData("blueWarp", gSaveContext.entranceOverrides[i].blueWarp);
SaveManager::Instance->LoadData("override", gSaveContext.entranceOverrides[i].override); SaveManager::Instance->LoadData("override", gSaveContext.entranceOverrides[i].override);
SaveManager::Instance->LoadData("overrideDestination", SaveManager::Instance->LoadData("overrideDestination", gSaveContext.entranceOverrides[i].overrideDestination);
gSaveContext.entranceOverrides[i].overrideDestination);
}); });
}); });
SaveManager::Instance->LoadArray("seed", ARRAY_COUNT(gSaveContext.seedIcons), SaveManager::Instance->LoadArray("seed", ARRAY_COUNT(gSaveContext.seedIcons), [&](size_t i) {
[&](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.seedIcons[i]); }); SaveManager::Instance->LoadData("", gSaveContext.seedIcons[i]);
});
SaveManager::Instance->LoadArray("randoSettings", RSK_MAX, [&](size_t i) { SaveManager::Instance->LoadArray("randoSettings", RSK_MAX, [&](size_t i) {
gSaveContext.randoSettings[i].key = RandomizerSettingKey(i); gSaveContext.randoSettings[i].key = RandomizerSettingKey(i);
@ -281,8 +280,7 @@ void SaveManager::LoadRandomizerVersion2() {
void SaveManager::SaveRandomizer(SaveContext* saveContext, const std::string& subString) { void SaveManager::SaveRandomizer(SaveContext* saveContext, const std::string& subString) {
if (!saveContext->n64ddFlag) if (!saveContext->n64ddFlag) return;
return;
SaveManager::Instance->SaveArray("itemLocations", RC_MAX, [&](size_t i) { SaveManager::Instance->SaveArray("itemLocations", RC_MAX, [&](size_t i) {
SaveManager::Instance->SaveStruct("", [&]() { SaveManager::Instance->SaveStruct("", [&]() {
@ -298,13 +296,13 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext, const std::string& su
SaveManager::Instance->SaveData("destination", saveContext->entranceOverrides[i].destination); SaveManager::Instance->SaveData("destination", saveContext->entranceOverrides[i].destination);
SaveManager::Instance->SaveData("blueWarp", saveContext->entranceOverrides[i].blueWarp); SaveManager::Instance->SaveData("blueWarp", saveContext->entranceOverrides[i].blueWarp);
SaveManager::Instance->SaveData("override", saveContext->entranceOverrides[i].override); SaveManager::Instance->SaveData("override", saveContext->entranceOverrides[i].override);
SaveManager::Instance->SaveData("overrideDestination", SaveManager::Instance->SaveData("overrideDestination", saveContext->entranceOverrides[i].overrideDestination);
saveContext->entranceOverrides[i].overrideDestination);
}); });
}); });
SaveManager::Instance->SaveArray("seed", ARRAY_COUNT(saveContext->seedIcons), SaveManager::Instance->SaveArray("seed", ARRAY_COUNT(saveContext->seedIcons), [&](size_t i) {
[&](size_t i) { SaveManager::Instance->SaveData("", saveContext->seedIcons[i]); }); SaveManager::Instance->SaveData("", saveContext->seedIcons[i]);
});
SaveManager::Instance->SaveArray("randoSettings", RSK_MAX, [&](size_t i) { SaveManager::Instance->SaveArray("randoSettings", RSK_MAX, [&](size_t i) {
SaveManager::Instance->SaveData("", saveContext->randoSettings[i].value); SaveManager::Instance->SaveData("", saveContext->randoSettings[i].value);
@ -337,7 +335,7 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext, const std::string& su
std::shared_ptr<Randomizer> randomizer = OTRGlobals::Instance->gRandomizer; std::shared_ptr<Randomizer> randomizer = OTRGlobals::Instance->gRandomizer;
std::vector<std::pair<RandomizerCheck, u16>> merchantPrices; std::vector<std::pair<RandomizerCheck, u16>> merchantPrices;
for (const auto& [check, price] : randomizer->merchantPrices) { for (const auto& [ check, price ] : randomizer->merchantPrices) {
merchantPrices.push_back(std::make_pair(check, price)); merchantPrices.push_back(std::make_pair(check, price));
} }
@ -355,8 +353,9 @@ void SaveManager::SaveRandomizer(SaveContext* saveContext, const std::string& su
for (const auto scene : randomizer->masterQuestDungeons) { for (const auto scene : randomizer->masterQuestDungeons) {
masterQuestDungeons.push_back(scene); masterQuestDungeons.push_back(scene);
} }
SaveManager::Instance->SaveArray("masterQuestDungeons", masterQuestDungeons.size(), SaveManager::Instance->SaveArray("masterQuestDungeons", masterQuestDungeons.size(), [&](size_t i) {
[&](size_t i) { SaveManager::Instance->SaveData("", masterQuestDungeons[i]); }); SaveManager::Instance->SaveData("", masterQuestDungeons[i]);
});
} }
void SaveManager::Init() { void SaveManager::Init() {
@ -436,18 +435,15 @@ void SaveManager::InitMeta(int fileNum) {
fileMetaInfo[fileNum].randoSave = gSaveContext.n64ddFlag; fileMetaInfo[fileNum].randoSave = gSaveContext.n64ddFlag;
// If the file is marked as a Master Quest file or if we're randomized and have at least one master quest dungeon, // If the file is marked as a Master Quest file or if we're randomized and have at least one master quest dungeon,
// we need the mq otr. // we need the mq otr.
fileMetaInfo[fileNum].requiresMasterQuest = fileMetaInfo[fileNum].requiresMasterQuest = gSaveContext.isMasterQuest > 0 || (gSaveContext.n64ddFlag && gSaveContext.mqDungeonCount > 0);
gSaveContext.isMasterQuest > 0 || (gSaveContext.n64ddFlag && gSaveContext.mqDungeonCount > 0);
// If the file is not marked as Master Quest, it could still theoretically be a rando save with all 12 MQ dungeons, // If the file is not marked as Master Quest, it could still theoretically be a rando save with all 12 MQ dungeons,
// in which case we don't actually require a vanilla OTR. // in which case we don't actually require a vanilla OTR.
fileMetaInfo[fileNum].requiresOriginal = fileMetaInfo[fileNum].requiresOriginal = !gSaveContext.isMasterQuest && (!gSaveContext.n64ddFlag || gSaveContext.mqDungeonCount < 12);
!gSaveContext.isMasterQuest && (!gSaveContext.n64ddFlag || gSaveContext.mqDungeonCount < 12);
fileMetaInfo[fileNum].buildVersionMajor = gSaveContext.sohStats.buildVersionMajor; fileMetaInfo[fileNum].buildVersionMajor = gSaveContext.sohStats.buildVersionMajor;
fileMetaInfo[fileNum].buildVersionMinor = gSaveContext.sohStats.buildVersionMinor; fileMetaInfo[fileNum].buildVersionMinor = gSaveContext.sohStats.buildVersionMinor;
fileMetaInfo[fileNum].buildVersionPatch = gSaveContext.sohStats.buildVersionPatch; fileMetaInfo[fileNum].buildVersionPatch = gSaveContext.sohStats.buildVersionPatch;
strncpy(fileMetaInfo[fileNum].buildVersion, gSaveContext.sohStats.buildVersion, strncpy(fileMetaInfo[fileNum].buildVersion, gSaveContext.sohStats.buildVersion, sizeof(fileMetaInfo[fileNum].buildVersion) - 1);
sizeof(fileMetaInfo[fileNum].buildVersion) - 1);
fileMetaInfo[fileNum].buildVersion[sizeof(fileMetaInfo[fileNum].buildVersion) - 1] = 0; fileMetaInfo[fileNum].buildVersion[sizeof(fileMetaInfo[fileNum].buildVersion) - 1] = 0;
} }
@ -598,7 +594,7 @@ void SaveManager::InitFileNormal() {
gSaveContext.pendingSale = ITEM_NONE; gSaveContext.pendingSale = ITEM_NONE;
gSaveContext.pendingSaleMod = MOD_NONE; gSaveContext.pendingSaleMod = MOD_NONE;
// RANDOTODO (ADD ITEMLOCATIONS TO GSAVECONTEXT) //RANDOTODO (ADD ITEMLOCATIONS TO GSAVECONTEXT)
} }
void SaveManager::InitFileDebug() { void SaveManager::InitFileDebug() {
@ -643,13 +639,11 @@ void SaveManager::InitFileDebug() {
gSaveContext.savedSceneNum = 0x51; gSaveContext.savedSceneNum = 0x51;
// Equipment // Equipment
static std::array<u8, 8> sButtonItems = { ITEM_SWORD_MASTER, ITEM_BOW, ITEM_BOMB, ITEM_OCARINA_FAIRY, static std::array<u8, 8> sButtonItems = { ITEM_SWORD_MASTER, ITEM_BOW, ITEM_BOMB, ITEM_OCARINA_FAIRY, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE };
ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE };
for (int button = 0; button < ARRAY_COUNT(gSaveContext.equips.buttonItems); button++) { for (int button = 0; button < ARRAY_COUNT(gSaveContext.equips.buttonItems); button++) {
gSaveContext.equips.buttonItems[button] = sButtonItems[button]; gSaveContext.equips.buttonItems[button] = sButtonItems[button];
} }
static std::array<u8, 7> sCButtonSlots = { SLOT_BOW, SLOT_BOMB, SLOT_OCARINA, SLOT_NONE, static std::array<u8, 7> sCButtonSlots = { SLOT_BOW, SLOT_BOMB, SLOT_OCARINA, SLOT_NONE, SLOT_NONE, SLOT_NONE, SLOT_NONE };
SLOT_NONE, SLOT_NONE, SLOT_NONE };
for (int button = 0; button < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); button++) { for (int button = 0; button < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); button++) {
gSaveContext.equips.cButtonSlots[button] = sCButtonSlots[button]; gSaveContext.equips.cButtonSlots[button] = sCButtonSlots[button];
} }
@ -806,15 +800,14 @@ void SaveManager::LoadFile(int fileNum) {
if (!sectionLoadHandlers.contains(sectionName)) { if (!sectionLoadHandlers.contains(sectionName)) {
// Unloadable sections aren't necessarily errors, they are probably mods that were unloaded // Unloadable sections aren't necessarily errors, they are probably mods that were unloaded
// TODO report in a more noticeable manner // TODO report in a more noticeable manner
SPDLOG_WARN("Save " + GetFileName(fileNum).string() + " contains unloadable section " + SPDLOG_WARN("Save " + GetFileName(fileNum).string() + " contains unloadable section " + sectionName);
sectionName);
continue; continue;
} }
SectionLoadHandler& handler = sectionLoadHandlers[sectionName]; SectionLoadHandler& handler = sectionLoadHandlers[sectionName];
if (!handler.contains(sectionVersion)) { if (!handler.contains(sectionVersion)) {
// A section that has a loader without a handler for the specific version means that the user has a // A section that has a loader without a handler for the specific version means that the user has a mod
// mod at an earlier version than the save has. In this case, the user probably wants to load the // at an earlier version than the save has. In this case, the user probably wants to load the save.
// save. Report the error so that the user can rectify the error. // Report the error so that the user can rectify the error.
// TODO report in a more noticeable manner // TODO report in a more noticeable manner
SPDLOG_ERROR("Save " + GetFileName(fileNum).string() + " contains section " + sectionName + SPDLOG_ERROR("Save " + GetFileName(fileNum).string() + " contains section " + sectionName +
" with an unloadable version " + std::to_string(sectionVersion)); " with an unloadable version " + std::to_string(sectionVersion));
@ -844,7 +837,8 @@ bool SaveManager::SaveFile_Exist(int fileNum) {
bool exists = std::filesystem::exists(GetFileName(fileNum)); bool exists = std::filesystem::exists(GetFileName(fileNum));
SPDLOG_INFO("File[{}] - {}", fileNum, exists ? "exists" : "does not exist"); SPDLOG_INFO("File[{}] - {}", fileNum, exists ? "exists" : "does not exist");
return exists; return exists;
} catch (std::filesystem::filesystem_error const& ex) { }
catch (std::filesystem::filesystem_error const& ex) {
SPDLOG_ERROR("Filesystem error"); SPDLOG_ERROR("Filesystem error");
return false; return false;
} }
@ -860,8 +854,7 @@ void SaveManager::AddLoadFunction(const std::string& name, int version, LoadFunc
} }
if (sectionLoadHandlers[name].contains(version)) { if (sectionLoadHandlers[name].contains(version)) {
SPDLOG_ERROR("Adding load function for section and version that already has one: " + name + ", " + SPDLOG_ERROR("Adding load function for section and version that already has one: " + name + ", " + std::to_string(version));
std::to_string(version));
assert(false); assert(false);
return; return;
} }
@ -906,8 +899,9 @@ void SaveManager::LoadBaseVersion1() {
SaveManager::Instance->LoadData("totalDays", gSaveContext.totalDays); SaveManager::Instance->LoadData("totalDays", gSaveContext.totalDays);
SaveManager::Instance->LoadData("bgsDayCount", gSaveContext.bgsDayCount); SaveManager::Instance->LoadData("bgsDayCount", gSaveContext.bgsDayCount);
SaveManager::Instance->LoadData("deaths", gSaveContext.deaths); SaveManager::Instance->LoadData("deaths", gSaveContext.deaths);
SaveManager::Instance->LoadArray("playerName", ARRAY_COUNT(gSaveContext.playerName), SaveManager::Instance->LoadArray("playerName", ARRAY_COUNT(gSaveContext.playerName), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.playerName[i]); }); SaveManager::Instance->LoadData("", gSaveContext.playerName[i]);
});
SaveManager::Instance->LoadData("n64ddFlag", gSaveContext.n64ddFlag); SaveManager::Instance->LoadData("n64ddFlag", gSaveContext.n64ddFlag);
SaveManager::Instance->LoadData("healthCapacity", gSaveContext.healthCapacity); SaveManager::Instance->LoadData("healthCapacity", gSaveContext.healthCapacity);
SaveManager::Instance->LoadData("health", gSaveContext.health); SaveManager::Instance->LoadData("health", gSaveContext.health);
@ -922,29 +916,25 @@ void SaveManager::LoadBaseVersion1() {
SaveManager::Instance->LoadData("bgsFlag", gSaveContext.bgsFlag); SaveManager::Instance->LoadData("bgsFlag", gSaveContext.bgsFlag);
SaveManager::Instance->LoadData("ocarinaGameRoundNum", gSaveContext.ocarinaGameRoundNum); SaveManager::Instance->LoadData("ocarinaGameRoundNum", gSaveContext.ocarinaGameRoundNum);
SaveManager::Instance->LoadStruct("childEquips", []() { SaveManager::Instance->LoadStruct("childEquips", []() {
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.childEquips.buttonItems), [](size_t i) {
"buttonItems", ARRAY_COUNT(gSaveContext.childEquips.buttonItems), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.childEquips.buttonItems[i], SaveManager::Instance->LoadData("", gSaveContext.childEquips.buttonItems[i],
static_cast<uint8_t>(ITEM_NONE)); static_cast<uint8_t>(ITEM_NONE));
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.childEquips.cButtonSlots), [](size_t i) {
"cButtonSlots", ARRAY_COUNT(gSaveContext.childEquips.cButtonSlots), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.childEquips.cButtonSlots[i], SaveManager::Instance->LoadData("", gSaveContext.childEquips.cButtonSlots[i],
static_cast<uint8_t>(SLOT_NONE)); static_cast<uint8_t>(SLOT_NONE));
}); });
SaveManager::Instance->LoadData("equipment", gSaveContext.childEquips.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.childEquips.equipment);
}); });
SaveManager::Instance->LoadStruct("adultEquips", []() { SaveManager::Instance->LoadStruct("adultEquips", []() {
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.adultEquips.buttonItems), [](size_t i) {
"buttonItems", ARRAY_COUNT(gSaveContext.adultEquips.buttonItems), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.adultEquips.buttonItems[i], SaveManager::Instance->LoadData("", gSaveContext.adultEquips.buttonItems[i],
static_cast<uint8_t>(ITEM_NONE)); static_cast<uint8_t>(ITEM_NONE));
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.adultEquips.cButtonSlots), [](size_t i) {
"cButtonSlots", ARRAY_COUNT(gSaveContext.adultEquips.cButtonSlots), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.adultEquips.cButtonSlots[i], SaveManager::Instance->LoadData("", gSaveContext.adultEquips.cButtonSlots[i],
static_cast<uint8_t>(SLOT_NONE)); static_cast<uint8_t>(SLOT_NONE));
}); });
SaveManager::Instance->LoadData("equipment", gSaveContext.adultEquips.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.adultEquips.equipment);
}); });
SaveManager::Instance->LoadData("unk_54", gSaveContext.unk_54); SaveManager::Instance->LoadData("unk_54", gSaveContext.unk_54);
@ -968,8 +958,7 @@ void SaveManager::LoadBaseVersion1() {
SaveManager::Instance->LoadData("equipment", gSaveContext.inventory.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.inventory.equipment);
SaveManager::Instance->LoadData("upgrades", gSaveContext.inventory.upgrades); SaveManager::Instance->LoadData("upgrades", gSaveContext.inventory.upgrades);
SaveManager::Instance->LoadData("questItems", gSaveContext.inventory.questItems); SaveManager::Instance->LoadData("questItems", gSaveContext.inventory.questItems);
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("dungeonItems", ARRAY_COUNT(gSaveContext.inventory.dungeonItems),
"dungeonItems", ARRAY_COUNT(gSaveContext.inventory.dungeonItems),
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonItems[i]); }); [](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonItems[i]); });
SaveManager::Instance->LoadArray("dungeonKeys", ARRAY_COUNT(gSaveContext.inventory.dungeonKeys), [](size_t i) { SaveManager::Instance->LoadArray("dungeonKeys", ARRAY_COUNT(gSaveContext.inventory.dungeonKeys), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonKeys[i]); SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonKeys[i]);
@ -1002,17 +991,21 @@ void SaveManager::LoadBaseVersion1() {
SaveManager::Instance->LoadData("tempSwchFlags", gSaveContext.fw.tempSwchFlags); SaveManager::Instance->LoadData("tempSwchFlags", gSaveContext.fw.tempSwchFlags);
SaveManager::Instance->LoadData("tempCollectFlags", gSaveContext.fw.tempCollectFlags); SaveManager::Instance->LoadData("tempCollectFlags", gSaveContext.fw.tempCollectFlags);
}); });
SaveManager::Instance->LoadArray("gsFlags", ARRAY_COUNT(gSaveContext.gsFlags), SaveManager::Instance->LoadArray("gsFlags", ARRAY_COUNT(gSaveContext.gsFlags), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.gsFlags[i]); }); SaveManager::Instance->LoadData("", gSaveContext.gsFlags[i]);
SaveManager::Instance->LoadArray("highScores", ARRAY_COUNT(gSaveContext.highScores), });
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.highScores[i]); }); SaveManager::Instance->LoadArray("highScores", ARRAY_COUNT(gSaveContext.highScores), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.highScores[i]);
});
SaveManager::Instance->LoadArray("eventChkInf", ARRAY_COUNT(gSaveContext.eventChkInf), [](size_t i) { SaveManager::Instance->LoadArray("eventChkInf", ARRAY_COUNT(gSaveContext.eventChkInf), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.eventChkInf[i]); SaveManager::Instance->LoadData("", gSaveContext.eventChkInf[i]);
}); });
SaveManager::Instance->LoadArray("itemGetInf", ARRAY_COUNT(gSaveContext.itemGetInf), SaveManager::Instance->LoadArray("itemGetInf", ARRAY_COUNT(gSaveContext.itemGetInf), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.itemGetInf[i]); }); SaveManager::Instance->LoadData("", gSaveContext.itemGetInf[i]);
SaveManager::Instance->LoadArray("infTable", ARRAY_COUNT(gSaveContext.infTable), });
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.infTable[i]); }); SaveManager::Instance->LoadArray("infTable", ARRAY_COUNT(gSaveContext.infTable), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.infTable[i]);
});
SaveManager::Instance->LoadData("worldMapAreaData", gSaveContext.worldMapAreaData); SaveManager::Instance->LoadData("worldMapAreaData", gSaveContext.worldMapAreaData);
SaveManager::Instance->LoadData("scarecrowCustomSongSet", gSaveContext.scarecrowLongSongSet); SaveManager::Instance->LoadData("scarecrowCustomSongSet", gSaveContext.scarecrowLongSongSet);
SaveManager::Instance->LoadArray("scarecrowCustomSong", sizeof(gSaveContext.scarecrowLongSong), [](size_t i) { SaveManager::Instance->LoadArray("scarecrowCustomSong", sizeof(gSaveContext.scarecrowLongSong), [](size_t i) {
@ -1046,8 +1039,9 @@ void SaveManager::LoadBaseVersion2() {
SaveManager::Instance->LoadData("totalDays", gSaveContext.totalDays); SaveManager::Instance->LoadData("totalDays", gSaveContext.totalDays);
SaveManager::Instance->LoadData("bgsDayCount", gSaveContext.bgsDayCount); SaveManager::Instance->LoadData("bgsDayCount", gSaveContext.bgsDayCount);
SaveManager::Instance->LoadData("deaths", gSaveContext.deaths); SaveManager::Instance->LoadData("deaths", gSaveContext.deaths);
SaveManager::Instance->LoadArray("playerName", ARRAY_COUNT(gSaveContext.playerName), SaveManager::Instance->LoadArray("playerName", ARRAY_COUNT(gSaveContext.playerName), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.playerName[i]); }); SaveManager::Instance->LoadData("", gSaveContext.playerName[i]);
});
SaveManager::Instance->LoadData("n64ddFlag", gSaveContext.n64ddFlag); SaveManager::Instance->LoadData("n64ddFlag", gSaveContext.n64ddFlag);
SaveManager::Instance->LoadData("healthCapacity", gSaveContext.healthCapacity); SaveManager::Instance->LoadData("healthCapacity", gSaveContext.healthCapacity);
SaveManager::Instance->LoadData("health", gSaveContext.health); SaveManager::Instance->LoadData("health", gSaveContext.health);
@ -1062,29 +1056,25 @@ void SaveManager::LoadBaseVersion2() {
SaveManager::Instance->LoadData("bgsFlag", gSaveContext.bgsFlag); SaveManager::Instance->LoadData("bgsFlag", gSaveContext.bgsFlag);
SaveManager::Instance->LoadData("ocarinaGameRoundNum", gSaveContext.ocarinaGameRoundNum); SaveManager::Instance->LoadData("ocarinaGameRoundNum", gSaveContext.ocarinaGameRoundNum);
SaveManager::Instance->LoadStruct("childEquips", []() { SaveManager::Instance->LoadStruct("childEquips", []() {
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.childEquips.buttonItems), [](size_t i) {
"buttonItems", ARRAY_COUNT(gSaveContext.childEquips.buttonItems), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.childEquips.buttonItems[i], SaveManager::Instance->LoadData("", gSaveContext.childEquips.buttonItems[i],
static_cast<uint8_t>(ITEM_NONE)); static_cast<uint8_t>(ITEM_NONE));
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.childEquips.cButtonSlots), [](size_t i) {
"cButtonSlots", ARRAY_COUNT(gSaveContext.childEquips.cButtonSlots), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.childEquips.cButtonSlots[i], SaveManager::Instance->LoadData("", gSaveContext.childEquips.cButtonSlots[i],
static_cast<uint8_t>(SLOT_NONE)); static_cast<uint8_t>(SLOT_NONE));
}); });
SaveManager::Instance->LoadData("equipment", gSaveContext.childEquips.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.childEquips.equipment);
}); });
SaveManager::Instance->LoadStruct("adultEquips", []() { SaveManager::Instance->LoadStruct("adultEquips", []() {
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.adultEquips.buttonItems), [](size_t i) {
"buttonItems", ARRAY_COUNT(gSaveContext.adultEquips.buttonItems), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.adultEquips.buttonItems[i], SaveManager::Instance->LoadData("", gSaveContext.adultEquips.buttonItems[i],
static_cast<uint8_t>(ITEM_NONE)); static_cast<uint8_t>(ITEM_NONE));
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.adultEquips.cButtonSlots), [](size_t i) {
"cButtonSlots", ARRAY_COUNT(gSaveContext.adultEquips.cButtonSlots), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.adultEquips.cButtonSlots[i], SaveManager::Instance->LoadData("", gSaveContext.adultEquips.cButtonSlots[i],
static_cast<uint8_t>(SLOT_NONE)); static_cast<uint8_t>(SLOT_NONE));
}); });
SaveManager::Instance->LoadData("equipment", gSaveContext.adultEquips.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.adultEquips.equipment);
}); });
SaveManager::Instance->LoadData("unk_54", gSaveContext.unk_54); SaveManager::Instance->LoadData("unk_54", gSaveContext.unk_54);
@ -1108,9 +1098,9 @@ void SaveManager::LoadBaseVersion2() {
SaveManager::Instance->LoadData("equipment", gSaveContext.inventory.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.inventory.equipment);
SaveManager::Instance->LoadData("upgrades", gSaveContext.inventory.upgrades); SaveManager::Instance->LoadData("upgrades", gSaveContext.inventory.upgrades);
SaveManager::Instance->LoadData("questItems", gSaveContext.inventory.questItems); SaveManager::Instance->LoadData("questItems", gSaveContext.inventory.questItems);
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("dungeonItems", ARRAY_COUNT(gSaveContext.inventory.dungeonItems), [](size_t i) {
"dungeonItems", ARRAY_COUNT(gSaveContext.inventory.dungeonItems), SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonItems[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonItems[i]); }); });
SaveManager::Instance->LoadArray("dungeonKeys", ARRAY_COUNT(gSaveContext.inventory.dungeonKeys), [](size_t i) { SaveManager::Instance->LoadArray("dungeonKeys", ARRAY_COUNT(gSaveContext.inventory.dungeonKeys), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonKeys[i]); SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonKeys[i]);
}); });
@ -1131,12 +1121,12 @@ void SaveManager::LoadBaseVersion2() {
SaveManager::Instance->LoadArray("counts", ARRAY_COUNT(gSaveContext.sohStats.count), [](size_t i) { SaveManager::Instance->LoadArray("counts", ARRAY_COUNT(gSaveContext.sohStats.count), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.sohStats.count[i]); SaveManager::Instance->LoadData("", gSaveContext.sohStats.count[i]);
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("scenesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.scenesDiscovered), [](size_t i) {
"scenesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.scenesDiscovered), SaveManager::Instance->LoadData("", gSaveContext.sohStats.scenesDiscovered[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.sohStats.scenesDiscovered[i]); }); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("entrancesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.entrancesDiscovered), [](size_t i) {
"entrancesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.entrancesDiscovered), SaveManager::Instance->LoadData("", gSaveContext.sohStats.entrancesDiscovered[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.sohStats.entrancesDiscovered[i]); }); });
}); });
SaveManager::Instance->LoadArray("sceneFlags", ARRAY_COUNT(gSaveContext.sceneFlags), [](size_t i) { SaveManager::Instance->LoadArray("sceneFlags", ARRAY_COUNT(gSaveContext.sceneFlags), [](size_t i) {
SaveManager::Instance->LoadStruct("", [&i]() { SaveManager::Instance->LoadStruct("", [&i]() {
@ -1163,17 +1153,21 @@ void SaveManager::LoadBaseVersion2() {
SaveManager::Instance->LoadData("tempSwchFlags", gSaveContext.fw.tempSwchFlags); SaveManager::Instance->LoadData("tempSwchFlags", gSaveContext.fw.tempSwchFlags);
SaveManager::Instance->LoadData("tempCollectFlags", gSaveContext.fw.tempCollectFlags); SaveManager::Instance->LoadData("tempCollectFlags", gSaveContext.fw.tempCollectFlags);
}); });
SaveManager::Instance->LoadArray("gsFlags", ARRAY_COUNT(gSaveContext.gsFlags), SaveManager::Instance->LoadArray("gsFlags", ARRAY_COUNT(gSaveContext.gsFlags), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.gsFlags[i]); }); SaveManager::Instance->LoadData("", gSaveContext.gsFlags[i]);
SaveManager::Instance->LoadArray("highScores", ARRAY_COUNT(gSaveContext.highScores), });
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.highScores[i]); }); SaveManager::Instance->LoadArray("highScores", ARRAY_COUNT(gSaveContext.highScores), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.highScores[i]);
});
SaveManager::Instance->LoadArray("eventChkInf", ARRAY_COUNT(gSaveContext.eventChkInf), [](size_t i) { SaveManager::Instance->LoadArray("eventChkInf", ARRAY_COUNT(gSaveContext.eventChkInf), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.eventChkInf[i]); SaveManager::Instance->LoadData("", gSaveContext.eventChkInf[i]);
}); });
SaveManager::Instance->LoadArray("itemGetInf", ARRAY_COUNT(gSaveContext.itemGetInf), SaveManager::Instance->LoadArray("itemGetInf", ARRAY_COUNT(gSaveContext.itemGetInf), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.itemGetInf[i]); }); SaveManager::Instance->LoadData("", gSaveContext.itemGetInf[i]);
SaveManager::Instance->LoadArray("infTable", ARRAY_COUNT(gSaveContext.infTable), });
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.infTable[i]); }); SaveManager::Instance->LoadArray("infTable", ARRAY_COUNT(gSaveContext.infTable), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.infTable[i]);
});
SaveManager::Instance->LoadData("worldMapAreaData", gSaveContext.worldMapAreaData); SaveManager::Instance->LoadData("worldMapAreaData", gSaveContext.worldMapAreaData);
SaveManager::Instance->LoadData("scarecrowCustomSongSet", gSaveContext.scarecrowLongSongSet); SaveManager::Instance->LoadData("scarecrowCustomSongSet", gSaveContext.scarecrowLongSongSet);
SaveManager::Instance->LoadArray("scarecrowCustomSong", ARRAY_COUNT(gSaveContext.scarecrowLongSong), [](size_t i) { SaveManager::Instance->LoadArray("scarecrowCustomSong", ARRAY_COUNT(gSaveContext.scarecrowLongSong), [](size_t i) {
@ -1252,8 +1246,9 @@ void SaveManager::LoadBaseVersion3() {
SaveManager::Instance->LoadData("totalDays", gSaveContext.totalDays); SaveManager::Instance->LoadData("totalDays", gSaveContext.totalDays);
SaveManager::Instance->LoadData("bgsDayCount", gSaveContext.bgsDayCount); SaveManager::Instance->LoadData("bgsDayCount", gSaveContext.bgsDayCount);
SaveManager::Instance->LoadData("deaths", gSaveContext.deaths); SaveManager::Instance->LoadData("deaths", gSaveContext.deaths);
SaveManager::Instance->LoadArray("playerName", ARRAY_COUNT(gSaveContext.playerName), SaveManager::Instance->LoadArray("playerName", ARRAY_COUNT(gSaveContext.playerName), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.playerName[i]); }); SaveManager::Instance->LoadData("", gSaveContext.playerName[i]);
});
SaveManager::Instance->LoadData("n64ddFlag", gSaveContext.n64ddFlag); SaveManager::Instance->LoadData("n64ddFlag", gSaveContext.n64ddFlag);
SaveManager::Instance->LoadData("healthCapacity", gSaveContext.healthCapacity); SaveManager::Instance->LoadData("healthCapacity", gSaveContext.healthCapacity);
SaveManager::Instance->LoadData("health", gSaveContext.health); SaveManager::Instance->LoadData("health", gSaveContext.health);
@ -1268,29 +1263,25 @@ void SaveManager::LoadBaseVersion3() {
SaveManager::Instance->LoadData("bgsFlag", gSaveContext.bgsFlag); SaveManager::Instance->LoadData("bgsFlag", gSaveContext.bgsFlag);
SaveManager::Instance->LoadData("ocarinaGameRoundNum", gSaveContext.ocarinaGameRoundNum); SaveManager::Instance->LoadData("ocarinaGameRoundNum", gSaveContext.ocarinaGameRoundNum);
SaveManager::Instance->LoadStruct("childEquips", []() { SaveManager::Instance->LoadStruct("childEquips", []() {
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.childEquips.buttonItems), [](size_t i) {
"buttonItems", ARRAY_COUNT(gSaveContext.childEquips.buttonItems), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.childEquips.buttonItems[i], SaveManager::Instance->LoadData("", gSaveContext.childEquips.buttonItems[i],
static_cast<uint8_t>(ITEM_NONE)); static_cast<uint8_t>(ITEM_NONE));
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.childEquips.cButtonSlots), [](size_t i) {
"cButtonSlots", ARRAY_COUNT(gSaveContext.childEquips.cButtonSlots), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.childEquips.cButtonSlots[i], SaveManager::Instance->LoadData("", gSaveContext.childEquips.cButtonSlots[i],
static_cast<uint8_t>(SLOT_NONE)); static_cast<uint8_t>(SLOT_NONE));
}); });
SaveManager::Instance->LoadData("equipment", gSaveContext.childEquips.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.childEquips.equipment);
}); });
SaveManager::Instance->LoadStruct("adultEquips", []() { SaveManager::Instance->LoadStruct("adultEquips", []() {
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.adultEquips.buttonItems), [](size_t i) {
"buttonItems", ARRAY_COUNT(gSaveContext.adultEquips.buttonItems), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.adultEquips.buttonItems[i], SaveManager::Instance->LoadData("", gSaveContext.adultEquips.buttonItems[i],
static_cast<uint8_t>(ITEM_NONE)); static_cast<uint8_t>(ITEM_NONE));
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.adultEquips.cButtonSlots), [](size_t i) {
"cButtonSlots", ARRAY_COUNT(gSaveContext.adultEquips.cButtonSlots), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.adultEquips.cButtonSlots[i], SaveManager::Instance->LoadData("", gSaveContext.adultEquips.cButtonSlots[i],
static_cast<uint8_t>(SLOT_NONE)); static_cast<uint8_t>(SLOT_NONE));
}); });
SaveManager::Instance->LoadData("equipment", gSaveContext.adultEquips.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.adultEquips.equipment);
}); });
SaveManager::Instance->LoadData("unk_54", gSaveContext.unk_54); SaveManager::Instance->LoadData("unk_54", gSaveContext.unk_54);
@ -1314,9 +1305,9 @@ void SaveManager::LoadBaseVersion3() {
SaveManager::Instance->LoadData("equipment", gSaveContext.inventory.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.inventory.equipment);
SaveManager::Instance->LoadData("upgrades", gSaveContext.inventory.upgrades); SaveManager::Instance->LoadData("upgrades", gSaveContext.inventory.upgrades);
SaveManager::Instance->LoadData("questItems", gSaveContext.inventory.questItems); SaveManager::Instance->LoadData("questItems", gSaveContext.inventory.questItems);
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("dungeonItems", ARRAY_COUNT(gSaveContext.inventory.dungeonItems),[](size_t i) {
"dungeonItems", ARRAY_COUNT(gSaveContext.inventory.dungeonItems), SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonItems[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonItems[i]); }); });
SaveManager::Instance->LoadArray("dungeonKeys", ARRAY_COUNT(gSaveContext.inventory.dungeonKeys), [](size_t i) { SaveManager::Instance->LoadArray("dungeonKeys", ARRAY_COUNT(gSaveContext.inventory.dungeonKeys), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonKeys[i]); SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonKeys[i]);
}); });
@ -1340,32 +1331,31 @@ void SaveManager::LoadBaseVersion3() {
}); });
SaveManager::Instance->LoadData("playTimer", gSaveContext.sohStats.playTimer); SaveManager::Instance->LoadData("playTimer", gSaveContext.sohStats.playTimer);
SaveManager::Instance->LoadData("pauseTimer", gSaveContext.sohStats.pauseTimer); SaveManager::Instance->LoadData("pauseTimer", gSaveContext.sohStats.pauseTimer);
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("itemTimestamps", ARRAY_COUNT(gSaveContext.sohStats.itemTimestamp), [](size_t i) {
"itemTimestamps", ARRAY_COUNT(gSaveContext.sohStats.itemTimestamp), SaveManager::Instance->LoadData("", gSaveContext.sohStats.itemTimestamp[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.sohStats.itemTimestamp[i]); }); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("sceneTimestamps", ARRAY_COUNT(gSaveContext.sohStats.sceneTimestamps), [](size_t i) {
"sceneTimestamps", ARRAY_COUNT(gSaveContext.sohStats.sceneTimestamps), [](size_t i) { SaveManager::Instance->LoadStruct("", [&i]() {
SaveManager::Instance->LoadStruct("", [&i]() { SaveManager::Instance->LoadData("scene", gSaveContext.sohStats.sceneTimestamps[i].scene);
SaveManager::Instance->LoadData("scene", gSaveContext.sohStats.sceneTimestamps[i].scene); SaveManager::Instance->LoadData("room", gSaveContext.sohStats.sceneTimestamps[i].room);
SaveManager::Instance->LoadData("room", gSaveContext.sohStats.sceneTimestamps[i].room); SaveManager::Instance->LoadData("sceneTime", gSaveContext.sohStats.sceneTimestamps[i].sceneTime);
SaveManager::Instance->LoadData("sceneTime", gSaveContext.sohStats.sceneTimestamps[i].sceneTime); SaveManager::Instance->LoadData("roomTime", gSaveContext.sohStats.sceneTimestamps[i].roomTime);
SaveManager::Instance->LoadData("roomTime", gSaveContext.sohStats.sceneTimestamps[i].roomTime); SaveManager::Instance->LoadData("isRoom", gSaveContext.sohStats.sceneTimestamps[i].isRoom);
SaveManager::Instance->LoadData("isRoom", gSaveContext.sohStats.sceneTimestamps[i].isRoom);
});
}); });
});
SaveManager::Instance->LoadData("tsIdx", gSaveContext.sohStats.tsIdx); SaveManager::Instance->LoadData("tsIdx", gSaveContext.sohStats.tsIdx);
SaveManager::Instance->LoadArray("counts", ARRAY_COUNT(gSaveContext.sohStats.count), [](size_t i) { SaveManager::Instance->LoadArray("counts", ARRAY_COUNT(gSaveContext.sohStats.count), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.sohStats.count[i]); SaveManager::Instance->LoadData("", gSaveContext.sohStats.count[i]);
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("scenesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.scenesDiscovered), [](size_t i) {
"scenesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.scenesDiscovered), SaveManager::Instance->LoadData("", gSaveContext.sohStats.scenesDiscovered[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.sohStats.scenesDiscovered[i]); }); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("entrancesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.entrancesDiscovered),[](size_t i) {
"entrancesDiscovered", ARRAY_COUNT(gSaveContext.sohStats.entrancesDiscovered), SaveManager::Instance->LoadData("", gSaveContext.sohStats.entrancesDiscovered[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.sohStats.entrancesDiscovered[i]); }); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("locationsSkipped", ARRAY_COUNT(gSaveContext.sohStats.locationsSkipped), [](size_t i) {
"locationsSkipped", ARRAY_COUNT(gSaveContext.sohStats.locationsSkipped), SaveManager::Instance->LoadData("", gSaveContext.sohStats.locationsSkipped[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.sohStats.locationsSkipped[i]); }); });
}); });
SaveManager::Instance->LoadArray("sceneFlags", ARRAY_COUNT(gSaveContext.sceneFlags), [](size_t i) { SaveManager::Instance->LoadArray("sceneFlags", ARRAY_COUNT(gSaveContext.sceneFlags), [](size_t i) {
SaveManager::Instance->LoadStruct("", [&i]() { SaveManager::Instance->LoadStruct("", [&i]() {
@ -1392,17 +1382,21 @@ void SaveManager::LoadBaseVersion3() {
SaveManager::Instance->LoadData("tempSwchFlags", gSaveContext.fw.tempSwchFlags); SaveManager::Instance->LoadData("tempSwchFlags", gSaveContext.fw.tempSwchFlags);
SaveManager::Instance->LoadData("tempCollectFlags", gSaveContext.fw.tempCollectFlags); SaveManager::Instance->LoadData("tempCollectFlags", gSaveContext.fw.tempCollectFlags);
}); });
SaveManager::Instance->LoadArray("gsFlags", ARRAY_COUNT(gSaveContext.gsFlags), SaveManager::Instance->LoadArray("gsFlags", ARRAY_COUNT(gSaveContext.gsFlags), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.gsFlags[i]); }); SaveManager::Instance->LoadData("", gSaveContext.gsFlags[i]);
SaveManager::Instance->LoadArray("highScores", ARRAY_COUNT(gSaveContext.highScores), });
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.highScores[i]); }); SaveManager::Instance->LoadArray("highScores", ARRAY_COUNT(gSaveContext.highScores), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.highScores[i]);
});
SaveManager::Instance->LoadArray("eventChkInf", ARRAY_COUNT(gSaveContext.eventChkInf), [](size_t i) { SaveManager::Instance->LoadArray("eventChkInf", ARRAY_COUNT(gSaveContext.eventChkInf), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.eventChkInf[i]); SaveManager::Instance->LoadData("", gSaveContext.eventChkInf[i]);
}); });
SaveManager::Instance->LoadArray("itemGetInf", ARRAY_COUNT(gSaveContext.itemGetInf), SaveManager::Instance->LoadArray("itemGetInf", ARRAY_COUNT(gSaveContext.itemGetInf), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.itemGetInf[i]); }); SaveManager::Instance->LoadData("", gSaveContext.itemGetInf[i]);
SaveManager::Instance->LoadArray("infTable", ARRAY_COUNT(gSaveContext.infTable), });
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.infTable[i]); }); SaveManager::Instance->LoadArray("infTable", ARRAY_COUNT(gSaveContext.infTable), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.infTable[i]);
});
SaveManager::Instance->LoadData("worldMapAreaData", gSaveContext.worldMapAreaData); SaveManager::Instance->LoadData("worldMapAreaData", gSaveContext.worldMapAreaData);
SaveManager::Instance->LoadData("scarecrowLongSongSet", gSaveContext.scarecrowLongSongSet); SaveManager::Instance->LoadData("scarecrowLongSongSet", gSaveContext.scarecrowLongSongSet);
SaveManager::Instance->LoadArray("scarecrowLongSong", ARRAY_COUNT(gSaveContext.scarecrowLongSong), [](size_t i) { SaveManager::Instance->LoadArray("scarecrowLongSong", ARRAY_COUNT(gSaveContext.scarecrowLongSong), [](size_t i) {
@ -1468,8 +1462,9 @@ void SaveManager::LoadBaseVersion4() {
SaveManager::Instance->LoadData("totalDays", gSaveContext.totalDays); SaveManager::Instance->LoadData("totalDays", gSaveContext.totalDays);
SaveManager::Instance->LoadData("bgsDayCount", gSaveContext.bgsDayCount); SaveManager::Instance->LoadData("bgsDayCount", gSaveContext.bgsDayCount);
SaveManager::Instance->LoadData("deaths", gSaveContext.deaths); SaveManager::Instance->LoadData("deaths", gSaveContext.deaths);
SaveManager::Instance->LoadArray("playerName", ARRAY_COUNT(gSaveContext.playerName), SaveManager::Instance->LoadArray("playerName", ARRAY_COUNT(gSaveContext.playerName), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.playerName[i]); }); SaveManager::Instance->LoadData("", gSaveContext.playerName[i]);
});
SaveManager::Instance->LoadData("n64ddFlag", gSaveContext.n64ddFlag); SaveManager::Instance->LoadData("n64ddFlag", gSaveContext.n64ddFlag);
SaveManager::Instance->LoadData("healthCapacity", gSaveContext.healthCapacity); SaveManager::Instance->LoadData("healthCapacity", gSaveContext.healthCapacity);
SaveManager::Instance->LoadData("health", gSaveContext.health); SaveManager::Instance->LoadData("health", gSaveContext.health);
@ -1484,29 +1479,25 @@ void SaveManager::LoadBaseVersion4() {
SaveManager::Instance->LoadData("bgsFlag", gSaveContext.bgsFlag); SaveManager::Instance->LoadData("bgsFlag", gSaveContext.bgsFlag);
SaveManager::Instance->LoadData("ocarinaGameRoundNum", gSaveContext.ocarinaGameRoundNum); SaveManager::Instance->LoadData("ocarinaGameRoundNum", gSaveContext.ocarinaGameRoundNum);
SaveManager::Instance->LoadStruct("childEquips", []() { SaveManager::Instance->LoadStruct("childEquips", []() {
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.childEquips.buttonItems), [](size_t i) {
"buttonItems", ARRAY_COUNT(gSaveContext.childEquips.buttonItems), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.childEquips.buttonItems[i], SaveManager::Instance->LoadData("", gSaveContext.childEquips.buttonItems[i],
static_cast<uint8_t>(ITEM_NONE)); static_cast<uint8_t>(ITEM_NONE));
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.childEquips.cButtonSlots), [](size_t i) {
"cButtonSlots", ARRAY_COUNT(gSaveContext.childEquips.cButtonSlots), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.childEquips.cButtonSlots[i], SaveManager::Instance->LoadData("", gSaveContext.childEquips.cButtonSlots[i],
static_cast<uint8_t>(SLOT_NONE)); static_cast<uint8_t>(SLOT_NONE));
}); });
SaveManager::Instance->LoadData("equipment", gSaveContext.childEquips.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.childEquips.equipment);
}); });
SaveManager::Instance->LoadStruct("adultEquips", []() { SaveManager::Instance->LoadStruct("adultEquips", []() {
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("buttonItems", ARRAY_COUNT(gSaveContext.adultEquips.buttonItems), [](size_t i) {
"buttonItems", ARRAY_COUNT(gSaveContext.adultEquips.buttonItems), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.adultEquips.buttonItems[i], SaveManager::Instance->LoadData("", gSaveContext.adultEquips.buttonItems[i],
static_cast<uint8_t>(ITEM_NONE)); static_cast<uint8_t>(ITEM_NONE));
}); });
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("cButtonSlots", ARRAY_COUNT(gSaveContext.adultEquips.cButtonSlots), [](size_t i) {
"cButtonSlots", ARRAY_COUNT(gSaveContext.adultEquips.cButtonSlots), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.adultEquips.cButtonSlots[i], SaveManager::Instance->LoadData("", gSaveContext.adultEquips.cButtonSlots[i],
static_cast<uint8_t>(SLOT_NONE)); static_cast<uint8_t>(SLOT_NONE));
}); });
SaveManager::Instance->LoadData("equipment", gSaveContext.adultEquips.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.adultEquips.equipment);
}); });
SaveManager::Instance->LoadData("unk_54", gSaveContext.unk_54); SaveManager::Instance->LoadData("unk_54", gSaveContext.unk_54);
@ -1530,9 +1521,9 @@ void SaveManager::LoadBaseVersion4() {
SaveManager::Instance->LoadData("equipment", gSaveContext.inventory.equipment); SaveManager::Instance->LoadData("equipment", gSaveContext.inventory.equipment);
SaveManager::Instance->LoadData("upgrades", gSaveContext.inventory.upgrades); SaveManager::Instance->LoadData("upgrades", gSaveContext.inventory.upgrades);
SaveManager::Instance->LoadData("questItems", gSaveContext.inventory.questItems); SaveManager::Instance->LoadData("questItems", gSaveContext.inventory.questItems);
SaveManager::Instance->LoadArray( SaveManager::Instance->LoadArray("dungeonItems", ARRAY_COUNT(gSaveContext.inventory.dungeonItems),[](size_t i) {
"dungeonItems", ARRAY_COUNT(gSaveContext.inventory.dungeonItems), SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonItems[i]);
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonItems[i]); }); });
SaveManager::Instance->LoadArray("dungeonKeys", ARRAY_COUNT(gSaveContext.inventory.dungeonKeys), [](size_t i) { SaveManager::Instance->LoadArray("dungeonKeys", ARRAY_COUNT(gSaveContext.inventory.dungeonKeys), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonKeys[i]); SaveManager::Instance->LoadData("", gSaveContext.inventory.dungeonKeys[i]);
}); });
@ -1564,17 +1555,21 @@ void SaveManager::LoadBaseVersion4() {
SaveManager::Instance->LoadData("tempSwchFlags", gSaveContext.fw.tempSwchFlags); SaveManager::Instance->LoadData("tempSwchFlags", gSaveContext.fw.tempSwchFlags);
SaveManager::Instance->LoadData("tempCollectFlags", gSaveContext.fw.tempCollectFlags); SaveManager::Instance->LoadData("tempCollectFlags", gSaveContext.fw.tempCollectFlags);
}); });
SaveManager::Instance->LoadArray("gsFlags", ARRAY_COUNT(gSaveContext.gsFlags), SaveManager::Instance->LoadArray("gsFlags", ARRAY_COUNT(gSaveContext.gsFlags), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.gsFlags[i]); }); SaveManager::Instance->LoadData("", gSaveContext.gsFlags[i]);
SaveManager::Instance->LoadArray("highScores", ARRAY_COUNT(gSaveContext.highScores), });
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.highScores[i]); }); SaveManager::Instance->LoadArray("highScores", ARRAY_COUNT(gSaveContext.highScores), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.highScores[i]);
});
SaveManager::Instance->LoadArray("eventChkInf", ARRAY_COUNT(gSaveContext.eventChkInf), [](size_t i) { SaveManager::Instance->LoadArray("eventChkInf", ARRAY_COUNT(gSaveContext.eventChkInf), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.eventChkInf[i]); SaveManager::Instance->LoadData("", gSaveContext.eventChkInf[i]);
}); });
SaveManager::Instance->LoadArray("itemGetInf", ARRAY_COUNT(gSaveContext.itemGetInf), SaveManager::Instance->LoadArray("itemGetInf", ARRAY_COUNT(gSaveContext.itemGetInf), [](size_t i) {
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.itemGetInf[i]); }); SaveManager::Instance->LoadData("", gSaveContext.itemGetInf[i]);
SaveManager::Instance->LoadArray("infTable", ARRAY_COUNT(gSaveContext.infTable), });
[](size_t i) { SaveManager::Instance->LoadData("", gSaveContext.infTable[i]); }); SaveManager::Instance->LoadArray("infTable", ARRAY_COUNT(gSaveContext.infTable), [](size_t i) {
SaveManager::Instance->LoadData("", gSaveContext.infTable[i]);
});
SaveManager::Instance->LoadData("worldMapAreaData", gSaveContext.worldMapAreaData); SaveManager::Instance->LoadData("worldMapAreaData", gSaveContext.worldMapAreaData);
SaveManager::Instance->LoadData("scarecrowLongSongSet", gSaveContext.scarecrowLongSongSet); SaveManager::Instance->LoadData("scarecrowLongSongSet", gSaveContext.scarecrowLongSongSet);
SaveManager::Instance->LoadArray("scarecrowLongSong", ARRAY_COUNT(gSaveContext.scarecrowLongSong), [](size_t i) { SaveManager::Instance->LoadArray("scarecrowLongSong", ARRAY_COUNT(gSaveContext.scarecrowLongSong), [](size_t i) {