api11 changes

This commit is contained in:
Stanley Dimant
2024-11-16 01:23:00 +01:00
parent 1b83e7b361
commit 514d254386
4 changed files with 17 additions and 33 deletions

View File

@@ -18,7 +18,7 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase
private readonly DalamudUtilService _dalamudUtil; private readonly DalamudUtilService _dalamudUtil;
private readonly string[] _fileTypesToHandle = ["tmb", "pap", "avfx", "atex", "sklb", "eid", "phyb", "scd", "skp", "shpk"]; private readonly string[] _fileTypesToHandle = ["tmb", "pap", "avfx", "atex", "sklb", "eid", "phyb", "scd", "skp", "shpk"];
private readonly HashSet<GameObjectHandler> _playerRelatedPointers = []; private readonly HashSet<GameObjectHandler> _playerRelatedPointers = [];
private Dictionary<IntPtr, ObjectKind> _cachedFrameAddresses = []; private ConcurrentDictionary<IntPtr, ObjectKind> _cachedFrameAddresses = [];
private ConcurrentDictionary<ObjectKind, HashSet<string>>? _semiTransientResources = null; private ConcurrentDictionary<ObjectKind, HashSet<string>>? _semiTransientResources = null;
private uint _lastClassJobId = uint.MaxValue; private uint _lastClassJobId = uint.MaxValue;
@@ -174,7 +174,7 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase
private void DalamudUtil_FrameworkUpdate() private void DalamudUtil_FrameworkUpdate()
{ {
_cachedFrameAddresses = _playerRelatedPointers.Where(k => k.Address != nint.Zero).ToDictionary(c => c.CurrentAddress(), c => c.ObjectKind); _cachedFrameAddresses = _cachedFrameAddresses = new ConcurrentDictionary<nint, ObjectKind>(_playerRelatedPointers.Where(k => k.Address != nint.Zero).ToDictionary(c => c.CurrentAddress(), c => c.ObjectKind));
lock (_cacheAdditionLock) lock (_cacheAdditionLock)
{ {
_cachedHandledPaths.Clear(); _cachedHandledPaths.Clear();

View File

@@ -1,5 +1,4 @@
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Game.Character; using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.UI.Info; using FFXIVClientStructs.FFXIV.Client.UI.Info;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@@ -11,19 +10,8 @@ public unsafe class BlockedCharacterHandler
private sealed record CharaData(ulong AccId, ulong ContentId); private sealed record CharaData(ulong AccId, ulong ContentId);
private readonly Dictionary<CharaData, bool> _blockedCharacterCache = new(); private readonly Dictionary<CharaData, bool> _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<BlockedCharacterHandler> _logger; private readonly ILogger<BlockedCharacterHandler> _logger;
private unsafe delegate BlockResultType GetBlockResultTypeDelegate(InfoProxyBlacklist* thisPtr, ulong accountId, ulong contentId);
public BlockedCharacterHandler(ILogger<BlockedCharacterHandler> logger, IGameInteropProvider gameInteropProvider) public BlockedCharacterHandler(ILogger<BlockedCharacterHandler> logger, IGameInteropProvider gameInteropProvider)
{ {
gameInteropProvider.InitializeFromAttributes(this); gameInteropProvider.InitializeFromAttributes(this);
@@ -44,13 +32,9 @@ public unsafe class BlockedCharacterHandler
if (_blockedCharacterCache.TryGetValue(combined, out var isBlocked)) if (_blockedCharacterCache.TryGetValue(combined, out var isBlocked))
return isBlocked; return isBlocked;
if (_getBlockResultType == null)
return _blockedCharacterCache[combined] = false;
firstTime = true; firstTime = true;
var infoProxy = InfoProxyBlacklist.Instance(); var blockStatus = InfoProxyBlacklist.Instance()->GetBlockResultType(combined.AccId, combined.ContentId);
var blockStatus = _getBlockResultType(infoProxy, combined.AccId, combined.ContentId);
_logger.LogTrace("CharaPtr {ptr} is BlockStatus: {status}", ptr, blockStatus); _logger.LogTrace("CharaPtr {ptr} is BlockStatus: {status}", ptr, blockStatus);
return _blockedCharacterCache[combined] = blockStatus != BlockResultType.NotBlocked; return _blockedCharacterCache[combined] = blockStatus != InfoProxyBlacklist.BlockResultType.NotBlocked;
} }
} }

View File

@@ -29,16 +29,16 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.13" /> <PackageReference Include="DalamudPackager" Version="11.0.0" />
<PackageReference Include="Downloader" Version="3.1.2" /> <PackageReference Include="Downloader" Version="3.2.1" />
<PackageReference Include="lz4net" Version="1.0.15.93" /> <PackageReference Include="lz4net" Version="1.0.15.93" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.163"> <PackageReference Include="Meziantou.Analyzer" Version="2.0.179">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.8" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.8" /> <PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.11" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="Glamourer.Api" Version="2.2.0" /> <PackageReference Include="Glamourer.Api" Version="2.2.0" />
<PackageReference Include="NReco.Logging.File" Version="1.2.1" /> <PackageReference Include="NReco.Logging.File" Version="1.2.1" />
<PackageReference Include="Penumbra.Api" Version="5.3.0" /> <PackageReference Include="Penumbra.Api" Version="5.3.0" />
@@ -48,7 +48,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.2" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.2.1" />
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>

View File

@@ -55,8 +55,8 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
_performanceCollector = performanceCollector; _performanceCollector = performanceCollector;
WorldData = new(() => WorldData = new(() =>
{ {
return gameData.GetExcelSheet<Lumina.Excel.GeneratedSheets.World>(Dalamud.Game.ClientLanguage.English)! return gameData.GetExcelSheet<Lumina.Excel.Sheets.World>(Dalamud.Game.ClientLanguage.English)!
.Where(w => !w.Name.RawData.IsEmpty && w.DataCenter.Row != 0 && (w.IsPublic || char.IsUpper((char)w.Name.RawData[0]))) .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()); .ToDictionary(w => (ushort)w.RowId, w => w.Name.ToString());
}); });
mediator.Subscribe<TargetPairMessage>(this, (msg) => mediator.Subscribe<TargetPairMessage>(this, (msg) =>
@@ -222,13 +222,13 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
public uint GetHomeWorldId() public uint GetHomeWorldId()
{ {
EnsureIsOnFramework(); EnsureIsOnFramework();
return _clientState.LocalPlayer!.HomeWorld.Id; return _clientState.LocalPlayer!.HomeWorld.RowId;
} }
public uint GetWorldId() public uint GetWorldId()
{ {
EnsureIsOnFramework(); EnsureIsOnFramework();
return _clientState.LocalPlayer!.CurrentWorld.Id; return _clientState.LocalPlayer!.CurrentWorld.RowId;
} }
public async Task<uint> GetWorldIdAsync() public async Task<uint> GetWorldIdAsync()
@@ -302,7 +302,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
_framework.Update += FrameworkOnUpdate; _framework.Update += FrameworkOnUpdate;
if (IsLoggedIn) if (IsLoggedIn)
{ {
_classJobId = _clientState.LocalPlayer!.ClassJob.Id; _classJobId = _clientState.LocalPlayer!.ClassJob.RowId;
} }
_logger.LogInformation("Started DalamudUtilService"); _logger.LogInformation("Started DalamudUtilService");
@@ -567,7 +567,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
var localPlayer = _clientState.LocalPlayer; var localPlayer = _clientState.LocalPlayer;
if (localPlayer != null) if (localPlayer != null)
{ {
_classJobId = localPlayer.ClassJob.Id; _classJobId = localPlayer.ClassJob.RowId;
} }
if (!IsInCombatOrPerforming) if (!IsInCombatOrPerforming)