Prevent a weird case of null crash.

This commit is contained in:
Ottermandias 2022-06-13 22:26:36 +02:00
parent e994163637
commit f6772af246
2 changed files with 7 additions and 6 deletions

View file

@ -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 )
{

View file

@ -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 )
{