Fix early loaded weapons blocking the identified collections cache with unprepared customize arrays.

This commit is contained in:
Ottermandias 2023-04-01 14:23:50 +02:00
parent d4738934f8
commit c12dbf3f8a

View file

@ -65,9 +65,10 @@ public unsafe class CollectionResolver
?? _collectionManager.Default; ?? _collectionManager.Default;
var player = _actors.AwaitedService.GetCurrentPlayer(); var player = _actors.AwaitedService.GetCurrentPlayer();
var _ = false;
return CollectionByIdentifier(player) return CollectionByIdentifier(player)
?? CheckYourself(player, gameObject) ?? CheckYourself(player, gameObject)
?? CollectionByAttributes(gameObject) ?? CollectionByAttributes(gameObject, ref _)
?? _collectionManager.Default; ?? _collectionManager.Default;
} }
@ -135,10 +136,11 @@ public unsafe class CollectionResolver
return false; return false;
} }
var collection2 = _collectionManager.ByType(CollectionType.Yourself) var notYetReady = false;
?? CollectionByAttributes(gameObject) var collection = _collectionManager.ByType(CollectionType.Yourself)
?? CollectionByAttributes(gameObject, ref notYetReady)
?? _collectionManager.Default; ?? _collectionManager.Default;
ret = _cache.Set(collection2, ActorIdentifier.Invalid, gameObject); ret = notYetReady ? collection.ToResolveData(gameObject) : _cache.Set(collection, ActorIdentifier.Invalid, gameObject);
return true; return true;
} }
@ -152,11 +154,12 @@ public unsafe class CollectionResolver
} }
var player = _actors.AwaitedService.GetCurrentPlayer(); var player = _actors.AwaitedService.GetCurrentPlayer();
var collection2 = (player.IsValid ? CollectionByIdentifier(player) : null) var notYetReady = false;
var collection = (player.IsValid ? CollectionByIdentifier(player) : null)
?? _collectionManager.ByType(CollectionType.Yourself) ?? _collectionManager.ByType(CollectionType.Yourself)
?? CollectionByAttributes(gameObject) ?? CollectionByAttributes(gameObject, ref notYetReady)
?? _collectionManager.Default; ?? _collectionManager.Default;
ret = _cache.Set(collection2, ActorIdentifier.Invalid, gameObject); ret = notYetReady ? collection.ToResolveData(gameObject) : _cache.Set(collection, ActorIdentifier.Invalid, gameObject);
return true; return true;
} }
@ -174,13 +177,14 @@ public unsafe class CollectionResolver
return _cache.Set(ModCollection.Empty, identifier, gameObject); return _cache.Set(ModCollection.Empty, identifier, gameObject);
} }
var notYetReady = false;
var collection = CollectionByIdentifier(identifier) var collection = CollectionByIdentifier(identifier)
?? CheckYourself(identifier, gameObject) ?? CheckYourself(identifier, gameObject)
?? CollectionByAttributes(gameObject) ?? CollectionByAttributes(gameObject, ref notYetReady)
?? CheckOwnedCollection(identifier, owner) ?? CheckOwnedCollection(identifier, owner, ref notYetReady)
?? _collectionManager.Default; ?? _collectionManager.Default;
return _cache.Set(collection, identifier, gameObject); return notYetReady ? collection.ToResolveData(gameObject) : _cache.Set(collection, identifier, gameObject);
} }
/// <summary> Check both temporary and permanent character collections. Temporary first. </summary> /// <summary> Check both temporary and permanent character collections. Temporary first. </summary>
@ -201,8 +205,8 @@ public unsafe class CollectionResolver
return null; return null;
} }
/// <summary> Check special collections given the actor. </summary> /// <summary> Check special collections given the actor. Returns notYetReady if the customize array is not filled. </summary>
private ModCollection? CollectionByAttributes(GameObject* actor) private ModCollection? CollectionByAttributes(GameObject* actor, ref bool notYetReady)
{ {
if (!actor->IsCharacter()) if (!actor->IsCharacter())
return null; return null;
@ -212,6 +216,12 @@ public unsafe class CollectionResolver
if (!IsModelHuman((uint)character->ModelCharaId)) if (!IsModelHuman((uint)character->ModelCharaId))
return null; return null;
if (character->CustomizeData[0] == 0)
{
notYetReady = true;
return null;
}
var bodyType = character->CustomizeData[2]; var bodyType = character->CustomizeData[2];
var collection = bodyType switch var collection = bodyType switch
{ {
@ -233,7 +243,7 @@ public unsafe class CollectionResolver
} }
/// <summary> Get the collection applying to the owner if it is available. </summary> /// <summary> Get the collection applying to the owner if it is available. </summary>
private ModCollection? CheckOwnedCollection(ActorIdentifier identifier, GameObject* owner) private ModCollection? CheckOwnedCollection(ActorIdentifier identifier, GameObject* owner, ref bool notYetReady)
{ {
if (identifier.Type != IdentifierType.Owned || !_config.UseOwnerNameForCharacterCollection || owner == null) if (identifier.Type != IdentifierType.Owned || !_config.UseOwnerNameForCharacterCollection || owner == null)
return null; return null;
@ -242,7 +252,7 @@ public unsafe class CollectionResolver
ObjectKind.None, ObjectKind.None,
uint.MaxValue); uint.MaxValue);
return CheckYourself(id, owner) return CheckYourself(id, owner)
?? CollectionByAttributes(owner); ?? CollectionByAttributes(owner, ref notYetReady);
} }
/// <summary> /// <summary>