simplify get ids
This commit is contained in:
@@ -29,21 +29,16 @@ public unsafe class BlockedCharacterHandler
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ulong GetAccIdFromPlayerPointer(nint ptr)
|
private static (ulong AccId, ulong ContentId) GetIdsFromPlayerPointer(nint ptr)
|
||||||
{
|
{
|
||||||
if (ptr == nint.Zero) return 0;
|
if (ptr == nint.Zero) return (0, 0);
|
||||||
return ((BattleChara*)ptr)->Character.AccountId;
|
var castChar = ((BattleChara*)ptr);
|
||||||
}
|
return (castChar->Character.AccountId, castChar->Character.ContentId);
|
||||||
|
|
||||||
private static ulong GetContentIdFromPlayerPointer(nint ptr)
|
|
||||||
{
|
|
||||||
if (ptr == nint.Zero) return 0;
|
|
||||||
return ((BattleChara*)ptr)->Character.ContentId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsCharacterBlocked(nint ptr)
|
public bool IsCharacterBlocked(nint ptr)
|
||||||
{
|
{
|
||||||
(ulong AccId, ulong ContentId) combined = (GetAccIdFromPlayerPointer(ptr), GetContentIdFromPlayerPointer(ptr));
|
var combined = GetIdsFromPlayerPointer(ptr);
|
||||||
if (_blockedCharacterCache.TryGetValue(combined, out var isBlocked))
|
if (_blockedCharacterCache.TryGetValue(combined, out var isBlocked))
|
||||||
return isBlocked;
|
return isBlocked;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user