Fix companion identification, extract offsets and vtable indices to separate file.

This commit is contained in:
Ottermandias 2023-01-16 13:02:22 +01:00
parent 79eee0e2c7
commit 4059e0630a
9 changed files with 60 additions and 22 deletions

View file

@ -1,5 +1,6 @@
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Component.GUI;
using Penumbra.GameData;
namespace Penumbra.Interop;
@ -51,6 +52,6 @@ public static unsafe class FontReloader
}
AtkModule = &atkModule->AtkModule;
ReloadFontsFunc = ( ( delegate* unmanaged< AtkModule*, bool, bool, void >* )AtkModule->vtbl )[ 43 ];
ReloadFontsFunc = ( ( delegate* unmanaged< AtkModule*, bool, bool, void >* )AtkModule->vtbl )[ Offsets.ReloadFontsVfunc ];
}
}

View file

@ -7,6 +7,7 @@ using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.ClientState.Objects.Types;
using Penumbra.Api;
using Penumbra.Api.Enums;
using Penumbra.GameData;
using Penumbra.Interop.Structs;
namespace Penumbra.Interop;
@ -23,10 +24,10 @@ public unsafe partial class ObjectReloader
// VFuncs that disable and enable draw, used only for GPose actors.
private static void DisableDraw( GameObject actor )
=> ( ( delegate* unmanaged< IntPtr, void >** )actor.Address )[ 0 ][ 17 ]( actor.Address );
=> ( ( delegate* unmanaged< IntPtr, void >** )actor.Address )[ 0 ][ Offsets.DisableDrawVfunc ]( actor.Address );
private static void EnableDraw( GameObject actor )
=> ( ( delegate* unmanaged< IntPtr, void >** )actor.Address )[ 0 ][ 16 ]( actor.Address );
=> ( ( delegate* unmanaged< IntPtr, void >** )actor.Address )[ 0 ][ Offsets.EnableDrawVfunc ]( actor.Address );
// Check whether we currently are in GPose.
// Also clear the name list.

View file

@ -129,7 +129,7 @@ public unsafe partial class PathResolver
{
if( timeline != IntPtr.Zero )
{
var getGameObjectIdx = ( ( delegate* unmanaged< IntPtr, int >** )timeline )[ 0 ][ 28 ];
var getGameObjectIdx = ( ( delegate* unmanaged< IntPtr, int >** )timeline )[ 0 ][ Offsets.GetGameObjectIdxVfunc ];
var idx = getGameObjectIdx( timeline );
if( idx >= 0 && idx < Dalamud.Objects.Length )
{
@ -192,7 +192,7 @@ public unsafe partial class PathResolver
private void LoadSomePapDetour( IntPtr a1, int a2, IntPtr a3, int a4 )
{
using var performance = Penumbra.Performance.Measure( PerformanceType.LoadPap );
var timelinePtr = a1 + 0x50;
var timelinePtr = a1 + Offsets.TimeLinePtr;
var last = _animationLoadData;
if( timelinePtr != IntPtr.Zero )
{

View file

@ -95,7 +95,7 @@ public unsafe partial class PathResolver
{
// Shortcut because this is called all the time.
// Same thing is checked at the beginning of the original function.
if( *( int* )( drawObject + 0x90c ) == 0 )
if( *( int* )( drawObject + Offsets.UpdateModelSkip ) == 0 )
{
return;
}
@ -133,7 +133,7 @@ public unsafe partial class PathResolver
{
// Shortcut because this is also called all the time.
// Same thing is checked at the beginning of the original function.
if( ( *( byte* )( drawObject + 0xa30 ) & 1 ) == 0 || *( ulong* )( drawObject + 0xa28 ) == 0 )
if( ( *( byte* )( drawObject + Offsets.GetEqpIndirectSkip1 ) & 1 ) == 0 || *( ulong* )( drawObject + Offsets.GetEqpIndirectSkip2 ) == 0 )
{
return;
}

View file

@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.System.Resource;
using Penumbra.GameData;
using Penumbra.GameData.Enums;
namespace Penumbra.Interop.Structs;
@ -87,10 +88,10 @@ public unsafe struct ResourceHandle
// May return null.
public static byte* GetData( ResourceHandle* handle )
=> ( ( delegate* unmanaged< ResourceHandle*, byte* > )handle->VTable[ 23 ] )( handle );
=> ( ( delegate* unmanaged< ResourceHandle*, byte* > )handle->VTable[ Offsets.ResourceHandleGetDataVfunc ] )( handle );
public static ulong GetLength( ResourceHandle* handle )
=> ( ( delegate* unmanaged< ResourceHandle*, ulong > )handle->VTable[ 17 ] )( handle );
=> ( ( delegate* unmanaged< ResourceHandle*, ulong > )handle->VTable[ Offsets.ResourceHandleGetLengthVfunc ] )( handle );
// Only use these if you know what you are doing.