diff --git a/MareSynchronos/FileCache/TransientResourceManager.cs b/MareSynchronos/FileCache/TransientResourceManager.cs index 6dd9802..f514df1 100644 --- a/MareSynchronos/FileCache/TransientResourceManager.cs +++ b/MareSynchronos/FileCache/TransientResourceManager.cs @@ -18,7 +18,7 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase private readonly DalamudUtilService _dalamudUtil; private readonly string[] _fileTypesToHandle = ["tmb", "pap", "avfx", "atex", "sklb", "eid", "phyb", "scd", "skp", "shpk"]; private readonly HashSet _playerRelatedPointers = []; - private Dictionary _cachedFrameAddresses = []; + private ConcurrentDictionary _cachedFrameAddresses = []; private ConcurrentDictionary>? _semiTransientResources = null; private uint _lastClassJobId = uint.MaxValue; @@ -174,7 +174,7 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase private void DalamudUtil_FrameworkUpdate() { - _cachedFrameAddresses = _playerRelatedPointers.Where(k => k.Address != nint.Zero).ToDictionary(c => c.CurrentAddress(), c => c.ObjectKind); + _cachedFrameAddresses = _cachedFrameAddresses = new ConcurrentDictionary(_playerRelatedPointers.Where(k => k.Address != nint.Zero).ToDictionary(c => c.CurrentAddress(), c => c.ObjectKind)); lock (_cacheAdditionLock) { _cachedHandledPaths.Clear(); diff --git a/MareSynchronos/Interop/BlockedCharacterHandler.cs b/MareSynchronos/Interop/BlockedCharacterHandler.cs index 5e3df7b..52b9414 100644 --- a/MareSynchronos/Interop/BlockedCharacterHandler.cs +++ b/MareSynchronos/Interop/BlockedCharacterHandler.cs @@ -1,5 +1,4 @@ using Dalamud.Plugin.Services; -using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.Game.Character; using FFXIVClientStructs.FFXIV.Client.UI.Info; using Microsoft.Extensions.Logging; @@ -11,19 +10,8 @@ public unsafe class BlockedCharacterHandler private sealed record CharaData(ulong AccId, ulong ContentId); private readonly Dictionary _blockedCharacterCache = new(); - private enum BlockResultType - { - NotBlocked = 1, - BlockedByAccountId = 2, - BlockedByContentId = 3, - } - - [Signature("48 83 EC 48 F6 81 ?? ?? ?? ?? ?? 75 ?? 33 C0 48 83 C4 48")] - private readonly GetBlockResultTypeDelegate? _getBlockResultType = null; private readonly ILogger _logger; - private unsafe delegate BlockResultType GetBlockResultTypeDelegate(InfoProxyBlacklist* thisPtr, ulong accountId, ulong contentId); - public BlockedCharacterHandler(ILogger logger, IGameInteropProvider gameInteropProvider) { gameInteropProvider.InitializeFromAttributes(this); @@ -44,13 +32,9 @@ public unsafe class BlockedCharacterHandler if (_blockedCharacterCache.TryGetValue(combined, out var isBlocked)) return isBlocked; - if (_getBlockResultType == null) - return _blockedCharacterCache[combined] = false; - firstTime = true; - var infoProxy = InfoProxyBlacklist.Instance(); - var blockStatus = _getBlockResultType(infoProxy, combined.AccId, combined.ContentId); + var blockStatus = InfoProxyBlacklist.Instance()->GetBlockResultType(combined.AccId, combined.ContentId); _logger.LogTrace("CharaPtr {ptr} is BlockStatus: {status}", ptr, blockStatus); - return _blockedCharacterCache[combined] = blockStatus != BlockResultType.NotBlocked; + return _blockedCharacterCache[combined] = blockStatus != InfoProxyBlacklist.BlockResultType.NotBlocked; } } diff --git a/MareSynchronos/MareSynchronos.csproj b/MareSynchronos/MareSynchronos.csproj index 3a1791d..19e190a 100644 --- a/MareSynchronos/MareSynchronos.csproj +++ b/MareSynchronos/MareSynchronos.csproj @@ -29,16 +29,16 @@ - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + @@ -48,7 +48,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/MareSynchronos/Services/DalamudUtilService.cs b/MareSynchronos/Services/DalamudUtilService.cs index d59b144..20d1494 100644 --- a/MareSynchronos/Services/DalamudUtilService.cs +++ b/MareSynchronos/Services/DalamudUtilService.cs @@ -55,8 +55,8 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber _performanceCollector = performanceCollector; WorldData = new(() => { - return gameData.GetExcelSheet(Dalamud.Game.ClientLanguage.English)! - .Where(w => !w.Name.RawData.IsEmpty && w.DataCenter.Row != 0 && (w.IsPublic || char.IsUpper((char)w.Name.RawData[0]))) + return gameData.GetExcelSheet(Dalamud.Game.ClientLanguage.English)! + .Where(w => !w.Name.IsEmpty && w.DataCenter.RowId != 0 && (w.IsPublic || char.IsUpper(w.Name.ToString()[0]))) .ToDictionary(w => (ushort)w.RowId, w => w.Name.ToString()); }); mediator.Subscribe(this, (msg) => @@ -222,13 +222,13 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber public uint GetHomeWorldId() { EnsureIsOnFramework(); - return _clientState.LocalPlayer!.HomeWorld.Id; + return _clientState.LocalPlayer!.HomeWorld.RowId; } public uint GetWorldId() { EnsureIsOnFramework(); - return _clientState.LocalPlayer!.CurrentWorld.Id; + return _clientState.LocalPlayer!.CurrentWorld.RowId; } public async Task GetWorldIdAsync() @@ -302,7 +302,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber _framework.Update += FrameworkOnUpdate; if (IsLoggedIn) { - _classJobId = _clientState.LocalPlayer!.ClassJob.Id; + _classJobId = _clientState.LocalPlayer!.ClassJob.RowId; } _logger.LogInformation("Started DalamudUtilService"); @@ -567,7 +567,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber var localPlayer = _clientState.LocalPlayer; if (localPlayer != null) { - _classJobId = localPlayer.ClassJob.Id; + _classJobId = localPlayer.ClassJob.RowId; } if (!IsInCombatOrPerforming)