diff --git a/LightlessSync/PlayerData/Factories/PlayerDataFactory.cs b/LightlessSync/PlayerData/Factories/PlayerDataFactory.cs index 45b7e01..99b9371 100644 --- a/LightlessSync/PlayerData/Factories/PlayerDataFactory.cs +++ b/LightlessSync/PlayerData/Factories/PlayerDataFactory.cs @@ -214,7 +214,6 @@ public class PlayerDataFactory .ConfigureAwait(false); // get all remaining paths and resolve them - var transientPaths = ManageSemiTransientData(objectKind); ct.ThrowIfCancellationRequested(); if (await CheckForNullDrawObject(playerRelatedObject.Address).ConfigureAwait(false)) diff --git a/LightlessSync/PlayerData/Handlers/GameObjectHandler.cs b/LightlessSync/PlayerData/Handlers/GameObjectHandler.cs index c90096d..f3d1a4b 100644 --- a/LightlessSync/PlayerData/Handlers/GameObjectHandler.cs +++ b/LightlessSync/PlayerData/Handlers/GameObjectHandler.cs @@ -78,6 +78,7 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP if (msg.Address == Address) { _haltProcessing = false; + Refresh(); } }); @@ -176,30 +177,36 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP Mediator.Publish(new GameObjectHandlerDestroyedMessage(this, _isOwnedObject)); } - private unsafe void CheckAndUpdateObject() + private void CheckAndUpdateObject() => CheckAndUpdateObject(allowPublish: true); + + private unsafe void CheckAndUpdateObject(bool allowPublish = true) { var prevAddr = Address; var prevDrawObj = DrawObjectAddress; Address = _getAddress(); + if (Address != IntPtr.Zero) { var gameObject = (FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)Address; - var drawObjAddr = (IntPtr)gameObject->DrawObject; - DrawObjectAddress = drawObjAddr; + DrawObjectAddress = (IntPtr)gameObject->DrawObject; EntityId = gameObject->EntityId; - CurrentDrawCondition = DrawCondition.None; + + var chara = (Character*)Address; + var newName = chara->GameObject.NameString; + + if (!string.IsNullOrEmpty(newName) && !string.Equals(newName, Name, StringComparison.Ordinal)) + Name = newName; } else { DrawObjectAddress = IntPtr.Zero; EntityId = uint.MaxValue; - CurrentDrawCondition = DrawCondition.DrawObjectZero; } CurrentDrawCondition = IsBeingDrawnUnsafe(); - if (_haltProcessing) return; + if (_haltProcessing || !allowPublish) return; bool drawObjDiff = DrawObjectAddress != prevDrawObj; bool addrDiff = Address != prevAddr; @@ -356,12 +363,10 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP private void FrameworkUpdate() { - if (!_delayedZoningTask?.IsCompleted ?? false) return; - try { - _performanceCollector.LogPerformance(this, $"CheckAndUpdateObject>{(_isOwnedObject ? "Self" : "Other")}+{ObjectKind}/{(string.IsNullOrEmpty(Name) ? "Unk" : Name)}" - + $"+{Address.ToString("X")}", CheckAndUpdateObject); + var zoningDelayActive = !(_delayedZoningTask?.IsCompleted ?? true); + _performanceCollector.LogPerformance(this, $"CheckAndUpdateObject>{(_isOwnedObject ? "Self" : "Other")}+{ObjectKind}/{(string.IsNullOrEmpty(Name) ? "Unk" : Name)}", () => CheckAndUpdateObject(allowPublish: !zoningDelayActive)); } catch (Exception ex) { @@ -462,6 +467,6 @@ public sealed class GameObjectHandler : DisposableMediatorSubscriberBase, IHighP Logger.LogDebug("[{this}] Delay after zoning complete", this); _zoningCts.Dispose(); } - }); + }, _zoningCts.Token); } } \ No newline at end of file diff --git a/LightlessSync/UI/CompactUI.cs b/LightlessSync/UI/CompactUI.cs index a27c568..a43f228 100644 --- a/LightlessSync/UI/CompactUI.cs +++ b/LightlessSync/UI/CompactUI.cs @@ -167,9 +167,12 @@ public class CompactUi : WindowMediatorSubscriberBase Mediator.Subscribe(this, (_) => IsOpen = false); Mediator.Subscribe(this, (_) => UiSharedService_GposeStart()); Mediator.Subscribe(this, (_) => UiSharedService_GposeEnd()); - Mediator.Subscribe(this, (msg) => _currentDownloads[msg.DownloadId] = (Dictionary)msg.DownloadStatus); + Mediator.Subscribe(this, msg => + { + _currentDownloads[msg.DownloadId] = new Dictionary(msg.DownloadStatus, StringComparer.Ordinal); + }); Mediator.Subscribe(this, (msg) => _currentDownloads.TryRemove(msg.DownloadId, out _)); - Mediator.Subscribe(this, (msg) => _drawFolders = DrawFolders.ToList()); + Mediator.Subscribe(this, (msg) => _drawFolders = [.. DrawFolders]); _characterAnalyzer = characterAnalyzer; _playerPerformanceConfig = playerPerformanceConfig; diff --git a/LightlessSync/UI/DownloadUi.cs b/LightlessSync/UI/DownloadUi.cs index 7ed5629..6cc4bd1 100644 --- a/LightlessSync/UI/DownloadUi.cs +++ b/LightlessSync/UI/DownloadUi.cs @@ -65,12 +65,14 @@ public class DownloadUi : WindowMediatorSubscriberBase IsOpen = true; - Mediator.Subscribe(this, (msg) => + Mediator.Subscribe(this, msg => { _currentDownloads[msg.DownloadId] = msg.DownloadStatus; - // Capture initial totals when download starts - var totalFiles = msg.DownloadStatus.Values.Sum(s => s.TotalFiles); - var totalBytes = msg.DownloadStatus.Values.Sum(s => s.TotalBytes); + + var snap = msg.DownloadStatus.ToArray(); + var totalFiles = snap.Sum(kv => kv.Value?.TotalFiles ?? 0); + var totalBytes = snap.Sum(kv => kv.Value?.TotalBytes ?? 0); + _downloadInitialTotals[msg.DownloadId] = (totalFiles, totalBytes); _notificationDismissed = false; }); @@ -79,7 +81,7 @@ public class DownloadUi : WindowMediatorSubscriberBase _currentDownloads.TryRemove(msg.DownloadId, out _); // Dismiss notification if all downloads are complete - if (!_currentDownloads.Any() && !_notificationDismissed) + if (_currentDownloads.IsEmpty && !_notificationDismissed) { Mediator.Publish(new LightlessNotificationDismissMessage("pair_download_progress")); _notificationDismissed = true; @@ -474,7 +476,7 @@ public class DownloadUi : WindowMediatorSubscriberBase totalBytes += playerTotalBytes; transferredBytes += playerTransferredBytes; - // per-player W/Q/P/D + // per-player W/Q/P/D/C var playerDlSlot = 0; var playerDlQueue = 0; var playerDlProg = 0; @@ -487,6 +489,7 @@ public class DownloadUi : WindowMediatorSubscriberBase switch (fileStatus.DownloadStatus) { case DownloadStatus.Initializing: + case DownloadStatus.WaitingForQueue: playerDlQueue++; totalDlQueue++; break; @@ -494,10 +497,6 @@ public class DownloadUi : WindowMediatorSubscriberBase playerDlSlot++; totalDlSlot++; break; - case DownloadStatus.WaitingForQueue: - playerDlQueue++; - totalDlQueue++; - break; case DownloadStatus.Downloading: playerDlProg++; totalDlProg++; @@ -550,11 +549,6 @@ public class DownloadUi : WindowMediatorSubscriberBase if (totalFiles == 0 || totalBytes == 0) return; - // max speed for per-player bar scale (clamped) - double maxSpeed = perPlayer.Count > 0 ? perPlayer.Max(p => p.SpeedBytesPerSecond) : 0; - if (maxSpeed <= 0) - maxSpeed = 1; - var drawList = ImGui.GetBackgroundDrawList(); var windowPos = ImGui.GetWindowPos();