From f58851118ede16c10ec483a53748c112aee1bdc6 Mon Sep 17 00:00:00 2001 From: defnotken Date: Mon, 15 Sep 2025 18:31:17 -0500 Subject: [PATCH 1/2] Fix Combat End and split combat + performance. --- .../Configurations/PlayerPerformanceConfig.cs | 2 + .../PlayerData/Handlers/PairHandler.cs | 16 ++++++-- LightlessSync/Services/DalamudUtilService.cs | 39 +++++++++++++------ LightlessSync/Services/Mediator/Messages.cs | 6 ++- LightlessSync/UI/SettingsUi.cs | 18 ++++++++- 5 files changed, 63 insertions(+), 18 deletions(-) diff --git a/LightlessSync/LightlessConfiguration/Configurations/PlayerPerformanceConfig.cs b/LightlessSync/LightlessConfiguration/Configurations/PlayerPerformanceConfig.cs index d87f3c3..ca12006 100644 --- a/LightlessSync/LightlessConfiguration/Configurations/PlayerPerformanceConfig.cs +++ b/LightlessSync/LightlessConfiguration/Configurations/PlayerPerformanceConfig.cs @@ -14,4 +14,6 @@ public class PlayerPerformanceConfig : ILightlessConfiguration public int TrisAutoPauseThresholdThousands { get; set; } = 250; public List UIDsToIgnore { get; set; } = new(); public bool PauseInInstanceDuty { get; set; } = false; + public bool PauseWhilePerforming { get; set; } = true; + public bool PauseInCombat { get; set; } = true; } \ No newline at end of file diff --git a/LightlessSync/PlayerData/Handlers/PairHandler.cs b/LightlessSync/PlayerData/Handlers/PairHandler.cs index edde269..5947f80 100644 --- a/LightlessSync/PlayerData/Handlers/PairHandler.cs +++ b/LightlessSync/PlayerData/Handlers/PairHandler.cs @@ -137,11 +137,21 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase public void ApplyCharacterData(Guid applicationBase, CharacterData characterData, bool forceApplyCustomization = false) { - if (_dalamudUtil.IsInCombatOrPerforming) + if (_dalamudUtil.IsInCombat) { Mediator.Publish(new EventMessage(new Event(PlayerName, Pair.UserData, nameof(PairHandler), EventSeverity.Warning, - "Cannot apply character data: you are in combat or performing music, deferring application"))); - Logger.LogDebug("[BASE-{appBase}] Received data but player is in combat or performing", applicationBase); + "Cannot apply character data: you are in combat, deferring application"))); + Logger.LogDebug("[BASE-{appBase}] Received data but player is in combat", applicationBase); + _dataReceivedInDowntime = new(applicationBase, characterData, forceApplyCustomization); + SetUploading(isUploading: false); + return; + } + + if (_dalamudUtil.IsPerforming) + { + Mediator.Publish(new EventMessage(new Event(PlayerName, Pair.UserData, nameof(PairHandler), EventSeverity.Warning, + "Cannot apply character data: you are performing music, deferring application"))); + Logger.LogDebug("[BASE-{appBase}] Received data but player is performing", applicationBase); _dataReceivedInDowntime = new(applicationBase, characterData, forceApplyCustomization); SetUploading(isUploading: false); return; diff --git a/LightlessSync/Services/DalamudUtilService.cs b/LightlessSync/Services/DalamudUtilService.cs index 4c2bdd8..88b0ee1 100644 --- a/LightlessSync/Services/DalamudUtilService.cs +++ b/LightlessSync/Services/DalamudUtilService.cs @@ -162,7 +162,8 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber public bool IsLoggedIn { get; private set; } public bool IsOnFrameworkThread => _framework.IsInFrameworkUpdateThread; public bool IsZoning => _condition[ConditionFlag.BetweenAreas] || _condition[ConditionFlag.BetweenAreas51]; - public bool IsInCombatOrPerforming { get; private set; } = false; + public bool IsInCombat { get; private set; } = false; + public bool IsPerforming { get; private set; } = false; public bool IsInInstance { get; private set; } = false; public bool HasModifiedGameFiles => _gameData.HasModifiedGameDataFiles; public uint ClassJobId => _classJobId!.Value; @@ -670,19 +671,33 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber Mediator.Publish(new GposeEndMessage()); } - if ((_condition[ConditionFlag.Performing] || _condition[ConditionFlag.InCombat]) && !IsInCombatOrPerforming && (_condition[ConditionFlag.BoundByDuty] && !_playerPerformanceConfigService.Current.PauseInInstanceDuty)) - { - _logger.LogDebug("Combat/Performance start"); - IsInCombatOrPerforming = true; - Mediator.Publish(new CombatOrPerformanceStartMessage()); - Mediator.Publish(new HaltScanMessage(nameof(IsInCombatOrPerforming))); + if ((_condition[ConditionFlag.InCombat]) && !IsInCombat && !IsInInstance && _playerPerformanceConfigService.Current.PauseInCombat) + { + _logger.LogDebug("Combat start"); + IsInCombat = true; + Mediator.Publish(new CombatStartMessage()); + Mediator.Publish(new HaltScanMessage(nameof(IsInCombat))); } - else if ((!_condition[ConditionFlag.Performing] && !_condition[ConditionFlag.InCombat]) && IsInCombatOrPerforming && (_condition[ConditionFlag.BoundByDuty] && !_playerPerformanceConfigService.Current.PauseInInstanceDuty)) + else if ((!_condition[ConditionFlag.InCombat]) && IsInCombat && !IsInInstance && _playerPerformanceConfigService.Current.PauseInCombat) { - _logger.LogDebug("Combat/Performance end"); - IsInCombatOrPerforming = false; - Mediator.Publish(new CombatOrPerformanceEndMessage()); - Mediator.Publish(new ResumeScanMessage(nameof(IsInCombatOrPerforming))); + _logger.LogDebug("Combat end"); + IsInCombat = false; + Mediator.Publish(new CombatEndMessage()); + Mediator.Publish(new ResumeScanMessage(nameof(IsInCombat))); + } + if (_condition[ConditionFlag.Performing] && !IsPerforming && _playerPerformanceConfigService.Current.PauseWhilePerforming) + { + _logger.LogDebug("Performance start"); + IsInCombat = true; + Mediator.Publish(new PerformanceStartMessage()); + Mediator.Publish(new HaltScanMessage(nameof(IsPerforming))); + } + else if (!_condition[ConditionFlag.Performing] && IsPerforming && _playerPerformanceConfigService.Current.PauseWhilePerforming) + { + _logger.LogDebug("Performance end"); + IsInCombat = false; + Mediator.Publish(new PerformanceEndMessage()); + Mediator.Publish(new ResumeScanMessage(nameof(IsPerforming))); } if ((_condition[ConditionFlag.BoundByDuty]) && !IsInInstance && _playerPerformanceConfigService.Current.PauseInInstanceDuty) { diff --git a/LightlessSync/Services/Mediator/Messages.cs b/LightlessSync/Services/Mediator/Messages.cs index ea800d2..9018fe2 100644 --- a/LightlessSync/Services/Mediator/Messages.cs +++ b/LightlessSync/Services/Mediator/Messages.cs @@ -79,8 +79,10 @@ public record OpenPermissionWindow(Pair Pair) : MessageBase; public record DownloadLimitChangedMessage() : SameThreadMessage; public record CensusUpdateMessage(byte Gender, byte RaceId, byte TribeId) : MessageBase; public record TargetPairMessage(Pair Pair) : MessageBase; -public record CombatOrPerformanceStartMessage : MessageBase; -public record CombatOrPerformanceEndMessage : MessageBase; +public record CombatStartMessage : MessageBase; +public record CombatEndMessage : MessageBase; +public record PerformanceStartMessage : MessageBase; +public record PerformanceEndMessage : MessageBase; public record InstanceOrDutyStartMessage : MessageBase; public record InstanceOrDutyEndMessage : MessageBase; public record EventMessage(Event Event) : MessageBase; diff --git a/LightlessSync/UI/SettingsUi.cs b/LightlessSync/UI/SettingsUi.cs index 7f42602..80dc521 100644 --- a/LightlessSync/UI/SettingsUi.cs +++ b/LightlessSync/UI/SettingsUi.cs @@ -1387,16 +1387,32 @@ public class SettingsUi : WindowMediatorSubscriberBase bool autoPause = _playerPerformanceConfigService.Current.AutoPausePlayersExceedingThresholds; bool autoPauseEveryone = _playerPerformanceConfigService.Current.AutoPausePlayersWithPreferredPermissionsExceedingThresholds; bool autoPauseInDuty = _playerPerformanceConfigService.Current.PauseInInstanceDuty; + bool autoPauseInCombat = _playerPerformanceConfigService.Current.PauseInCombat; + bool autoPauseWhilePerforming = _playerPerformanceConfigService.Current.PauseWhilePerforming; if (_uiShared.MediumTreeNode("Auto Pause", UIColors.Get("LightlessPurple"))) { + if (ImGui.Checkbox("Auto pause sync while combat", ref autoPauseInCombat)) + { + _playerPerformanceConfigService.Current.PauseInCombat = autoPauseInCombat; + _playerPerformanceConfigService.Save(); + } + _uiShared.DrawHelpText("AUTO-ENABLED: Your risk of crashing during a fight increases when this is disabled. For example: VFX mods Loading mid fight can cause a crash." + Environment.NewLine + + UiSharedService.TooltipSeparator + "WARNING: DISABLE AT YOUR OWN RISK."); + if (ImGui.Checkbox("Auto pause sync while in Perfomance as Bard", ref autoPauseWhilePerforming)) + { + _playerPerformanceConfigService.Current.PauseWhilePerforming = autoPauseWhilePerforming; + _playerPerformanceConfigService.Save(); + } + _uiShared.DrawHelpText("AUTO-ENABLED: Your risk of crashing during a performance increases when this is disabled. For example: Some mods can crash you mid performance" + Environment.NewLine + + UiSharedService.TooltipSeparator + "WARNING: DISABLE AT YOUR OWN RISK."); if (ImGui.Checkbox("Auto pause sync while in instances and duties", ref autoPauseInDuty)) { _playerPerformanceConfigService.Current.PauseInInstanceDuty = autoPauseInDuty; _playerPerformanceConfigService.Save(); } _uiShared.DrawHelpText("When enabled, it will automatically pause all players while you are in an instance, such as a dungeon or raid." + Environment.NewLine - + UiSharedService.TooltipSeparator + "Warning: You many have to leave the dungeon to resync with people again"); + + UiSharedService.TooltipSeparator + "Warning: You may have to leave the dungeon to resync with people again"); if (ImGui.Checkbox("Automatically pause players exceeding thresholds", ref autoPause)) { -- 2.49.1 From 0c3af33d5dae700fa33ac39e86a76a4b625bb3c6 Mon Sep 17 00:00:00 2001 From: defnotken Date: Mon, 15 Sep 2025 18:42:34 -0500 Subject: [PATCH 2/2] oops forgot to push --- LightlessSync/PlayerData/Handlers/PairHandler.cs | 12 ++++++++++-- .../Services/CharaData/CharaDataNearbyManager.cs | 4 ++-- LightlessSync/Services/DalamudUtilService.cs | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/LightlessSync/PlayerData/Handlers/PairHandler.cs b/LightlessSync/PlayerData/Handlers/PairHandler.cs index 5947f80..24cd87f 100644 --- a/LightlessSync/PlayerData/Handlers/PairHandler.cs +++ b/LightlessSync/PlayerData/Handlers/PairHandler.cs @@ -88,11 +88,19 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase _redrawOnNextApplication = true; } }); - Mediator.Subscribe(this, (msg) => + Mediator.Subscribe(this, (msg) => { EnableSync(); }); - Mediator.Subscribe(this, _ => + Mediator.Subscribe(this, _ => + { + DisableSync(); + }); + Mediator.Subscribe(this, (msg) => + { + EnableSync(); + }); + Mediator.Subscribe(this, _ => { DisableSync(); }); diff --git a/LightlessSync/Services/CharaData/CharaDataNearbyManager.cs b/LightlessSync/Services/CharaData/CharaDataNearbyManager.cs index 8b86e8e..b3d4800 100644 --- a/LightlessSync/Services/CharaData/CharaDataNearbyManager.cs +++ b/LightlessSync/Services/CharaData/CharaDataNearbyManager.cs @@ -236,7 +236,7 @@ public sealed class CharaDataNearbyManager : DisposableMediatorSubscriberBase } } - if (_charaDataConfigService.Current.NearbyDrawWisps && !_dalamudUtilService.IsInGpose && !_dalamudUtilService.IsInCombatOrPerforming) + if (_charaDataConfigService.Current.NearbyDrawWisps && !_dalamudUtilService.IsInGpose && !_dalamudUtilService.IsInCombat && !_dalamudUtilService.IsPerforming && !_dalamudUtilService.IsInInstance) await _dalamudUtilService.RunOnFrameworkThread(() => ManageWispsNearby(previousPoses)).ConfigureAwait(false); } @@ -253,7 +253,7 @@ public sealed class CharaDataNearbyManager : DisposableMediatorSubscriberBase return; } - if (!_charaDataConfigService.Current.NearbyDrawWisps || _dalamudUtilService.IsInGpose || _dalamudUtilService.IsInCombatOrPerforming) + if (!_charaDataConfigService.Current.NearbyDrawWisps || _dalamudUtilService.IsInGpose || _dalamudUtilService.IsInCombat || _dalamudUtilService.IsPerforming || _dalamudUtilService.IsInInstance) ClearAllVfx(); var camera = CameraManager.Instance()->CurrentCamera; diff --git a/LightlessSync/Services/DalamudUtilService.cs b/LightlessSync/Services/DalamudUtilService.cs index 88b0ee1..ea21af7 100644 --- a/LightlessSync/Services/DalamudUtilService.cs +++ b/LightlessSync/Services/DalamudUtilService.cs @@ -767,7 +767,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber _classJobId = localPlayer.ClassJob.RowId; } - if (!IsInCombatOrPerforming) + if (!IsInCombat || !IsPerforming || !IsInInstance) Mediator.Publish(new FrameworkUpdateMessage()); Mediator.Publish(new PriorityFrameworkUpdateMessage()); @@ -796,7 +796,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber IsLodEnabled = lodEnabled; } - if (IsInCombatOrPerforming) + if (IsInCombat || IsPerforming || IsInInstance) Mediator.Publish(new FrameworkUpdateMessage()); Mediator.Publish(new DelayedFrameworkUpdateMessage()); -- 2.49.1