Actually perform deferred applications?
This commit is contained in:
@@ -44,6 +44,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
|||||||
private CancellationTokenSource? _downloadCancellationTokenSource = new();
|
private CancellationTokenSource? _downloadCancellationTokenSource = new();
|
||||||
private bool _forceApplyMods = false;
|
private bool _forceApplyMods = false;
|
||||||
private bool _isVisible;
|
private bool _isVisible;
|
||||||
|
private Guid _deferred = Guid.Empty;
|
||||||
private Guid _penumbraCollection = Guid.Empty;
|
private Guid _penumbraCollection = Guid.Empty;
|
||||||
private bool _redrawOnNextApplication = false;
|
private bool _redrawOnNextApplication = false;
|
||||||
|
|
||||||
@@ -165,6 +166,13 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
if (_charaHandler == null || (PlayerCharacter == IntPtr.Zero))
|
if (_charaHandler == null || (PlayerCharacter == IntPtr.Zero))
|
||||||
{
|
{
|
||||||
|
if (_deferred != Guid.Empty)
|
||||||
|
{
|
||||||
|
_isVisible = false;
|
||||||
|
_visibilityService.StopTracking(Pair.Ident);
|
||||||
|
_visibilityService.StartTracking(Pair.Ident);
|
||||||
|
}
|
||||||
|
|
||||||
Mediator.Publish(new EventMessage(new Event(PlayerName, Pair.UserData, nameof(PairHandler), EventSeverity.Warning,
|
Mediator.Publish(new EventMessage(new Event(PlayerName, Pair.UserData, nameof(PairHandler), EventSeverity.Warning,
|
||||||
"Cannot apply character data: Receiving Player is in an invalid state, deferring application")));
|
"Cannot apply character data: Receiving Player is in an invalid state, deferring application")));
|
||||||
Logger.LogDebug("[BASE-{appBase}] Received data but player was in invalid state, charaHandlerIsNull: {charaIsNull}, playerPointerIsNull: {ptrIsNull}",
|
Logger.LogDebug("[BASE-{appBase}] Received data but player was in invalid state, charaHandlerIsNull: {charaIsNull}, playerPointerIsNull: {ptrIsNull}",
|
||||||
@@ -176,9 +184,17 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
|||||||
_cachedData = characterData;
|
_cachedData = characterData;
|
||||||
Mediator.Publish(new PairDataAppliedMessage(Pair.UserData.UID, characterData));
|
Mediator.Publish(new PairDataAppliedMessage(Pair.UserData.UID, characterData));
|
||||||
Logger.LogDebug("[BASE-{appBase}] Setting data: {hash}, forceApplyMods: {force}", applicationBase, _cachedData.DataHash.Value, _forceApplyMods);
|
Logger.LogDebug("[BASE-{appBase}] Setting data: {hash}, forceApplyMods: {force}", applicationBase, _cachedData.DataHash.Value, _forceApplyMods);
|
||||||
|
// Ensure that this deferred application actually occurs by forcing visibiltiy to re-proc
|
||||||
|
// Set _deferred as a silencing flag to avoid spamming logs once per frame with failed applications
|
||||||
|
_isVisible = false;
|
||||||
|
_deferred = applicationBase;
|
||||||
|
_visibilityService.StopTracking(Pair.Ident);
|
||||||
|
_visibilityService.StartTracking(Pair.Ident);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_deferred = Guid.Empty;
|
||||||
|
|
||||||
SetUploading(isUploading: false);
|
SetUploading(isUploading: false);
|
||||||
|
|
||||||
if (Pair.IsDownloadBlocked)
|
if (Pair.IsDownloadBlocked)
|
||||||
@@ -656,6 +672,16 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
if (!IsVisible && nowVisible)
|
if (!IsVisible && nowVisible)
|
||||||
{
|
{
|
||||||
|
// This is deferred application attempt, avoid any log output
|
||||||
|
if (_deferred != Guid.Empty)
|
||||||
|
{
|
||||||
|
_isVisible = true;
|
||||||
|
_ = Task.Run(() =>
|
||||||
|
{
|
||||||
|
ApplyCharacterData(_deferred, _cachedData!, forceApplyCustomization: true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
IsVisible = true;
|
IsVisible = true;
|
||||||
Mediator.Publish(new PairHandlerVisibleMessage(this));
|
Mediator.Publish(new PairHandlerVisibleMessage(this));
|
||||||
if (_cachedData != null)
|
if (_cachedData != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user