remove Penumbra dependency and use nuget, minor internal refactoring of structs, more resilent downloads

This commit is contained in:
rootdarkarchon
2022-12-18 13:00:34 +01:00
parent 5263ab839b
commit ffd896168c
13 changed files with 58 additions and 105 deletions

View File

@@ -8,18 +8,6 @@ public unsafe struct Material
{
[FieldOffset( 0x10 )]
public ResourceHandle* ResourceHandle;
[FieldOffset( 0x28 )]
public MaterialData* MaterialData;
[FieldOffset( 0x48 )]
public Texture* Tex1;
[FieldOffset( 0x60 )]
public Texture* Tex2;
[FieldOffset( 0x78 )]
public Texture* Tex3;
}
[StructLayout( LayoutKind.Explicit )]

View File

@@ -1,3 +1,4 @@
using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle;
using System.Runtime.InteropServices;
namespace Penumbra.Interop.Structs;

View File

@@ -1,5 +1,6 @@
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.Graphics.Render;
using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle;
namespace Penumbra.Interop.Structs;

View File

@@ -1,26 +1,12 @@
using System;
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.System.Resource;
using Penumbra.GameData.Enums;
namespace Penumbra.Interop.Structs;
[StructLayout( LayoutKind.Explicit )]
public unsafe struct ResourceHandle
{
[StructLayout( LayoutKind.Explicit )]
public struct DataIndirection
{
[FieldOffset( 0x00 )]
public void** VTable;
[FieldOffset( 0x10 )]
public byte* DataPtr;
[FieldOffset( 0x28 )]
public ulong DataLength;
}
public const int SsoSize = 15;
public byte* FileName()
@@ -36,61 +22,12 @@ public unsafe struct ResourceHandle
}
}
public ReadOnlySpan< byte > FileNameSpan()
=> new(FileName(), FileNameLength);
[FieldOffset( 0x00 )]
public void** VTable;
[FieldOffset( 0x08 )]
public ResourceCategory Category;
[FieldOffset( 0x0C )]
public ResourceType FileType;
[FieldOffset( 0x10 )]
public uint Id;
[FieldOffset( 0x48 )]
public byte* FileNameData;
[FieldOffset( 0x58 )]
public int FileNameLength;
[FieldOffset( 0xAC )]
public uint RefCount;
// May return null.
public static byte* GetData( ResourceHandle* handle )
=> ( ( delegate* unmanaged< ResourceHandle*, byte* > )handle->VTable[ 23 ] )( handle );
public static ulong GetLength( ResourceHandle* handle )
=> ( ( delegate* unmanaged< ResourceHandle*, ulong > )handle->VTable[ 17 ] )( handle );
// Only use these if you know what you are doing.
// Those are actually only sure to be accessible for DefaultResourceHandles.
[FieldOffset( 0xB0 )]
public DataIndirection* Data;
[FieldOffset( 0xB8 )]
public uint DataLength;
public (IntPtr Data, int Length) GetData()
=> Data != null
? ( ( IntPtr )Data->DataPtr, ( int )Data->DataLength )
: ( IntPtr.Zero, 0 );
public bool SetData( IntPtr data, int length )
{
if( Data == null )
{
return false;
}
Data->DataPtr = length != 0 ? ( byte* )data : null;
Data->DataLength = ( ulong )length;
DataLength = ( uint )length;
return true;
}
}

View File

@@ -2,6 +2,7 @@
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using FFXIVClientStructs.FFXIV.Client.System.Resource.Handle;
using Penumbra.Interop.Structs;
namespace MareSynchronos.Interop;
@@ -25,8 +26,8 @@ public unsafe struct WeaponDrawObject
public unsafe struct HumanExt
{
[FieldOffset(0x0)] public Human Human;
[FieldOffset(0x9E8)] public ResourceHandle* Decal;
[FieldOffset(0x9F0)] public ResourceHandle* LegacyBodyDecal;
[FieldOffset(0x9E8)] public Penumbra.Interop.Structs.ResourceHandle* Decal;
[FieldOffset(0x9F0)] public Penumbra.Interop.Structs.ResourceHandle* LegacyBodyDecal;
}
[StructLayout(LayoutKind.Explicit)]