From e348f95495d3af9742010b1e44a2c3d7f30dba1a Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sun, 12 Jan 2020 04:15:17 -0700 Subject: Call EnsureApplicationSaveData when launching a game (#871) * Workaround for the lack of a program registry * Call EnsureApplicationSaveData when launching a game --- .../HOS/Services/Arp/ApplicationLaunchProperty.cs | 6 ++--- Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs | 30 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services') diff --git a/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs b/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs index 4962e3ff..686577d7 100644 --- a/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs +++ b/Ryujinx.HLE/HOS/Services/Arp/ApplicationLaunchProperty.cs @@ -1,12 +1,10 @@ using Ryujinx.HLE.FileSystem; -using Ryujinx.HLE.Utilities; -using System; namespace Ryujinx.HLE.HOS.Services.Arp { class ApplicationLaunchProperty { - public long TitleId; + public ulong TitleId; public int Version; public byte BaseGameStorageId; public byte UpdateGameStorageId; @@ -33,7 +31,7 @@ namespace Ryujinx.HLE.HOS.Services.Arp return new ApplicationLaunchProperty { - TitleId = BitConverter.ToInt64(StringUtils.HexToBytes(context.Device.System.TitleId), 0), + TitleId = context.Device.System.TitleId, Version = 0x00, BaseGameStorageId = (byte)StorageId.NandSystem, UpdateGameStorageId = (byte)StorageId.None diff --git a/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs b/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs index 60f4a3f4..4e967886 100644 --- a/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs +++ b/Ryujinx.HLE/HOS/Services/Fs/IFileSystemProxy.cs @@ -133,6 +133,20 @@ namespace Ryujinx.HLE.HOS.Services.Fs SaveDataCreateInfo createInfo = context.RequestData.ReadStruct(); SaveMetaCreateInfo metaCreateInfo = context.RequestData.ReadStruct(); + // TODO: There's currently no program registry for FS to reference. + // Workaround that by setting the application ID and owner ID if they're not already set + if (attribute.TitleId == TitleId.Zero) + { + attribute.TitleId = new TitleId(context.Process.TitleId); + } + + if (createInfo.OwnerId == TitleId.Zero) + { + createInfo.OwnerId = new TitleId(context.Process.TitleId); + } + + Logger.PrintInfo(LogClass.ServiceFs, $"Creating save with title ID {attribute.TitleId.Value:x16}"); + Result result = _baseFileSystemProxy.CreateSaveDataFileSystem(ref attribute, ref createInfo, ref metaCreateInfo); return (ResultCode)result.Value; @@ -196,6 +210,18 @@ namespace Ryujinx.HLE.HOS.Services.Fs SaveMetaCreateInfo metaCreateInfo = context.RequestData.ReadStruct(); HashSalt hashSalt = context.RequestData.ReadStruct(); + // TODO: There's currently no program registry for FS to reference. + // Workaround that by setting the application ID and owner ID if they're not already set + if (attribute.TitleId == TitleId.Zero) + { + attribute.TitleId = new TitleId(context.Process.TitleId); + } + + if (createInfo.OwnerId == TitleId.Zero) + { + createInfo.OwnerId = new TitleId(context.Process.TitleId); + } + Result result = _baseFileSystemProxy.CreateSaveDataFileSystemWithHashSalt(ref attribute, ref createInfo, ref metaCreateInfo, ref hashSalt); return (ResultCode)result.Value; @@ -208,6 +234,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataAttribute attribute = context.RequestData.ReadStruct(); + // TODO: There's currently no program registry for FS to reference. + // Workaround that by setting the application ID if it's not already set if (attribute.TitleId == TitleId.Zero) { attribute.TitleId = new TitleId(context.Process.TitleId); @@ -247,6 +275,8 @@ namespace Ryujinx.HLE.HOS.Services.Fs SaveDataSpaceId spaceId = (SaveDataSpaceId)context.RequestData.ReadInt64(); SaveDataAttribute attribute = context.RequestData.ReadStruct(); + // TODO: There's currently no program registry for FS to reference. + // Workaround that by setting the application ID if it's not already set if (attribute.TitleId == TitleId.Zero) { attribute.TitleId = new TitleId(context.Process.TitleId); -- cgit v1.2.3