From 2021420ea3f586c88123dbb94874d11af0e7c6e8 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Sun, 20 Oct 2019 12:13:23 -0400 Subject: [PATCH] Re-introduces a workaround to create save data if it does not exist We need to investigate what HW does when save data does not exist, because some games such as Breath of the Wild and Fire Emblem Warriors do not use the proper channels proper channels (EnsureSaveData, CreateSaveData) to create them. However, some games such as Super Mario Odyssey do. --- src/core/file_sys/savedata_factory.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index fc8755c78e..c947a90826 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp @@ -95,6 +95,16 @@ ResultVal SaveDataFactory::Open(SaveDataSpaceId space, GetFullPath(space, meta.type, meta.title_id, meta.user_id, meta.save_id); auto out = dir->GetDirectoryRelative(save_directory); + + if (out == nullptr) { + // TODO (bunnei): This is a work-around to always create a save data directory if it does + // not already exist. This is a hack, as we do not understand how this works on hardware. + // Without a save data directory, many games will assert on boot. This should not have any + // bad side-effects. + // TODO: It seems that some games do not use proper channels (EnsureSaveData, + // CreateSaveData) to create save data. Need to investigate how HW deals with this. + out = dir->CreateDirectoryRelative(save_directory); + } // Return an error if the save data doesn't actually exist. if (out == nullptr) {