mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Fix for EQDP not working on redraws due to resetting itself early.
This commit is contained in:
parent
c7344efdc2
commit
6949011acf
2 changed files with 38 additions and 10 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
|
using Dalamud.Logging;
|
||||||
using Dalamud.Utility.Signatures;
|
using Dalamud.Utility.Signatures;
|
||||||
|
using Penumbra.Meta.Files;
|
||||||
using Penumbra.Meta.Manipulations;
|
using Penumbra.Meta.Manipulations;
|
||||||
using Penumbra.Mods;
|
using Penumbra.Mods;
|
||||||
|
|
||||||
|
|
@ -171,12 +173,26 @@ public unsafe partial class PathResolver
|
||||||
|
|
||||||
|
|
||||||
// Small helper to handle setting metadata and reverting it at the end of the function.
|
// Small helper to handle setting metadata and reverting it at the end of the function.
|
||||||
|
// Since eqp and eqdp may be called multiple times in a row, we need to count them,
|
||||||
|
// so that we do not reset the files too early.
|
||||||
private readonly struct MetaChanger : IDisposable
|
private readonly struct MetaChanger : IDisposable
|
||||||
{
|
{
|
||||||
|
private static int _eqpCounter;
|
||||||
|
private static int _eqdpCounter;
|
||||||
private readonly MetaManipulation.Type _type;
|
private readonly MetaManipulation.Type _type;
|
||||||
|
|
||||||
private MetaChanger( MetaManipulation.Type type )
|
private MetaChanger( MetaManipulation.Type type )
|
||||||
=> _type = type;
|
{
|
||||||
|
_type = type;
|
||||||
|
if( type == MetaManipulation.Type.Eqp )
|
||||||
|
{
|
||||||
|
++_eqpCounter;
|
||||||
|
}
|
||||||
|
else if( type == MetaManipulation.Type.Eqdp )
|
||||||
|
{
|
||||||
|
++_eqdpCounter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static MetaChanger ChangeEqp( ModCollection collection )
|
public static MetaChanger ChangeEqp( ModCollection collection )
|
||||||
{
|
{
|
||||||
|
|
@ -200,13 +216,17 @@ public unsafe partial class PathResolver
|
||||||
return new MetaChanger( MetaManipulation.Type.Unknown );
|
return new MetaChanger( MetaManipulation.Type.Unknown );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MetaChanger ChangeEqdp( PathResolver resolver, IntPtr drawObject )
|
// We only need to change anything if it is actually equipment here.
|
||||||
|
public static MetaChanger ChangeEqdp( PathResolver resolver, IntPtr drawObject, uint modelType )
|
||||||
{
|
{
|
||||||
#if USE_EQDP
|
#if USE_EQDP
|
||||||
var collection = resolver.GetCollection( drawObject );
|
if( modelType < 10 )
|
||||||
if( collection != null )
|
|
||||||
{
|
{
|
||||||
return ChangeEqdp( collection );
|
var collection = resolver.GetCollection( drawObject );
|
||||||
|
if( collection != null )
|
||||||
|
{
|
||||||
|
return ChangeEqdp( collection );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return new MetaChanger( MetaManipulation.Type.Unknown );
|
return new MetaChanger( MetaManipulation.Type.Unknown );
|
||||||
|
|
@ -287,10 +307,18 @@ public unsafe partial class PathResolver
|
||||||
switch( _type )
|
switch( _type )
|
||||||
{
|
{
|
||||||
case MetaManipulation.Type.Eqdp:
|
case MetaManipulation.Type.Eqdp:
|
||||||
Penumbra.ModManager.Collections.DefaultCollection.SetEqdpFiles();
|
if( --_eqdpCounter == 0 )
|
||||||
|
{
|
||||||
|
Penumbra.ModManager.Collections.DefaultCollection.SetEqdpFiles();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MetaManipulation.Type.Eqp:
|
case MetaManipulation.Type.Eqp:
|
||||||
Penumbra.ModManager.Collections.DefaultCollection.SetEqpFiles();
|
if( --_eqpCounter == 0 )
|
||||||
|
{
|
||||||
|
Penumbra.ModManager.Collections.DefaultCollection.SetEqpFiles();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MetaManipulation.Type.Est:
|
case MetaManipulation.Type.Est:
|
||||||
Penumbra.ModManager.Collections.DefaultCollection.SetEstFiles();
|
Penumbra.ModManager.Collections.DefaultCollection.SetEstFiles();
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,10 @@ public unsafe partial class PathResolver
|
||||||
private IntPtr ResolveMPapDetour( IntPtr drawObject, IntPtr path, IntPtr unk3, uint unk4, uint unk5 )
|
private IntPtr ResolveMPapDetour( IntPtr drawObject, IntPtr path, IntPtr unk3, uint unk4, uint unk5 )
|
||||||
=> ResolvePathDetour( drawObject, ResolveMPapPathHook!.Original( drawObject, path, unk3, unk4, unk5 ) );
|
=> ResolvePathDetour( drawObject, ResolveMPapPathHook!.Original( drawObject, path, unk3, unk4, unk5 ) );
|
||||||
|
|
||||||
private IntPtr ResolveMdlDetour( IntPtr drawObject, IntPtr path, IntPtr unk3, uint unk4 )
|
private IntPtr ResolveMdlDetour( IntPtr drawObject, IntPtr path, IntPtr unk3, uint modelType )
|
||||||
{
|
{
|
||||||
using var eqdp = MetaChanger.ChangeEqdp( this, drawObject );
|
using var eqdp = MetaChanger.ChangeEqdp( this, drawObject, modelType );
|
||||||
return ResolvePathDetour( drawObject, ResolveMdlPathHook!.Original( drawObject, path, unk3, unk4 ) );
|
return ResolvePathDetour( drawObject, ResolveMdlPathHook!.Original( drawObject, path, unk3, modelType ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntPtr ResolveMtrlDetour( IntPtr drawObject, IntPtr path, IntPtr unk3, uint unk4, ulong unk5 )
|
private IntPtr ResolveMtrlDetour( IntPtr drawObject, IntPtr path, IntPtr unk3, uint unk4, ulong unk5 )
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue