Address gdk's comments

This commit is contained in:
Thog 2019-07-04 17:02:40 +02:00
parent 898effb7be
commit 662716bc9c
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
5 changed files with 52 additions and 47 deletions

View file

@ -32,7 +32,7 @@ namespace Ryujinx.HLE.FileSystem
currentTitleId = context.Process.TitleId;
}
string saveAccount = saveMetaData.UserId.IsZero() ? "savecommon" : saveMetaData.UserId.ToString();
string saveAccount = saveMetaData.UserId.IsNull ? "savecommon" : saveMetaData.UserId.ToString();
string savePath = Path.Combine(baseSavePath,
saveMetaData.SaveId.ToString("x16"),

View file

@ -3,20 +3,17 @@
namespace Ryujinx.HLE.HOS.Services.Friend
{
[Flags]
enum FriendServicePermissionLevelMask
{
User = 1,
Overlay = 2,
Manager = 4,
System = 8
}
enum FriendServicePermissionLevel
{
UserMask = 1,
OverlayMask = 2,
ManagerMask = 4,
SystemMask = 8,
Admin = -1,
User = FriendServicePermissionLevelMask.User,
Overlay = FriendServicePermissionLevelMask.User | FriendServicePermissionLevelMask.Overlay,
Manager = FriendServicePermissionLevelMask.User | FriendServicePermissionLevelMask.Overlay | FriendServicePermissionLevelMask.Manager,
System = FriendServicePermissionLevelMask.User | FriendServicePermissionLevelMask.System
User = UserMask,
Overlay = UserMask | OverlayMask,
Manager = UserMask | OverlayMask | ManagerMask,
System = UserMask | SystemMask
}
}

View file

@ -22,8 +22,9 @@ namespace Ryujinx.HLE.HOS.Services.Friend
private LinkedList<NotificationInfo> _notifications;
private bool _hasNewFriendRequest;
private bool _hasFriendListUpdate;
private bool _hasNewFriendRequest;
private bool _hasFriendListUpdate;
private Dictionary<int, ServiceProcessRequest> _commands;
@ -111,7 +112,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
{
lock (_lock)
{
if (_userId.Equals(targetId))
if (_userId == targetId)
{
if (!_hasFriendListUpdate)
{
@ -153,7 +154,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
{
lock (_lock)
{
if (((int)_permissionLevel & (int)FriendServicePermissionLevelMask.Overlay) != 0 && _userId.Equals(targetId))
if ((_permissionLevel & FriendServicePermissionLevel.OverlayMask) != 0 && _userId == targetId)
{
if (!_hasNewFriendRequest)
{
@ -178,15 +179,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend
public void Dispose()
{
Dispose(true);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
NotificationEventHandler.Instance.UnregisterNotificationService(this);
}
NotificationEventHandler.Instance.UnregisterNotificationService(this);
}
}
}

View file

@ -9,6 +9,22 @@ namespace Ryujinx.HLE.HOS.Services.Friend
private INotificationService[] _registry;
public static NotificationEventHandler Instance
{
get
{
lock (instanceLock)
{
if (instance == null)
{
instance = new NotificationEventHandler();
}
return instance;
}
}
}
NotificationEventHandler()
{
_registry = new INotificationService[0x20];
@ -63,21 +79,5 @@ namespace Ryujinx.HLE.HOS.Services.Friend
}
}
}
public static NotificationEventHandler Instance
{
get
{
lock (instanceLock)
{
if (instance == null)
{
instance = new NotificationEventHandler();
}
return instance;
}
}
}
}
}

View file

@ -6,10 +6,10 @@ using System.Runtime.InteropServices;
namespace Ryujinx.HLE.Utilities
{
[StructLayout(LayoutKind.Sequential)]
public struct UInt128
public struct UInt128 : IEquatable<UInt128>
{
public long Low { get; private set; }
public long High { get; private set; }
public readonly long Low;
public readonly long High;
public bool IsNull => (Low | High) == 0;
@ -47,14 +47,29 @@ namespace Ryujinx.HLE.Utilities
return High.ToString("x16") + Low.ToString("x16");
}
public bool IsZero()
public static bool operator ==(UInt128 x, UInt128 y)
{
return (Low | High) == 0;
return x.Equals(y);
}
public static bool operator !=(UInt128 x, UInt128 y)
{
return !x.Equals(y);
}
public override bool Equals(object obj)
{
return obj is UInt128 uint128 && Equals(uint128);
}
public bool Equals(UInt128 cmpObj)
{
return Low == cmpObj.Low && High == cmpObj.High;
}
public override int GetHashCode()
{
return HashCode.Combine(Low, High);
}
}
}