Fix crash when loading unversioned oot_save.sav (#7090)

This commit is contained in:
Philip Dubé
2026-08-17 17:23:08 +00:00
committed by GitHub
parent 6a3c9b7604
commit 4c43ef030d
+7 -1
View File
@@ -2799,11 +2799,17 @@ void SaveManager::ConvertFromUnversioned() {
#define SLOT_SIZE (sizeof(SaveContext_v0) + 0x28)
#define SLOT_OFFSET(index) (SRAM_HEADER_SIZE + 0x10 + (index * SLOT_SIZE))
std::ifstream input("oot_save.sav", std::ios::binary);
std::ifstream input(Ship::Context::GetPathRelativeToAppDirectory("oot_save.sav"), std::ios::binary);
std::vector<char> data(std::istreambuf_iterator<char>(input), {});
input.close();
// Couldn't read the file, or it's too short to hold all three slots
if (data.size() < SLOT_OFFSET(3)) {
CreateDefaultGlobal();
return;
}
for (size_t i = 0; i < ARRAY_COUNT(sZeldaMagic) - 3; i++) {
if (sZeldaMagic[i + SRAM_HEADER_MAGIC] != data[i + SRAM_HEADER_MAGIC]) {
CreateDefaultGlobal();