From f6772af246ec7528bc7af26bc574b4df76407e03 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 13 Jun 2022 22:26:36 +0200 Subject: [PATCH] Prevent a weird case of null crash. --- Penumbra/Interop/Resolver/PathResolver.Material.cs | 3 ++- Penumbra/Interop/Resolver/PathResolver.cs | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Penumbra/Interop/Resolver/PathResolver.Material.cs b/Penumbra/Interop/Resolver/PathResolver.Material.cs index 400d0a4c..160820e3 100644 --- a/Penumbra/Interop/Resolver/PathResolver.Material.cs +++ b/Penumbra/Interop/Resolver/PathResolver.Material.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using Dalamud.Hooking; using Dalamud.Logging; using Dalamud.Utility.Signatures; @@ -55,7 +56,7 @@ public unsafe partial class PathResolver } // Check specifically for shpk and tex files whether we are currently in a material load. - private bool HandleMaterialSubFiles( ResourceType type, out ModCollection? collection ) + private bool HandleMaterialSubFiles( ResourceType type, [NotNullWhen(true)] out ModCollection? collection ) { if( _mtrlCollection != null && type is ResourceType.Tex or ResourceType.Shpk ) { diff --git a/Penumbra/Interop/Resolver/PathResolver.cs b/Penumbra/Interop/Resolver/PathResolver.cs index 77f413f6..c634755a 100644 --- a/Penumbra/Interop/Resolver/PathResolver.cs +++ b/Penumbra/Interop/Resolver/PathResolver.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using Dalamud.Logging; using Dalamud.Utility.Signatures; using FFXIVClientStructs.FFXIV.Client.System.Resource; @@ -40,16 +41,15 @@ public partial class PathResolver : IDisposable // A potential next request will add the path anew. var nonDefault = HandleMaterialSubFiles( type, out var collection ) || PathCollections.TryRemove( gamePath.Path, out collection ) - //|| HandlePapFile( type, gamePath, out collection ) || HandleAnimationFile( type, gamePath, out collection ) || HandleDecalFile( type, gamePath, out collection ); - if( !nonDefault ) + if( !nonDefault || collection == null) { collection = Penumbra.CollectionManager.Default; } // Resolve using character/default collection first, otherwise forced, as usual. - var resolved = collection!.ResolvePath( gamePath ); + var resolved = collection.ResolvePath( gamePath ); // Since mtrl files load their files separately, we need to add the new, resolved path // so that the functions loading tex and shpk can find that path and use its collection. @@ -59,7 +59,7 @@ public partial class PathResolver : IDisposable return true; } - private bool HandleDecalFile( ResourceType type, Utf8GamePath gamePath, out ModCollection? collection ) + private bool HandleDecalFile( ResourceType type, Utf8GamePath gamePath, [NotNullWhen(true)] out ModCollection? collection ) { if( type == ResourceType.Tex && _lastCreatedCollection != null @@ -73,7 +73,7 @@ public partial class PathResolver : IDisposable return false; } - private bool HandleAnimationFile( ResourceType type, Utf8GamePath _, out ModCollection? collection ) + private bool HandleAnimationFile( ResourceType type, Utf8GamePath _, [NotNullWhen(true)] out ModCollection? collection ) { if( _animationLoadCollection != null ) {