mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-18 05:47:52 +01:00
No EST files anymore.
This commit is contained in:
parent
943207cae8
commit
ebef4ff650
8 changed files with 68 additions and 183 deletions
49
Penumbra/Interop/Hooks/Meta/EstHook.cs
Normal file
49
Penumbra/Interop/Hooks/Meta/EstHook.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using OtterGui.Services;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Structs;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
|
||||
namespace Penumbra.Interop.Hooks.Meta;
|
||||
|
||||
public class EstHook : FastHook<EstHook.Delegate>
|
||||
{
|
||||
public delegate EstEntry Delegate(uint id, int estType, uint genderRace);
|
||||
|
||||
private readonly MetaState _metaState;
|
||||
|
||||
public EstHook(HookManager hooks, MetaState metaState)
|
||||
{
|
||||
_metaState = metaState;
|
||||
Task = hooks.CreateHook<Delegate>("GetEstEntry", "44 8B C9 83 EA ?? 74", Detour, true);
|
||||
}
|
||||
|
||||
private EstEntry Detour(uint genderRace, int estType, uint id)
|
||||
{
|
||||
EstEntry ret;
|
||||
if (_metaState.EstCollection is { Valid: true, ModCollection.MetaCache: { } cache }
|
||||
&& cache.Est.TryGetValue(Convert(genderRace, estType, id), out var entry))
|
||||
ret = entry.Entry;
|
||||
else
|
||||
ret = Task.Result.Original(genderRace, estType, id);
|
||||
|
||||
Penumbra.Log.Information($"[GetEstEntry] Invoked with {genderRace}, {estType}, {id}, returned {ret.Value}.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static EstIdentifier Convert(uint genderRace, int estType, uint id)
|
||||
{
|
||||
var i = new PrimaryId((ushort)id);
|
||||
var gr = (GenderRace)genderRace;
|
||||
var type = estType switch
|
||||
{
|
||||
1 => EstType.Face,
|
||||
2 => EstType.Hair,
|
||||
3 => EstType.Head,
|
||||
4 => EstType.Body,
|
||||
_ => (EstType)0,
|
||||
};
|
||||
return new EstIdentifier(i, type, gr);
|
||||
}
|
||||
}
|
||||
|
|
@ -158,26 +158,26 @@ public sealed unsafe class ResolvePathHooksBase : IDisposable
|
|||
|
||||
private nint ResolvePapHuman(nint drawObject, nint pathBuffer, nint pathBufferSize, uint unkAnimationIndex, nint animationName)
|
||||
{
|
||||
using var est = GetEstChanges(drawObject, out var data);
|
||||
return ResolvePath(data, _resolvePapPathHook.Original(drawObject, pathBuffer, pathBufferSize, unkAnimationIndex, animationName));
|
||||
_parent.MetaState.EstCollection = _parent.CollectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||
return ResolvePath(_parent.MetaState.EstCollection, _resolvePapPathHook.Original(drawObject, pathBuffer, pathBufferSize, unkAnimationIndex, animationName));
|
||||
}
|
||||
|
||||
private nint ResolvePhybHuman(nint drawObject, nint pathBuffer, nint pathBufferSize, uint partialSkeletonIndex)
|
||||
{
|
||||
using var est = GetEstChanges(drawObject, out var data);
|
||||
return ResolvePath(data, _resolvePhybPathHook.Original(drawObject, pathBuffer, pathBufferSize, partialSkeletonIndex));
|
||||
_parent.MetaState.EstCollection = _parent.CollectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||
return ResolvePath(_parent.MetaState.EstCollection, _resolvePhybPathHook.Original(drawObject, pathBuffer, pathBufferSize, partialSkeletonIndex));
|
||||
}
|
||||
|
||||
private nint ResolveSklbHuman(nint drawObject, nint pathBuffer, nint pathBufferSize, uint partialSkeletonIndex)
|
||||
{
|
||||
using var est = GetEstChanges(drawObject, out var data);
|
||||
return ResolvePath(data, _resolveSklbPathHook.Original(drawObject, pathBuffer, pathBufferSize, partialSkeletonIndex));
|
||||
_parent.MetaState.EstCollection = _parent.CollectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||
return ResolvePath(_parent.MetaState.EstCollection, _resolveSklbPathHook.Original(drawObject, pathBuffer, pathBufferSize, partialSkeletonIndex));
|
||||
}
|
||||
|
||||
private nint ResolveSkpHuman(nint drawObject, nint pathBuffer, nint pathBufferSize, uint partialSkeletonIndex)
|
||||
{
|
||||
using var est = GetEstChanges(drawObject, out var data);
|
||||
return ResolvePath(data, _resolveSkpPathHook.Original(drawObject, pathBuffer, pathBufferSize, partialSkeletonIndex));
|
||||
_parent.MetaState.EstCollection = _parent.CollectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||
return ResolvePath(_parent.MetaState.EstCollection, _resolveSkpPathHook.Original(drawObject, pathBuffer, pathBufferSize, partialSkeletonIndex));
|
||||
}
|
||||
|
||||
private nint ResolveVfxHuman(nint drawObject, nint pathBuffer, nint pathBufferSize, uint slotIndex, nint unkOutParam)
|
||||
|
|
@ -206,19 +206,6 @@ public sealed unsafe class ResolvePathHooksBase : IDisposable
|
|||
return ResolvePath(drawObject, pathBuffer);
|
||||
}
|
||||
|
||||
private DisposableContainer GetEstChanges(nint drawObject, out ResolveData data)
|
||||
{
|
||||
data = _parent.CollectionResolver.IdentifyCollection((DrawObject*)drawObject, true);
|
||||
if (_parent.InInternalResolve)
|
||||
return DisposableContainer.Empty;
|
||||
|
||||
return new DisposableContainer(data.ModCollection.TemporarilySetEstFile(_parent.CharacterUtility, EstType.Face),
|
||||
data.ModCollection.TemporarilySetEstFile(_parent.CharacterUtility, EstType.Body),
|
||||
data.ModCollection.TemporarilySetEstFile(_parent.CharacterUtility, EstType.Hair),
|
||||
data.ModCollection.TemporarilySetEstFile(_parent.CharacterUtility, EstType.Head));
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static Hook<T> Create<T>(string name, HookManager hooks, nint address, Type type, T other, T human) where T : Delegate
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace Penumbra.Interop.PathResolving;
|
|||
// GetSlotEqpData seems to be the only function using the EQP table.
|
||||
// It is only called by CheckSlotsForUnload (called by UpdateModels),
|
||||
// SetupModelAttributes (called by UpdateModels and OnModelLoadComplete)
|
||||
// and a unnamed function called by UpdateRender.
|
||||
// and an unnamed function called by UpdateRender.
|
||||
// It seems to be enough to change the EQP entries for UpdateModels.
|
||||
|
||||
// GetEqdpDataFor[Adults|Children|Other] seem to be the only functions using the EQDP tables.
|
||||
|
|
@ -35,7 +35,7 @@ namespace Penumbra.Interop.PathResolving;
|
|||
// they all are called by many functions, but the most relevant seem to be Human.SetupFromCharacterData, which is only called by CharacterBase.Create,
|
||||
// ChangeCustomize and RspSetupCharacter, which is hooked here, as well as Character.CalculateHeight.
|
||||
|
||||
// GMP Entries seem to be only used by "48 8B ?? 53 55 57 48 83 ?? ?? 48 8B", which has a DrawObject as its first parameter.
|
||||
// GMP Entries seem to be only used by "48 8B ?? 53 55 57 48 83 ?? ?? 48 8B", which is SetupVisor.
|
||||
public sealed unsafe class MetaState : IDisposable
|
||||
{
|
||||
private readonly Configuration _config;
|
||||
|
|
@ -48,6 +48,7 @@ public sealed unsafe class MetaState : IDisposable
|
|||
public ResolveData CustomizeChangeCollection = ResolveData.Invalid;
|
||||
public ResolveData EqpCollection = ResolveData.Invalid;
|
||||
public ResolveData GmpCollection = ResolveData.Invalid;
|
||||
public ResolveData EstCollection = ResolveData.Invalid;
|
||||
public PrimaryId UndividedGmpId = 0;
|
||||
|
||||
private ResolveData _lastCreatedCollection = ResolveData.Invalid;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue