diff options
| author | Thomas Guillemard <me@thog.eu> | 2019-07-04 17:14:17 +0200 |
|---|---|---|
| committer | Ac_K <Acoustik666@gmail.com> | 2019-07-04 17:14:17 +0200 |
| commit | 789cdba8b51f310399752f7a1309e489fadf8dc1 (patch) | |
| tree | 7a0a596ea90dccad5f740708f2b22444c2d33a2d /Ryujinx.HLE/Utilities | |
| parent | b2b736abc2569ab5d8199da666aef8d8394844a0 (diff) | |
Refactor the friend namespace (#721)
* Refactor the friend namespace and UInt128
This commit also:
- Fix GetFriendsList arguments ordering.
- Add GetFriendListIds.
- Expose the permission level of the port instance.
- InvalidUUID => InvalidArgument
* friend: add all cmds as commments
* add Friend structure layout
* Rename FriendErr to FriendError
* Accurately implement INotificationService
* Fix singleton lock of NotificationEventHandler
* Address comments
* Add comments for IDaemonSuspendSessionService cmds
* Explicitly define the Charset when needed
Also make "Nickname" a string
* Address gdk's comments
Diffstat (limited to 'Ryujinx.HLE/Utilities')
| -rw-r--r-- | Ryujinx.HLE/Utilities/UInt128.cs | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/Ryujinx.HLE/Utilities/UInt128.cs b/Ryujinx.HLE/Utilities/UInt128.cs index 8f5fc28f..22d87f6b 100644 --- a/Ryujinx.HLE/Utilities/UInt128.cs +++ b/Ryujinx.HLE/Utilities/UInt128.cs @@ -1,13 +1,15 @@ using System; using System.IO; using System.Linq; +using System.Runtime.InteropServices; namespace Ryujinx.HLE.Utilities { - public struct UInt128 + [StructLayout(LayoutKind.Sequential)] + public struct UInt128 : IEquatable<UInt128> { - public long High { get; private set; } - public long Low { get; private set; } + public readonly long Low; + public readonly long High; public bool IsNull => (Low | High) == 0; @@ -45,9 +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 |
