rebuild aid on login

This commit is contained in:
rootdarkarchon
2025-04-21 10:25:01 +02:00
parent 85058379e7
commit c0870e85df

View File

@@ -47,7 +47,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
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 readonly Dictionary<ulong, string> _aidCache = [];
private readonly Lazy<uint> _aid; private Lazy<uint> _aid;
private int _aidCounter = 0; 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,
@@ -64,6 +64,7 @@ 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(() =>
{ {
@@ -126,12 +127,15 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
}).ConfigureAwait(false); }).ConfigureAwait(false);
}); });
IsWine = Util.IsWine(); IsWine = Util.IsWine();
_aid = RebuildAid();
}
_aid = new(() => private Lazy<uint> RebuildAid() {
return new(() =>
{ {
unsafe unsafe
{ {
var address = sigScanner.GetStaticAddressFromSig("48 8B 0D ?? ?? ?? ?? 4C 8B CA"); var address = _sigScanner.GetStaticAddressFromSig("48 8B 0D ?? ?? ?? ?? 4C 8B CA");
return (uint)(address != nint.Zero ? (*(ulong**)address)[1] : 0u); return (uint)(address != nint.Zero ? (*(ulong**)address)[1] : 0u);
} }
}); });
@@ -172,6 +176,9 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
public MareMediator Mediator { get; } public MareMediator Mediator { get; }
private readonly ISigScanner _sigScanner;
public IGameObject? CreateGameObject(IntPtr reference) public IGameObject? CreateGameObject(IntPtr reference)
{ {
EnsureIsOnFramework(); EnsureIsOnFramework();
@@ -758,6 +765,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();
Mediator.Publish(new DalamudLoginMessage()); Mediator.Publish(new DalamudLoginMessage());
} }
else if (localPlayer == null && IsLoggedIn) else if (localPlayer == null && IsLoggedIn)