From 789cdba8b51f310399752f7a1309e489fadf8dc1 Mon Sep 17 00:00:00 2001 From: Thomas Guillemard Date: Thu, 4 Jul 2019 17:14:17 +0200 Subject: 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 --- Ryujinx.HLE/Utilities/UInt128.cs | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'Ryujinx.HLE/Utilities') 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 { - 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 -- cgit v1.2.3