changes to LinkedModCollection nullability

This commit is contained in:
Stanley Dimant 2022-09-03 19:36:41 +02:00 committed by Ottermandias
parent e0000c9ef9
commit 75182d094b
3 changed files with 9 additions and 15 deletions

View file

@ -1,4 +1,4 @@
using System;
using System;
using FFXIVClientStructs.FFXIV.Client.Game.Object;
namespace Penumbra.Collections;
@ -6,11 +6,7 @@ namespace Penumbra.Collections;
public class LinkedModCollection
{
private IntPtr? _associatedGameObject;
public IntPtr AssociatedGameObject
{
get => _associatedGameObject ?? IntPtr.Zero;
set => _associatedGameObject = value;
}
public IntPtr AssociatedGameObject = IntPtr.Zero;
public ModCollection ModCollection;
public LinkedModCollection(ModCollection modCollection)
@ -18,15 +14,13 @@ public class LinkedModCollection
ModCollection = modCollection;
}
public LinkedModCollection(IntPtr? gameObject, ModCollection collection)
public LinkedModCollection(IntPtr gameObject, ModCollection collection)
{
AssociatedGameObject = gameObject ?? IntPtr.Zero;
AssociatedGameObject = gameObject;
ModCollection = collection;
}
public unsafe LinkedModCollection(GameObject* gameObject, ModCollection collection)
public unsafe LinkedModCollection(GameObject* gameObject, ModCollection collection) : this((IntPtr)gameObject, collection)
{
AssociatedGameObject = ( IntPtr )gameObject;
ModCollection = collection;
}
}

View file

@ -81,7 +81,7 @@ public unsafe partial class PathResolver
// Just add or remove the resolved path.
[MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )]
public IntPtr ResolvePath( IntPtr? gameObject, ModCollection collection, IntPtr path )
public IntPtr ResolvePath( IntPtr gameObject, ModCollection collection, IntPtr path )
{
if( path == IntPtr.Zero )
{
@ -94,7 +94,7 @@ public unsafe partial class PathResolver
}
// Special handling for paths so that we do not store non-owned temporary strings in the dictionary.
public void SetCollection( IntPtr? gameObject, Utf8String path, ModCollection collection )
public void SetCollection( IntPtr gameObject, Utf8String path, ModCollection collection )
{
if( _pathCollections.ContainsKey( path ) || path.IsOwned )
{

View file

@ -227,7 +227,7 @@ public partial class PathResolver
// Implementation
[MethodImpl( MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization )]
private IntPtr ResolvePath( IntPtr drawObject, IntPtr path )
=> _parent._paths.ResolvePath( (IntPtr?)FindParent( drawObject, out _), FindParent( drawObject, out var collection ) == null
=> _parent._paths.ResolvePath( (IntPtr?)FindParent( drawObject, out _) ?? IntPtr.Zero, FindParent( drawObject, out var collection ) == null
? Penumbra.CollectionManager.Default
: collection.ModCollection, path );
@ -251,7 +251,7 @@ public partial class PathResolver
}
parent = FindParent( parentObject, out collection );
return _parent._paths.ResolvePath( (IntPtr?)parent, parent == null
return _parent._paths.ResolvePath( (IntPtr?)parent ?? IntPtr.Zero, parent == null
? Penumbra.CollectionManager.Default
: collection.ModCollection, path );
}