Maybe fix AtchCaller crashes.

This commit is contained in:
Ottermandias 2025-04-05 14:42:25 +02:00
parent c3b2443ab5
commit 3b54485127
2 changed files with 5 additions and 1 deletions

View file

@ -25,7 +25,7 @@ public unsafe class AtchCallerHook1 : FastHook<AtchCallerHook1.Delegate>, IDispo
private void Detour(DrawObjectData* data, uint slot, nint unk, Model playerModel)
{
var collection = _collectionResolver.IdentifyCollection(playerModel.AsDrawObject, true);
var collection = playerModel.Valid ? _collectionResolver.IdentifyCollection(playerModel.AsDrawObject, true) : _collectionResolver.DefaultCollection;
_metaState.AtchCollection.Push(collection);
Task.Result.Original(data, slot, unk, playerModel);
_metaState.AtchCollection.Pop();

View file

@ -95,6 +95,10 @@ public sealed unsafe class CollectionResolver(
return IdentifyCollection(obj, useCache);
}
/// <summary> Get the default collection. </summary>
public ResolveData DefaultCollection
=> collectionManager.Active.Default.ToResolveData();
/// <summary> Return whether the given ModelChara id refers to a human-type model. </summary>
public bool IsModelHuman(uint modelCharaId)
=> humanModels.IsHuman(modelCharaId);