Browse Source

Add proper `IsEqual()` method to `UserID`

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
f1497cd0ff
  1. 4
      sources/Users/Tests/TEST_User.uc
  2. 20
      sources/Users/UserID.uc

4
sources/Users/Tests/TEST_User.uc

@ -55,9 +55,9 @@ protected static function Test_UserID()
testID3 = UserID(__().memory.Allocate(class'UserID'));
testID2.Initialize(P("76561198025127722"));
testID3.Initialize(P("76561198044316328"));
TEST_ExpectTrue(testID.IsEqualTo(testID2));
TEST_ExpectTrue(testID.IsEqual(testID2));
TEST_ExpectTrue(testID.IsEqualToSteamID(testID2.GetSteamID()));
TEST_ExpectFalse(testID3.IsEqualTo(testID));
TEST_ExpectFalse(testID3.IsEqual(testID));
Issue("Steam data returned by `UserID` is incorrect.");
SteamID = testID3.GetSteamID();

20
sources/Users/UserID.uc

@ -244,21 +244,23 @@ public final function SteamID GetSteamID()
return initializedData;
}
/**
* Checks if two `UserID`s are the same.
*
* @param otherID `UserID` to compare caller object to.
* @return `true` if caller `UserID` is identical to `otherID` and
* `false` otherwise. If at least one of the `UserID`s being compared is
* uninitialized, the result will be `false`.
*/
public final function bool IsEqualTo(UserID otherID)
public function bool IsEqual(Object other)
{
local UserID otherID;
if (!IsInitialized()) return false;
otherID = UserID(other);
if (otherID == none) return false;
if (!otherID.IsInitialized()) return false;
return (initializedData.steamID32 == otherID.initializedData.steamID32);
}
protected function int CalculateHashCode()
{
return initializedData.steamID32;
}
/**
* Checks if caller `UserID`s is the same as what's described by
* given `SteamID`.

Loading…
Cancel
Save