From fec8535c0f4d5feaeadc7e52d45589326595745e Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Sun, 9 Apr 2023 18:09:05 +0700 Subject: [PATCH] Make `User`'s equality depend on its `UserID` --- sources/Users/User.uc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sources/Users/User.uc b/sources/Users/User.uc index 4eae0ad..ccce20a 100644 --- a/sources/Users/User.uc +++ b/sources/Users/User.uc @@ -176,6 +176,22 @@ public final function bool SetPersistentData( return result; } +public function bool IsEqual(Object other) { + local User otherUser; + + if (id == none) return false; + otherUser = User(other); + if (otherUser == none) return false; + if (otherUser.id == none) return false; + + return id.IsEqual(otherUser.id); +} + +protected function int CalculateHashCode() { + // If `id` is `none`, then caller `User` shouldn't be used at all + return id.GetHashCode(); +} + defaultproperties { } \ No newline at end of file