diff --git a/FFXIVClientStructs.dll b/FFXIVClientStructs.dll index e1130434..6e370f3a 100644 Binary files a/FFXIVClientStructs.dll and b/FFXIVClientStructs.dll differ diff --git a/Penumbra/Interop/GameResourceManagement.cs b/Penumbra/Interop/ResidentResources.cs similarity index 88% rename from Penumbra/Interop/GameResourceManagement.cs rename to Penumbra/Interop/ResidentResources.cs index a36f09ab..d2859193 100644 --- a/Penumbra/Interop/GameResourceManagement.cs +++ b/Penumbra/Interop/ResidentResources.cs @@ -111,12 +111,17 @@ namespace Penumbra.Interop + $"{ResourceToPath( ( byte* )pResources[ i ] )}" ); UnloadCharacterResource( oldResources[ i ] ); - // Temporary fix against crashes? + + // Easiest way to actually remove a file from the resource manager. + // Not doing this keeps them in memory for some reason, + // and then corrupts the state when entering a loading screen that is not a teleport. + // This increases the references of all loaded files by one temporarily, but there is extra logic for 0-references, + // and they get loaded anew with GetResourceAsync, but this gets redirected and thus the modded resource reference is increased twice. + // Then it reduces the refcount of all reduces by 1 again, but this time for real, so the resource gets ref count -1, leading to problems. if( handle->RefCount <= 0 ) { handle->RefCount = 1; - handle->IncRef(); - handle->RefCount = 1; + handle->DecRef(); } } } diff --git a/Penumbra/UI/MenuTabs/TabDebug.cs b/Penumbra/UI/MenuTabs/TabDebug.cs index 18dac78b..28f939b6 100644 --- a/Penumbra/UI/MenuTabs/TabDebug.cs +++ b/Penumbra/UI/MenuTabs/TabDebug.cs @@ -171,7 +171,7 @@ namespace Penumbra.UI .GetField( "_changedSettings", BindingFlags.Instance | BindingFlags.NonPublic ) ?.GetValue( _penumbra.ObjectReloader ); - var currentObjectId = ( int? )_penumbra.ObjectReloader.GetType() + var currentObjectId = ( uint? )_penumbra.ObjectReloader.GetType() .GetField( "_currentObjectId", BindingFlags.Instance | BindingFlags.NonPublic ) ?.GetValue( _penumbra.ObjectReloader ); diff --git a/Penumbra/UI/MenuTabs/TabSettings.cs b/Penumbra/UI/MenuTabs/TabSettings.cs index 47a33a8d..1cf93dfa 100644 --- a/Penumbra/UI/MenuTabs/TabSettings.cs +++ b/Penumbra/UI/MenuTabs/TabSettings.cs @@ -115,6 +115,7 @@ namespace Penumbra.UI { _config.IsEnabled = enabled; _configChanged = true; + Service.Get().ReloadPlayerResources(); _base._penumbra.ObjectReloader.RedrawAll( enabled ? RedrawType.WithSettings : RedrawType.WithoutSettings ); if( _config.EnablePlayerWatch ) {