mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Use different hooking method for EQP entries.
This commit is contained in:
parent
4743acf767
commit
bad1f45ab9
7 changed files with 82 additions and 6 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit ec35e66499eb388b4e7917e4fae4615218d33335
|
||||
Subproject commit 539d138700543e7c2c6c918f9f68e33228111e4d
|
||||
34
Penumbra/Interop/Hooks/Meta/EqpHook.cs
Normal file
34
Penumbra/Interop/Hooks/Meta/EqpHook.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.GameData.Structs;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
|
||||
namespace Penumbra.Interop.Hooks.Meta;
|
||||
|
||||
public unsafe class EqpHook : FastHook<EqpHook.Delegate>
|
||||
{
|
||||
public delegate void Delegate(CharacterUtility* utility, EqpEntry* flags, CharacterArmor* armor);
|
||||
|
||||
private readonly MetaState _metaState;
|
||||
|
||||
public EqpHook(HookManager hooks, MetaState metaState)
|
||||
{
|
||||
_metaState = metaState;
|
||||
Task = hooks.CreateHook<Delegate>("GetEqpFlags", "E8 ?? ?? ?? ?? 0F B6 44 24 ?? C0 E8", Detour, true);
|
||||
}
|
||||
|
||||
private void Detour(CharacterUtility* utility, EqpEntry* flags, CharacterArmor* armor)
|
||||
{
|
||||
if (_metaState.EqpCollection.Valid)
|
||||
{
|
||||
using var eqp = _metaState.ResolveEqpData(_metaState.EqpCollection.ModCollection);
|
||||
Task.Result.Original(utility, flags, armor);
|
||||
}
|
||||
else
|
||||
{
|
||||
Task.Result.Original(utility, flags, armor);
|
||||
}
|
||||
|
||||
Penumbra.Log.Excessive($"[GetEqpFlags] Invoked on 0x{(nint)utility:X} with 0x{(ulong)armor:X}, returned 0x{(ulong)*flags:X16}.");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
|
||||
|
|
@ -28,8 +29,8 @@ public sealed unsafe class GetEqpIndirect : FastHook<GetEqpIndirect.Delegate>
|
|||
return;
|
||||
|
||||
Penumbra.Log.Excessive($"[Get EQP Indirect] Invoked on {(nint)drawObject:X}.");
|
||||
var collection = _collectionResolver.IdentifyCollection(drawObject, true);
|
||||
using var eqp = _metaState.ResolveEqpData(collection.ModCollection);
|
||||
_metaState.EqpCollection = _collectionResolver.IdentifyCollection(drawObject, true);
|
||||
Task.Result.Original(drawObject);
|
||||
_metaState.EqpCollection = ResolveData.Invalid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
36
Penumbra/Interop/Hooks/Meta/GetEqpIndirect2.cs
Normal file
36
Penumbra/Interop/Hooks/Meta/GetEqpIndirect2.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
|
||||
namespace Penumbra.Interop.Hooks.Meta;
|
||||
|
||||
public sealed unsafe class GetEqpIndirect2 : FastHook<GetEqpIndirect2.Delegate>
|
||||
{
|
||||
private readonly CollectionResolver _collectionResolver;
|
||||
private readonly MetaState _metaState;
|
||||
|
||||
public GetEqpIndirect2(HookManager hooks, CollectionResolver collectionResolver, MetaState metaState)
|
||||
{
|
||||
_collectionResolver = collectionResolver;
|
||||
_metaState = metaState;
|
||||
Task = hooks.CreateHook<Delegate>("Get EQP Indirect 2", Sigs.GetEqpIndirect2, Detour, true);
|
||||
}
|
||||
|
||||
public delegate void Delegate(DrawObject* drawObject);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private void Detour(DrawObject* drawObject)
|
||||
{
|
||||
// Shortcut because this is also called all the time.
|
||||
// Same thing is checked at the beginning of the original function.
|
||||
if (((*(uint*)((nint)drawObject + Offsets.GetEqpIndirect2Skip) >> 0x12) & 1) == 0)
|
||||
return;
|
||||
|
||||
Penumbra.Log.Excessive($"[Get EQP Indirect 2] Invoked on {(nint)drawObject:X}.");
|
||||
_metaState.EqpCollection = _collectionResolver.IdentifyCollection(drawObject, true);
|
||||
Task.Result.Original(drawObject);
|
||||
_metaState.EqpCollection = ResolveData.Invalid;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
|
||||
namespace Penumbra.Interop.Hooks.Meta;
|
||||
|
|
@ -23,8 +24,9 @@ public sealed unsafe class ModelLoadComplete : FastHook<ModelLoadComplete.Delega
|
|||
{
|
||||
Penumbra.Log.Excessive($"[Model Load Complete] Invoked on {(nint)drawObject:X}.");
|
||||
var collection = _collectionResolver.IdentifyCollection(drawObject, true);
|
||||
using var eqp = _metaState.ResolveEqpData(collection.ModCollection);
|
||||
using var eqdp = _metaState.ResolveEqdpData(collection.ModCollection, MetaState.GetDrawObjectGenderRace((nint)drawObject), true, true);
|
||||
_metaState.EqpCollection = collection;
|
||||
Task.Result.Original(drawObject);
|
||||
_metaState.EqpCollection = ResolveData.Invalid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
|
||||
using OtterGui.Services;
|
||||
using Penumbra.Collections;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
|
||||
|
|
@ -29,8 +30,9 @@ public sealed unsafe class UpdateModel : FastHook<UpdateModel.Delegate>
|
|||
|
||||
Penumbra.Log.Excessive($"[Update Model] Invoked on {(nint)drawObject:X}.");
|
||||
var collection = _collectionResolver.IdentifyCollection(drawObject, true);
|
||||
using var eqp = _metaState.ResolveEqpData(collection.ModCollection);
|
||||
using var eqdp = _metaState.ResolveEqdpData(collection.ModCollection, MetaState.GetDrawObjectGenderRace((nint)drawObject), true, true);
|
||||
Task.Result.Original.Invoke(drawObject);
|
||||
_metaState.EqpCollection = collection;
|
||||
Task.Result.Original(drawObject);
|
||||
_metaState.EqpCollection = ResolveData.Invalid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public sealed unsafe class MetaState : IDisposable
|
|||
private readonly CreateCharacterBase _createCharacterBase;
|
||||
|
||||
public ResolveData CustomizeChangeCollection = ResolveData.Invalid;
|
||||
public ResolveData EqpCollection = ResolveData.Invalid;
|
||||
|
||||
private ResolveData _lastCreatedCollection = ResolveData.Invalid;
|
||||
private DisposableContainer _characterBaseCreateMetaChanges = DisposableContainer.Empty;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue