save common implementation

This commit is contained in:
emmaus 2018-09-27 08:26:12 +00:00
commit 263bb21dbb
6 changed files with 16 additions and 11 deletions

View file

@ -1,5 +1,6 @@
using Ryujinx.HLE.HOS; using Ryujinx.HLE.HOS;
using System.IO; using System.IO;
using System.Linq;
using static Ryujinx.HLE.FileSystem.VirtualFileSystem; using static Ryujinx.HLE.FileSystem.VirtualFileSystem;
@ -35,9 +36,12 @@ namespace Ryujinx.HLE.FileSystem
} }
} }
string SaveAccount = SaveMetaData.UserId.ToString().All("0".Contains) ?
"savecommon" : SaveMetaData.UserId.ToString();
string SavePath = Path.Combine(BaseSavePath, string SavePath = Path.Combine(BaseSavePath,
SaveMetaData.SaveId.ToString("x16"), SaveMetaData.SaveId.ToString("x16"),
SaveMetaData.UserId.ToString(), SaveAccount,
SaveMetaData.SaveDataType == SaveDataType.SaveData ? CurrentTitleId.ToString("x16") : string.Empty); SaveMetaData.SaveDataType == SaveDataType.SaveData ? CurrentTitleId.ToString("x16") : string.Empty);
return SavePath; return SavePath;

View file

@ -39,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Acc
{ {
UserId Uuid = new UserId( UserId Uuid = new UserId(
Context.RequestData.ReadInt64(), Context.RequestData.ReadInt64(),
Context.RequestData.ReadInt64()); Context.RequestData.ReadInt64(), false);
Context.ResponseData.Write(Context.Device.System.State.TryGetUser(Uuid, out _) ? 1 : 0); Context.ResponseData.Write(Context.Device.System.State.TryGetUser(Uuid, out _) ? 1 : 0);
@ -94,7 +94,7 @@ namespace Ryujinx.HLE.HOS.Services.Acc
{ {
UserId Uuid = new UserId( UserId Uuid = new UserId(
Context.RequestData.ReadInt64(), Context.RequestData.ReadInt64(),
Context.RequestData.ReadInt64()); Context.RequestData.ReadInt64(), false);
if (!Context.Device.System.State.TryGetUser(Uuid, out UserProfile Profile)) if (!Context.Device.System.State.TryGetUser(Uuid, out UserProfile Profile))
{ {

View file

@ -63,7 +63,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
{ {
UserId Uuid = new UserId( UserId Uuid = new UserId(
Context.RequestData.ReadInt64(), Context.RequestData.ReadInt64(),
Context.RequestData.ReadInt64()); Context.RequestData.ReadInt64(), false);
if (Context.Device.System.State.TryGetUser(Uuid, out UserProfile Profile)) if (Context.Device.System.State.TryGetUser(Uuid, out UserProfile Profile))
{ {
@ -81,7 +81,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
{ {
UserId Uuid = new UserId( UserId Uuid = new UserId(
Context.RequestData.ReadInt64(), Context.RequestData.ReadInt64(),
Context.RequestData.ReadInt64()); Context.RequestData.ReadInt64(), false);
long Unknown0 = Context.RequestData.ReadInt64(); long Unknown0 = Context.RequestData.ReadInt64();

View file

@ -80,7 +80,7 @@ namespace Ryujinx.HLE.HOS.Services.FspSrv
UserId UserId = new UserId( UserId UserId = new UserId(
Context.RequestData.ReadInt64(), Context.RequestData.ReadInt64(),
Context.RequestData.ReadInt64()); Context.RequestData.ReadInt64(), false);
long SaveId = Context.RequestData.ReadInt64(); long SaveId = Context.RequestData.ReadInt64();

View file

@ -57,9 +57,10 @@ namespace Ryujinx.HLE.HOS.SystemState
Profiles = new ConcurrentDictionary<string, UserProfile>(); Profiles = new ConcurrentDictionary<string, UserProfile>();
UserId DefaultUuid = new UserId("00000000000000000000000000000001"); UserId DefaultUuid = new UserId("00000000000000000000000000000001", true);
AddUser(DefaultUuid, "Player"); AddUser(DefaultUuid, "Player");
OpenUser(DefaultUuid); OpenUser(DefaultUuid);
} }

View file

@ -11,9 +11,9 @@ namespace Ryujinx.HLE.HOS.SystemState
public byte[] Bytes { get; private set; } public byte[] Bytes { get; private set; }
public UserId(long Low, long High) public UserId(long Low, long High, bool Verify)
{ {
if ((Low | High) == 0) if ((Low | High) == 0 && Verify)
{ {
throw new ArgumentException("Zero is not a valid user id!"); throw new ArgumentException("Zero is not a valid user id!");
} }
@ -43,14 +43,14 @@ namespace Ryujinx.HLE.HOS.SystemState
this.Bytes = Bytes; this.Bytes = Bytes;
} }
public UserId(string UserIdHex) public UserId(string UserIdHex, bool Verify)
{ {
if (UserIdHex == null || UserIdHex.Length != 32 || !UserIdHex.All("0123456789abcdefABCDEF".Contains)) if (UserIdHex == null || UserIdHex.Length != 32 || !UserIdHex.All("0123456789abcdefABCDEF".Contains))
{ {
throw new ArgumentException("Invalid user id!", nameof(UserIdHex)); throw new ArgumentException("Invalid user id!", nameof(UserIdHex));
} }
if (UserIdHex == "00000000000000000000000000000000") if (UserIdHex == "00000000000000000000000000000000" && Verify)
{ {
throw new ArgumentException("Zero is not a valid user id!", nameof(UserIdHex)); throw new ArgumentException("Zero is not a valid user id!", nameof(UserIdHex));
} }