mirror of
https://github.com/Caraxi/mare.client.git
synced 2025-12-12 15:17:23 +01:00
fix some exceptions when playerchara is null
This commit is contained in:
parent
5ff3388aff
commit
f16dbe6dd6
1 changed files with 5 additions and 2 deletions
|
|
@ -48,6 +48,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||||
private bool _sentBetweenAreas = false;
|
private bool _sentBetweenAreas = false;
|
||||||
private readonly Dictionary<ulong, string> _aidCache = [];
|
private readonly Dictionary<ulong, string> _aidCache = [];
|
||||||
private readonly Lazy<uint> _aid;
|
private readonly Lazy<uint> _aid;
|
||||||
|
private int _aidCounter = 0;
|
||||||
|
|
||||||
public DalamudUtilService(ILogger<DalamudUtilService> logger, IClientState clientState, IObjectTable objectTable, IFramework framework,
|
public DalamudUtilService(ILogger<DalamudUtilService> logger, IClientState clientState, IObjectTable objectTable, IFramework framework,
|
||||||
IGameGui gameGui, ICondition condition, IDataManager gameData, ITargetManager targetManager, IGameConfig gameConfig, ISigScanner sigScanner,
|
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)
|
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;
|
var aid = ((BattleChara*)ptr)->Character.AccountId;
|
||||||
if (!_aidCache.TryGetValue(aid, out string? hash))
|
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;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue