summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Zach Hilman2019-10-22 15:47:31 -0400
committerGravatar Zach Hilman2019-10-22 15:47:38 -0400
commitbb207fe27adcaa0d4c00b1962a519195ff4fc200 (patch)
tree1c1c24752586b2ad54b471b1220cef420f383558 /src
parentMerge pull request #3001 from bunnei/fix-clang-error (diff)
downloadyuzu-bb207fe27adcaa0d4c00b1962a519195ff4fc200.tar.gz
yuzu-bb207fe27adcaa0d4c00b1962a519195ff4fc200.tar.xz
yuzu-bb207fe27adcaa0d4c00b1962a519195ff4fc200.zip
savedata_factory: Automatically create certain savedata
After further hardware investigation, it appears that some games, perhaps those more lazily coded, will not call EnsureSaveData, meaning that they expect the normal (current) save to be automatically made. Additionally, some games do not create a cache or temporary save before use. In these 3 specific instances, the save is created automatically for the game if it doesn't exist.
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/savedata_factory.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp
index fc8755c78..e2a7eaf7b 100644
--- a/src/core/file_sys/savedata_factory.cpp
+++ b/src/core/file_sys/savedata_factory.cpp
@@ -16,6 +16,7 @@ namespace FileSys {
16constexpr char SAVE_DATA_SIZE_FILENAME[] = ".yuzu_save_size"; 16constexpr char SAVE_DATA_SIZE_FILENAME[] = ".yuzu_save_size";
17 17
18namespace { 18namespace {
19
19void PrintSaveDataDescriptorWarnings(SaveDataDescriptor meta) { 20void PrintSaveDataDescriptorWarnings(SaveDataDescriptor meta) {
20 if (meta.type == SaveDataType::SystemSaveData || meta.type == SaveDataType::SaveData) { 21 if (meta.type == SaveDataType::SystemSaveData || meta.type == SaveDataType::SaveData) {
21 if (meta.zero_1 != 0) { 22 if (meta.zero_1 != 0) {
@@ -52,6 +53,13 @@ void PrintSaveDataDescriptorWarnings(SaveDataDescriptor meta) {
52 meta.user_id[1], meta.user_id[0]); 53 meta.user_id[1], meta.user_id[0]);
53 } 54 }
54} 55}
56
57bool ShouldSaveDataBeAutomaticallyCreated(SaveDataSpaceId space, const SaveDataDescriptor& desc) {
58 return desc.type == SaveDataType::CacheStorage || desc.type == SaveDataType::TemporaryStorage ||
59 (space == SaveDataSpaceId::NandUser && ///< Normal Save Data -- Current Title & User
60 desc.type == SaveDataType::SaveData && desc.title_id == 0 && desc.save_id == 0);
61}
62
55} // Anonymous namespace 63} // Anonymous namespace
56 64
57std::string SaveDataDescriptor::DebugInfo() const { 65std::string SaveDataDescriptor::DebugInfo() const {
@@ -96,6 +104,10 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space,
96 104
97 auto out = dir->GetDirectoryRelative(save_directory); 105 auto out = dir->GetDirectoryRelative(save_directory);
98 106
107 if (out == nullptr && ShouldSaveDataBeAutomaticallyCreated(space, meta)) {
108 return Create(space, meta);
109 }
110
99 // Return an error if the save data doesn't actually exist. 111 // Return an error if the save data doesn't actually exist.
100 if (out == nullptr) { 112 if (out == nullptr) {
101 // TODO(Subv): Find out correct error code. 113 // TODO(Subv): Find out correct error code.