diff --git a/Ryujinx.HLE/FileSystem/SaveHelper.cs b/Ryujinx.HLE/FileSystem/SaveHelper.cs index 0dfcfd2bb9..411d13e250 100644 --- a/Ryujinx.HLE/FileSystem/SaveHelper.cs +++ b/Ryujinx.HLE/FileSystem/SaveHelper.cs @@ -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"), diff --git a/Ryujinx.HLE/HOS/Services/Friend/FriendServicePermissionLevel.cs b/Ryujinx.HLE/HOS/Services/Friend/FriendServicePermissionLevel.cs index 02d37049bc..2ddb0b858b 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/FriendServicePermissionLevel.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/FriendServicePermissionLevel.cs @@ -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 } } diff --git a/Ryujinx.HLE/HOS/Services/Friend/INotificationService.cs b/Ryujinx.HLE/HOS/Services/Friend/INotificationService.cs index b9a5639215..68893efeb8 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/INotificationService.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/INotificationService.cs @@ -22,8 +22,9 @@ namespace Ryujinx.HLE.HOS.Services.Friend private LinkedList _notifications; - private bool _hasNewFriendRequest; - private bool _hasFriendListUpdate; + + private bool _hasNewFriendRequest; + private bool _hasFriendListUpdate; private Dictionary _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); } } } \ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Friend/NotificationEventHandler.cs b/Ryujinx.HLE/HOS/Services/Friend/NotificationEventHandler.cs index e2d903be5e..8582a074bb 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/NotificationEventHandler.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/NotificationEventHandler.cs @@ -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; - } - } - } } } diff --git a/Ryujinx.HLE/Utilities/UInt128.cs b/Ryujinx.HLE/Utilities/UInt128.cs index 58b05afd95..22d87f6b17 100644 --- a/Ryujinx.HLE/Utilities/UInt128.cs +++ b/Ryujinx.HLE/Utilities/UInt128.cs @@ -6,10 +6,10 @@ using System.Runtime.InteropServices; namespace Ryujinx.HLE.Utilities { [StructLayout(LayoutKind.Sequential)] - public struct UInt128 + public struct UInt128 : IEquatable { - 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); + } } } \ No newline at end of file