mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 21:24:18 +01:00
Make Individual Collection lookup thread-safe by locking.
This commit is contained in:
parent
e9ab9a71a8
commit
5a817db069
4 changed files with 134 additions and 116 deletions
|
|
@ -459,7 +459,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
|||
if (!id.IsValid)
|
||||
return (false, false, _collectionManager.Default.Name);
|
||||
|
||||
if (_collectionManager.Individuals.Individuals.TryGetValue(id, out var collection))
|
||||
if (_collectionManager.Individuals.TryGetValue(id, out var collection))
|
||||
return (true, true, collection.Name);
|
||||
|
||||
AssociatedCollection(gameObjectIdx, out collection);
|
||||
|
|
@ -474,7 +474,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
|||
if (!id.IsValid)
|
||||
return (PenumbraApiEc.InvalidIdentifier, _collectionManager.Default.Name);
|
||||
|
||||
var oldCollection = _collectionManager.Individuals.Individuals.TryGetValue(id, out var c) ? c.Name : string.Empty;
|
||||
var oldCollection = _collectionManager.Individuals.TryGetValue(id, out var c) ? c.Name : string.Empty;
|
||||
|
||||
if (collectionName.Length == 0)
|
||||
{
|
||||
|
|
@ -809,8 +809,8 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
|||
if (!identifier.IsValid)
|
||||
return (PenumbraApiEc.InvalidArgument, string.Empty);
|
||||
|
||||
if (!forceOverwriteCharacter && _collectionManager.Individuals.Individuals.ContainsKey(identifier)
|
||||
|| _tempCollections.Collections.Individuals.ContainsKey(identifier))
|
||||
if (!forceOverwriteCharacter && _collectionManager.Individuals.ContainsKey(identifier)
|
||||
|| _tempCollections.Collections.ContainsKey(identifier))
|
||||
return (PenumbraApiEc.CharacterCollectionExists, string.Empty);
|
||||
|
||||
var name = $"{tag}_{character}";
|
||||
|
|
@ -855,11 +855,11 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
|||
|
||||
if (forceAssignment)
|
||||
{
|
||||
if (_tempCollections.Collections.Individuals.ContainsKey(identifier) && !_tempCollections.Collections.Delete(identifier))
|
||||
if (_tempCollections.Collections.ContainsKey(identifier) && !_tempCollections.Collections.Delete(identifier))
|
||||
return PenumbraApiEc.AssignmentDeletionFailed;
|
||||
}
|
||||
else if (_tempCollections.Collections.Individuals.ContainsKey(identifier)
|
||||
|| _collectionManager.Individuals.Individuals.ContainsKey(identifier))
|
||||
else if (_tempCollections.Collections.ContainsKey(identifier)
|
||||
|| _collectionManager.Individuals.ContainsKey(identifier))
|
||||
{
|
||||
return PenumbraApiEc.CharacterCollectionExists;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,6 @@ public class TempCollectionManager : IDisposable
|
|||
return false;
|
||||
|
||||
var identifier = Penumbra.Actors.CreatePlayer(byteString, worldId);
|
||||
return Collections.Individuals.TryGetValue(identifier, out var collection) && RemoveTemporaryCollection(collection.Name);
|
||||
return Collections.TryGetValue(identifier, out var collection) && RemoveTemporaryCollection(collection.Name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue