fix aid discrepancy
This commit is contained in:
@@ -37,7 +37,6 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
private readonly IGameGui _gameGui;
|
||||
private readonly ILogger<DalamudUtilService> _logger;
|
||||
private readonly IObjectTable _objectTable;
|
||||
private readonly ISigScanner _sigScanner;
|
||||
private readonly PerformanceCollectorService _performanceCollector;
|
||||
private uint? _classJobId = 0;
|
||||
private DateTime _delayedFrameworkUpdateCheck = DateTime.UtcNow;
|
||||
@@ -47,12 +46,10 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
private readonly Dictionary<string, (string Name, nint Address)> _playerCharas = new(StringComparer.Ordinal);
|
||||
private readonly List<string> _notUpdatedCharas = [];
|
||||
private bool _sentBetweenAreas = false;
|
||||
private readonly Dictionary<ulong, string> _aidCache = [];
|
||||
private Lazy<uint> _aid;
|
||||
private int _aidCounter = 0;
|
||||
private Lazy<ulong> _cid;
|
||||
|
||||
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,
|
||||
BlockedCharacterHandler blockedCharacterHandler, MareMediator mediator, PerformanceCollectorService performanceCollector)
|
||||
{
|
||||
_logger = logger;
|
||||
@@ -65,7 +62,6 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
_gameConfig = gameConfig;
|
||||
_blockedCharacterHandler = blockedCharacterHandler;
|
||||
Mediator = mediator;
|
||||
_sigScanner = sigScanner;
|
||||
_performanceCollector = performanceCollector;
|
||||
WorldData = new(() =>
|
||||
{
|
||||
@@ -128,19 +124,10 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
}).ConfigureAwait(false);
|
||||
});
|
||||
IsWine = Util.IsWine();
|
||||
_aid = RebuildAid();
|
||||
_cid = RebuildCID();
|
||||
}
|
||||
|
||||
private Lazy<uint> RebuildAid() {
|
||||
return new(() =>
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
var address = _sigScanner.GetStaticAddressFromSig("48 8B 0D ?? ?? ?? ?? 4C 8B CA");
|
||||
return (uint)(address != nint.Zero ? (*(ulong**)address)[1] : 0u);
|
||||
}
|
||||
});
|
||||
}
|
||||
private Lazy<ulong> RebuildCID() => new(GetCID);
|
||||
|
||||
public bool IsWine { get; init; }
|
||||
|
||||
@@ -312,20 +299,12 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
|
||||
public async Task<string> GetPlayerNameHashedAsync()
|
||||
{
|
||||
return await RunOnFrameworkThread(() => _aid.Value.ToString().GetHash256()).ConfigureAwait(false);
|
||||
return await RunOnFrameworkThread(() => _cid.Value.ToString().GetHash256()).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private unsafe string GetHashedAccIdFromPlayerPointer(nint ptr)
|
||||
private unsafe static string GetHashedCIDFromPlayerPointer(nint ptr)
|
||||
{
|
||||
if (ptr == nint.Zero) return "UNK" + _aidCounter++;
|
||||
var aid = ((BattleChara*)ptr)->Character.AccountId;
|
||||
if (!_aidCache.TryGetValue(aid, out string? hash))
|
||||
{
|
||||
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 ((BattleChara*)ptr)->Character.ContentId.ToString().GetHash256();
|
||||
}
|
||||
|
||||
public IntPtr GetPlayerPtr()
|
||||
@@ -646,7 +625,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
}
|
||||
|
||||
var charaName = ((GameObject*)chara.Address)->NameString;
|
||||
var hash = GetHashedAccIdFromPlayerPointer(chara.Address);
|
||||
var hash = GetHashedCIDFromPlayerPointer(chara.Address);
|
||||
if (!IsAnythingDrawing)
|
||||
CheckCharacterForDrawing(chara.Address, charaName);
|
||||
_notUpdatedCharas.Remove(hash);
|
||||
@@ -762,7 +741,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
_logger.LogDebug("Logged in");
|
||||
IsLoggedIn = true;
|
||||
_lastZone = _clientState.TerritoryType;
|
||||
_aid = RebuildAid();
|
||||
_cid = RebuildCID();
|
||||
Mediator.Publish(new DalamudLoginMessage());
|
||||
}
|
||||
else if (localPlayer == null && IsLoggedIn)
|
||||
|
||||
Reference in New Issue
Block a user