Merge pull request #3007 from DarkLordZach/fsc-regress
savedata_factory: Automatically create certain savedata
This commit is contained in:
commit
a81bd962ab
@ -16,6 +16,7 @@ namespace FileSys {
|
|||||||
constexpr char SAVE_DATA_SIZE_FILENAME[] = ".yuzu_save_size";
|
constexpr char SAVE_DATA_SIZE_FILENAME[] = ".yuzu_save_size";
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void PrintSaveDataDescriptorWarnings(SaveDataDescriptor meta) {
|
void PrintSaveDataDescriptorWarnings(SaveDataDescriptor meta) {
|
||||||
if (meta.type == SaveDataType::SystemSaveData || meta.type == SaveDataType::SaveData) {
|
if (meta.type == SaveDataType::SystemSaveData || meta.type == SaveDataType::SaveData) {
|
||||||
if (meta.zero_1 != 0) {
|
if (meta.zero_1 != 0) {
|
||||||
@ -52,6 +53,13 @@ void PrintSaveDataDescriptorWarnings(SaveDataDescriptor meta) {
|
|||||||
meta.user_id[1], meta.user_id[0]);
|
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
|
} // Anonymous namespace
|
||||||
|
|
||||||
std::string SaveDataDescriptor::DebugInfo() const {
|
std::string SaveDataDescriptor::DebugInfo() const {
|
||||||
@ -96,6 +104,10 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space,
|
|||||||
|
|
||||||
auto out = dir->GetDirectoryRelative(save_directory);
|
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.
|
// Return an error if the save data doesn't actually exist.
|
||||||
if (out == nullptr) {
|
if (out == nullptr) {
|
||||||
// TODO(Subv): Find out correct error code.
|
// TODO(Subv): Find out correct error code.
|
||||||
|
Loading…
Reference in New Issue
Block a user