diff --git a/FFXIVClientStructs.Common.dll b/FFXIVClientStructs.Common.dll new file mode 100644 index 00000000..69fee26d Binary files /dev/null and b/FFXIVClientStructs.Common.dll differ diff --git a/FFXIVClientStructs.Generators.dll b/FFXIVClientStructs.Generators.dll new file mode 100644 index 00000000..19281c93 Binary files /dev/null and b/FFXIVClientStructs.Generators.dll differ diff --git a/FFXIVClientStructs.dll b/FFXIVClientStructs.dll new file mode 100644 index 00000000..e1130434 Binary files /dev/null and b/FFXIVClientStructs.dll differ diff --git a/Penumbra/Interop/GameResourceManagement.cs b/Penumbra/Interop/GameResourceManagement.cs index a0f00ecc..8731afca 100644 --- a/Penumbra/Interop/GameResourceManagement.cs +++ b/Penumbra/Interop/GameResourceManagement.cs @@ -3,6 +3,7 @@ using System.Runtime.InteropServices; using Dalamud.Plugin; using Penumbra.Structs; using Reloaded.Hooks.Definitions.X64; +using ResourceHandle = FFXIVClientStructs.FFXIV.Client.System.Resource.Handle.ResourceHandle; namespace Penumbra.Interop { @@ -86,9 +87,11 @@ namespace Penumbra.Interop for( var i = 0; i < NumResources; i++ ) { + var handle = ( ResourceHandle* )oldResources[ i ]; if( oldResources[ i ].ToPointer() == pResources[ i ] ) { PluginLog.Debug( $"Unchanged resource: {ResourceToPath( ( byte* )oldResources[ i ].ToPointer() )}" ); + ( ( ResourceHandle* )oldResources[ i ] )->DecRef(); continue; } @@ -97,6 +100,13 @@ namespace Penumbra.Interop + $"{ResourceToPath( ( byte* )pResources[ i ] )}" ); UnloadCharacterResource( oldResources[ i ] ); + // Temporary fix against crashes? + if( handle->RefCount <= 0 ) + { + handle->RefCount = 1; + handle->IncRef(); + handle->RefCount = 1; + } } } } diff --git a/Penumbra/Penumbra.csproj b/Penumbra/Penumbra.csproj index 1049ff78..9c9023b2 100644 --- a/Penumbra/Penumbra.csproj +++ b/Penumbra/Penumbra.csproj @@ -27,36 +27,31 @@ + - $(DALAMUD_ROOT)\Dalamud.dll - ..\libs\Dalamud.dll $(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll False - $(DALAMUD_ROOT)\ImGui.NET.dll - ..\libs\ImGui.NET.dll $(AppData)\XIVLauncher\addon\Hooks\dev\ImGui.NET.dll False - $(DALAMUD_ROOT)\ImGuiScene.dll - ..\libs\ImGuiScene.dll $(AppData)\XIVLauncher\addon\Hooks\dev\ImGuiScene.dll False - $(DALAMUD_ROOT)\Lumina.dll - ..\libs\Lumina.dll $(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.dll False - $(DALAMUD_ROOT)\Lumina.Excel.dll - ..\libs\Lumina.Excel.dll $(AppData)\XIVLauncher\addon\Hooks\dev\Lumina.Excel.dll False + + ..\FFXIVClientStructs.dll + true + @@ -66,6 +61,14 @@ + + + + + + + + @@ -73,10 +76,10 @@ - - - - + + + + diff --git a/Penumbra/Plugin.cs b/Penumbra/Plugin.cs index fa2653b7..47e9d73e 100644 --- a/Penumbra/Plugin.cs +++ b/Penumbra/Plugin.cs @@ -48,6 +48,7 @@ namespace Penumbra public void Initialize( DalamudPluginInterface pluginInterface ) { + FFXIVClientStructs.Resolver.Initialize(); PluginInterface = pluginInterface; Service< DalamudPluginInterface >.Set( PluginInterface ); GameData.GameData.GetIdentifier( PluginInterface );