summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-10-30 03:05:09 +0100
committerGitHub <noreply@github.com>2019-10-30 03:05:09 +0100
commita81bd962ab433116e85c4391898e85d5f0564b55 (patch)
treedb2f0d83b941d4780584609a2d517cb3247479f6 /src/core
parentMerge pull request #3004 from ReinUsesLisp/maxwell3d-cleanup (diff)
parentsavedata_factory: Automatically create certain savedata (diff)
downloadyuzu-a81bd962ab433116e85c4391898e85d5f0564b55.tar
yuzu-a81bd962ab433116e85c4391898e85d5f0564b55.tar.gz
yuzu-a81bd962ab433116e85c4391898e85d5f0564b55.tar.bz2
yuzu-a81bd962ab433116e85c4391898e85d5f0564b55.tar.lz
yuzu-a81bd962ab433116e85c4391898e85d5f0564b55.tar.xz
yuzu-a81bd962ab433116e85c4391898e85d5f0564b55.tar.zst
yuzu-a81bd962ab433116e85c4391898e85d5f0564b55.zip
Diffstat (limited to 'src/core')
-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 {
constexpr char SAVE_DATA_SIZE_FILENAME[] = ".yuzu_save_size";
namespace {
+
void PrintSaveDataDescriptorWarnings(SaveDataDescriptor meta) {
if (meta.type == SaveDataType::SystemSaveData || meta.type == SaveDataType::SaveData) {
if (meta.zero_1 != 0) {
@@ -52,6 +53,13 @@ void PrintSaveDataDescriptorWarnings(SaveDataDescriptor meta) {
meta.user_id[1], meta.user_id[0]);
}
}
+
+bool ShouldSaveDataBeAutomaticallyCreated(SaveDataSpaceId space, const SaveDataDescriptor& desc) {
+ return desc.type == SaveDataType::CacheStorage || desc.type == SaveDataType::TemporaryStorage ||
+ (space == SaveDataSpaceId::NandUser && ///< Normal Save Data -- Current Title & User
+ desc.type == SaveDataType::SaveData && desc.title_id == 0 && desc.save_id == 0);
+}
+
} // Anonymous namespace
std::string SaveDataDescriptor::DebugInfo() const {
@@ -96,6 +104,10 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space,
auto out = dir->GetDirectoryRelative(save_directory);
+ if (out == nullptr && ShouldSaveDataBeAutomaticallyCreated(space, meta)) {
+ return Create(space, meta);
+ }
+
// Return an error if the save data doesn't actually exist.
if (out == nullptr) {
// TODO(Subv): Find out correct error code.