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