diff --git a/MareSynchronos/Services/DalamudUtilService.cs b/MareSynchronos/Services/DalamudUtilService.cs index 599acc2..4d05f4f 100644 --- a/MareSynchronos/Services/DalamudUtilService.cs +++ b/MareSynchronos/Services/DalamudUtilService.cs @@ -48,6 +48,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber private bool _sentBetweenAreas = false; private readonly Dictionary _aidCache = []; private readonly Lazy _aid; + private int _aidCounter = 0; public DalamudUtilService(ILogger logger, IClientState clientState, IObjectTable objectTable, IFramework framework, IGameGui gameGui, ICondition condition, IDataManager gameData, ITargetManager targetManager, IGameConfig gameConfig, ISigScanner sigScanner, @@ -302,11 +303,13 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber private unsafe string GetHashedAccIdFromPlayerPointer(nint ptr) { - if (ptr == nint.Zero) return string.Empty; + if (ptr == nint.Zero) return "UNK" + _aidCounter++; var aid = ((BattleChara*)ptr)->Character.AccountId; if (!_aidCache.TryGetValue(aid, out string? hash)) { - _aidCache[aid] = hash = unchecked((uint)(((((BattleChara*)GetPlayerCharacter().Address)->Character.AccountId ^ aid) >> 31) ^ _aid.Value)).ToString().GetHash256(); + var player = GetPlayerCharacter(); + if (player == null) return "UNK" + _aidCounter++; + _aidCache[aid] = hash = unchecked((uint)(((((BattleChara*)player.Address)->Character.AccountId ^ aid) >> 31) ^ _aid.Value)).ToString().GetHash256(); } return hash; }