Cleaning of registry, fixed typo in object kind as it should be companion in the companion kind.
This commit is contained in:
@@ -1622,7 +1622,7 @@ internal sealed class PairHandlerAdapter : DisposableMediatorSubscriberBase, IPa
|
||||
if (companion != nint.Zero)
|
||||
{
|
||||
await _ipcManager.CustomizePlus.RevertByIdAsync(customizeId).ConfigureAwait(false);
|
||||
using GameObjectHandler tempHandler = await _gameObjectHandlerFactory.Create(ObjectKind.Pet, () => companion, isWatched: false).ConfigureAwait(false);
|
||||
using GameObjectHandler tempHandler = await _gameObjectHandlerFactory.Create(ObjectKind.Companion, () => companion, isWatched: false).ConfigureAwait(false);
|
||||
await _ipcManager.Glamourer.RevertAsync(Logger, tempHandler, applicationId, cancelToken).ConfigureAwait(false);
|
||||
await _ipcManager.Penumbra.RedrawAsync(Logger, tempHandler, applicationId, cancelToken).ConfigureAwait(false);
|
||||
}
|
||||
@@ -1848,5 +1848,4 @@ internal sealed class PairHandlerAdapter : DisposableMediatorSubscriberBase, IPa
|
||||
ApplyCharacterData(pending.ApplicationId,
|
||||
pending.CharacterData, pending.Forced);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public sealed class PairHandlerRegistry : IDisposable
|
||||
private readonly object _gate = new();
|
||||
private readonly object _pendingGate = new();
|
||||
private readonly Dictionary<string, PairHandlerEntry> _entriesByIdent = new(StringComparer.Ordinal);
|
||||
private readonly Dictionary<IPairHandlerAdapter, PairHandlerEntry> _entriesByHandler = new();
|
||||
private readonly Dictionary<IPairHandlerAdapter, PairHandlerEntry> _entriesByHandler = new(ReferenceEqualityComparer.Instance);
|
||||
|
||||
private readonly IPairHandlerAdapterFactory _handlerFactory;
|
||||
private readonly PairManager _pairManager;
|
||||
@@ -162,7 +162,13 @@ public sealed class PairHandlerRegistry : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
handler.ApplyData(dto.CharaData);
|
||||
if (!handler.Initialized)
|
||||
{
|
||||
handler.Initialize();
|
||||
QueuePendingCharacterData(registration, dto);
|
||||
return PairOperationResult.Ok();
|
||||
}
|
||||
|
||||
return PairOperationResult.Ok();
|
||||
}
|
||||
|
||||
@@ -385,25 +391,20 @@ public sealed class PairHandlerRegistry : IDisposable
|
||||
|
||||
private void QueuePendingCharacterData(PairRegistration registration, OnlineUserCharaDataDto dto)
|
||||
{
|
||||
if (registration.CharacterIdent is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (registration.CharacterIdent is null) return;
|
||||
|
||||
CancellationTokenSource? previous = null;
|
||||
CancellationTokenSource? previous;
|
||||
CancellationTokenSource cts;
|
||||
|
||||
lock (_pendingGate)
|
||||
{
|
||||
if (_pendingCharacterData.TryGetValue(registration.CharacterIdent, out previous))
|
||||
{
|
||||
previous.Cancel();
|
||||
}
|
||||
_pendingCharacterData.TryGetValue(registration.CharacterIdent, out previous);
|
||||
previous?.Cancel();
|
||||
|
||||
cts = new CancellationTokenSource();
|
||||
_pendingCharacterData[registration.CharacterIdent] = cts;
|
||||
}
|
||||
|
||||
previous?.Dispose();
|
||||
cts.CancelAfter(_handlerReadyTimeout);
|
||||
_ = Task.Run(() => WaitThenApplyPendingCharacterDataAsync(registration, dto, cts.Token, cts));
|
||||
}
|
||||
@@ -414,16 +415,10 @@ public sealed class PairHandlerRegistry : IDisposable
|
||||
lock (_pendingGate)
|
||||
{
|
||||
if (_pendingCharacterData.TryGetValue(ident, out cts))
|
||||
{
|
||||
_pendingCharacterData.Remove(ident);
|
||||
}
|
||||
}
|
||||
|
||||
if (cts is not null)
|
||||
{
|
||||
cts.Cancel();
|
||||
cts.Dispose();
|
||||
}
|
||||
cts?.Cancel();
|
||||
}
|
||||
|
||||
private void CancelAllPendingCharacterData()
|
||||
@@ -433,21 +428,13 @@ public sealed class PairHandlerRegistry : IDisposable
|
||||
{
|
||||
if (_pendingCharacterData.Count > 0)
|
||||
{
|
||||
snapshot = _pendingCharacterData.Values.ToList();
|
||||
snapshot = [.. _pendingCharacterData.Values];
|
||||
_pendingCharacterData.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (snapshot is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var cts in snapshot)
|
||||
{
|
||||
cts.Cancel();
|
||||
cts.Dispose();
|
||||
}
|
||||
if (snapshot is null) return;
|
||||
foreach (var cts in snapshot) cts.Cancel();
|
||||
}
|
||||
|
||||
private async Task WaitThenApplyPendingCharacterDataAsync(
|
||||
|
||||
Reference in New Issue
Block a user