Add correct handling of forceAssignment and correct iteration while deleting.

This commit is contained in:
Ottermandias 2023-03-25 12:21:55 +01:00
parent 3c564add0e
commit 831990949f
3 changed files with 10 additions and 4 deletions

@ -1 +1 @@
Subproject commit f66e49bde2878542de17edf428de61f6c8a42efc
Subproject commit d87dfa44ff6efcf4fe576d8a877c78f4ac0dc893

View file

@ -905,8 +905,14 @@ public class PenumbraApi : IDisposable, IPenumbraApi
return PenumbraApiEc.CollectionMissing;
}
if( !forceAssignment
&& ( Penumbra.TempMods.Collections.Individuals.ContainsKey( identifier ) || Penumbra.CollectionManager.Individuals.Individuals.ContainsKey( identifier ) ) )
if( forceAssignment )
{
if( Penumbra.TempMods.Collections.Individuals.ContainsKey( identifier ) && !Penumbra.TempMods.Collections.Delete( identifier ) )
{
return PenumbraApiEc.AssignmentDeletionFailed;
}
}
else if( Penumbra.TempMods.Collections.Individuals.ContainsKey( identifier ) || Penumbra.CollectionManager.Individuals.Individuals.ContainsKey( identifier ) )
{
return PenumbraApiEc.CharacterCollectionExists;
}

View file

@ -187,7 +187,7 @@ public class TempModManager
if( Collections[ i ].Collection == collection )
{
CollectionChanged?.Invoke( CollectionType.Temporary, collection, null, Collections[ i ].DisplayName );
Collections.Delete( i );
Collections.Delete( i-- );
}
}