disable data application and scanner in combat
This commit is contained in:
@@ -177,7 +177,7 @@ public sealed class FileCacheManager : IDisposable
|
||||
|
||||
public Task<List<FileCacheEntity>> ValidateLocalIntegrity(IProgress<(int, int, FileCacheEntity)> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
_mareMediator.Publish(new HaltScanMessage("IntegrityCheck"));
|
||||
_mareMediator.Publish(new HaltScanMessage(nameof(ValidateLocalIntegrity)));
|
||||
_logger.LogInformation("Validating local storage");
|
||||
var cacheEntries = _fileCaches.SelectMany(v => v.Value).Where(v => v.IsCacheEntry).ToList();
|
||||
List<FileCacheEntity> brokenEntities = new();
|
||||
@@ -212,7 +212,7 @@ public sealed class FileCacheManager : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
_mareMediator.Publish(new ResumeScanMessage("IntegrityCheck"));
|
||||
_mareMediator.Publish(new ResumeScanMessage(nameof(ValidateLocalIntegrity)));
|
||||
return Task.FromResult(brokenEntities);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase
|
||||
Mediator.Subscribe<FrameworkUpdateMessage>(this, (_) => DalamudUtil_FrameworkUpdate());
|
||||
Mediator.Subscribe<ClassJobChangedMessage>(this, (msg) =>
|
||||
{
|
||||
if (_playerRelatedPointers.Contains(msg.gameObjectHandler))
|
||||
if (_playerRelatedPointers.Contains(msg.GameObjectHandler))
|
||||
{
|
||||
DalamudUtil_ClassJobChanged();
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
||||
{
|
||||
if (!CheckPenumbraApi()) return;
|
||||
|
||||
Mediator.Publish(new HaltScanMessage("TextureConversion"));
|
||||
Mediator.Publish(new HaltScanMessage(nameof(PenumbraConvertTextureFiles)));
|
||||
int currentTexture = 0;
|
||||
foreach (var texture in textures)
|
||||
{
|
||||
@@ -519,7 +519,7 @@ public sealed class IpcManager : DisposableMediatorSubscriberBase
|
||||
}
|
||||
}
|
||||
}
|
||||
Mediator.Publish(new ResumeScanMessage("TextureConversion"));
|
||||
Mediator.Publish(new ResumeScanMessage(nameof(PenumbraConvertTextureFiles)));
|
||||
|
||||
await _dalamudUtil.RunOnFrameworkThread(async () =>
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.Interop;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.PlayerData.Handlers;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
@@ -21,13 +20,12 @@ public class PairHandlerFactory
|
||||
private readonly IpcManager _ipcManager;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
private readonly MareMediator _mareMediator;
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
private readonly PluginWarningNotificationService _pluginWarningNotificationManager;
|
||||
|
||||
public PairHandlerFactory(ILoggerFactory loggerFactory, GameObjectHandlerFactory gameObjectHandlerFactory, IpcManager ipcManager,
|
||||
FileDownloadManagerFactory fileDownloadManagerFactory, DalamudUtilService dalamudUtilService,
|
||||
PluginWarningNotificationService pluginWarningNotificationManager, IHostApplicationLifetime hostApplicationLifetime,
|
||||
FileCacheManager fileCacheManager, MareMediator mareMediator, MareConfigService mareConfigService)
|
||||
FileCacheManager fileCacheManager, MareMediator mareMediator)
|
||||
{
|
||||
_loggerFactory = loggerFactory;
|
||||
_gameObjectHandlerFactory = gameObjectHandlerFactory;
|
||||
@@ -38,13 +36,12 @@ public class PairHandlerFactory
|
||||
_hostApplicationLifetime = hostApplicationLifetime;
|
||||
_fileCacheManager = fileCacheManager;
|
||||
_mareMediator = mareMediator;
|
||||
_mareConfigService = mareConfigService;
|
||||
}
|
||||
|
||||
public PairHandler Create(OnlineUserIdentDto onlineUserIdentDto)
|
||||
{
|
||||
return new PairHandler(_loggerFactory.CreateLogger<PairHandler>(), onlineUserIdentDto, _gameObjectHandlerFactory,
|
||||
_ipcManager, _fileDownloadManagerFactory.Create(), _pluginWarningNotificationManager, _dalamudUtilService, _hostApplicationLifetime,
|
||||
_fileCacheManager, _mareMediator, _mareConfigService);
|
||||
_fileCacheManager, _mareMediator);
|
||||
}
|
||||
}
|
||||
@@ -361,6 +361,7 @@ public class PlayerDataFactory
|
||||
{
|
||||
foreach (var item in previousData.FileReplacements[objectKind].Where(i => i.HasFileReplacement).SelectMany(p => p.GamePaths))
|
||||
{
|
||||
_logger.LogDebug("Persisting {item}", item);
|
||||
_transientResourceManager.AddSemiTransientResource(objectKind, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using MareSynchronos.API.Dto.User;
|
||||
using MareSynchronos.FileCache;
|
||||
using MareSynchronos.Interop;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.PlayerData.Factories;
|
||||
using MareSynchronos.PlayerData.Pairs;
|
||||
using MareSynchronos.Services;
|
||||
@@ -22,7 +21,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
private readonly DalamudUtilService _dalamudUtil;
|
||||
private readonly FileDownloadManager _downloadManager;
|
||||
private readonly FileCacheManager _fileDbManager;
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
private readonly GameObjectHandlerFactory _gameObjectHandlerFactory;
|
||||
private readonly IpcManager _ipcManager;
|
||||
private readonly IHostApplicationLifetime _lifetime;
|
||||
@@ -44,8 +42,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
IpcManager ipcManager, FileDownloadManager transferManager,
|
||||
PluginWarningNotificationService pluginWarningNotificationManager,
|
||||
DalamudUtilService dalamudUtil, IHostApplicationLifetime lifetime,
|
||||
FileCacheManager fileDbManager, MareMediator mediator,
|
||||
MareConfigService mareConfigService) : base(logger, mediator)
|
||||
FileCacheManager fileDbManager, MareMediator mediator) : base(logger, mediator)
|
||||
{
|
||||
OnlineUser = onlineUser;
|
||||
_gameObjectHandlerFactory = gameObjectHandlerFactory;
|
||||
@@ -55,7 +52,6 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_lifetime = lifetime;
|
||||
_fileDbManager = fileDbManager;
|
||||
_mareConfigService = mareConfigService;
|
||||
_penumbraCollection = _ipcManager.PenumbraCreateTemporaryCollectionAsync(logger, OnlineUser.User.UID).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
|
||||
Mediator.Subscribe<FrameworkUpdateMessage>(this, (_) => FrameworkUpdate());
|
||||
@@ -77,11 +73,24 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
});
|
||||
Mediator.Subscribe<ClassJobChangedMessage>(this, (msg) =>
|
||||
{
|
||||
if (msg.gameObjectHandler == _charaHandler)
|
||||
if (msg.GameObjectHandler == _charaHandler)
|
||||
{
|
||||
_redrawOnNextApplication = true;
|
||||
}
|
||||
});
|
||||
Mediator.Subscribe<CombatEndMessage>(this, (msg) =>
|
||||
{
|
||||
if (IsVisible && _cachedData != null)
|
||||
{
|
||||
Guid g = Guid.NewGuid();
|
||||
ApplyCharacterData(g, _cachedData, true);
|
||||
}
|
||||
});
|
||||
Mediator.Subscribe<CombatStartMessage>(this, _ =>
|
||||
{
|
||||
_downloadCancellationTokenSource = _downloadCancellationTokenSource?.CancelRecreate();
|
||||
_applicationCancellationTokenSource = _applicationCancellationTokenSource?.CancelRecreate();
|
||||
});
|
||||
|
||||
LastAppliedDataSize = -1;
|
||||
}
|
||||
@@ -108,15 +117,17 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
|
||||
public void ApplyCharacterData(Guid applicationBase, CharacterData characterData, bool forceApplyCustomization = false)
|
||||
{
|
||||
if (_charaHandler == null || (PlayerCharacter == IntPtr.Zero))
|
||||
if (_charaHandler == null || (PlayerCharacter == IntPtr.Zero) || _dalamudUtil.IsInCombat)
|
||||
{
|
||||
Logger.LogDebug("[BASE-{appBase}] Received data but player was in invalid state, charaHandlerIsNull: {charaIsNull}, playerPointerIsNull: {ptrIsNull}",
|
||||
applicationBase, _charaHandler == null, PlayerCharacter == IntPtr.Zero);
|
||||
Logger.LogDebug("[BASE-{appBase}] Received data but player was in invalid state, inCombat: {inCombat}, charaHandlerIsNull: {charaIsNull}, playerPointerIsNull: {ptrIsNull}",
|
||||
applicationBase, _dalamudUtil.IsInCombat, _charaHandler == null, PlayerCharacter == IntPtr.Zero);
|
||||
var hasDiffMods = characterData.CheckUpdatedData(applicationBase, _cachedData, Logger,
|
||||
this, forceApplyCustomization, forceApplyMods: false).Any(p => p.Value.Contains(PlayerChanges.ModManip) || p.Value.Contains(PlayerChanges.ModFiles));
|
||||
this, forceApplyCustomization, forceApplyMods: false)
|
||||
.Any(p => p.Value.Contains(PlayerChanges.ModManip) || p.Value.Contains(PlayerChanges.ModFiles));
|
||||
_forceApplyMods = hasDiffMods || _forceApplyMods || (PlayerCharacter == IntPtr.Zero && _cachedData == null);
|
||||
_cachedData = characterData;
|
||||
Logger.LogDebug("[BASE-{appBase}] Setting data: {hash}, forceApplyMods: {force}", applicationBase, _cachedData.DataHash.Value, _forceApplyMods);
|
||||
if (_dalamudUtil.IsInCombat) SetUploading(isUploading: false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,8 +48,21 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase
|
||||
_playerRelatedObjects[ObjectKind.Companion] = gameObjectHandlerFactory.Create(ObjectKind.Companion, () => dalamudUtil.GetCompanion(), isWatched: true)
|
||||
.GetAwaiter().GetResult();
|
||||
|
||||
Mediator.Subscribe<ClassJobChangedMessage>(this, (msg) =>
|
||||
{
|
||||
if (msg.GameObjectHandler != _playerRelatedObjects[ObjectKind.Player]) return;
|
||||
|
||||
Logger.LogTrace("Removing pet data for {obj}", msg.GameObjectHandler);
|
||||
_playerData.FileReplacements.Remove(ObjectKind.Pet);
|
||||
_playerData.GlamourerString.Remove(ObjectKind.Pet);
|
||||
_playerData.CustomizePlusScale.Remove(ObjectKind.Pet);
|
||||
Mediator.Publish(new CharacterDataCreatedMessage(_playerData.ToAPI()));
|
||||
});
|
||||
|
||||
Mediator.Subscribe<ClearCacheForObjectMessage>(this, (msg) =>
|
||||
{
|
||||
// ignore pets
|
||||
if (msg.ObjectToCreateFor == _playerRelatedObjects[ObjectKind.Pet]) return;
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
Logger.LogTrace("Clearing cache for {obj}", msg.ObjectToCreateFor);
|
||||
|
||||
@@ -51,8 +51,9 @@ public sealed class CharacterAnalyzer : MediatorSubscriberBase, IDisposable
|
||||
CurrentFile = 1;
|
||||
Logger.LogDebug("=== Computing {amount} remaining files ===", remaining.Count);
|
||||
|
||||
Mediator.Publish(new HaltScanMessage("CharacterAnalyzer"));
|
||||
|
||||
Mediator.Publish(new HaltScanMessage(nameof(CharacterAnalyzer)));
|
||||
try
|
||||
{
|
||||
foreach (var file in remaining)
|
||||
{
|
||||
Logger.LogDebug("Computing file {file}", file.FilePaths[0]);
|
||||
@@ -62,7 +63,15 @@ public sealed class CharacterAnalyzer : MediatorSubscriberBase, IDisposable
|
||||
|
||||
_fileCacheManager.WriteOutFullCsv();
|
||||
|
||||
Mediator.Publish(new ResumeScanMessage("CharacterAnalzyer"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogWarning(ex, "Failed to analyze files");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Mediator.Publish(new ResumeScanMessage(nameof(CharacterAnalyzer)));
|
||||
}
|
||||
}
|
||||
|
||||
Mediator.Publish(new CharacterDataAnalyzedMessage());
|
||||
|
||||
@@ -35,7 +35,8 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
private bool _sentBetweenAreas = false;
|
||||
|
||||
public DalamudUtilService(ILogger<DalamudUtilService> logger, IClientState clientState, IObjectTable objectTable, IFramework framework,
|
||||
IGameGui gameGui, ICondition condition, IDataManager gameData, ITargetManager targetManager, MareMediator mediator, PerformanceCollectorService performanceCollector)
|
||||
IGameGui gameGui, ICondition condition, IDataManager gameData, ITargetManager targetManager,
|
||||
MareMediator mediator, PerformanceCollectorService performanceCollector)
|
||||
{
|
||||
_logger = logger;
|
||||
_clientState = clientState;
|
||||
@@ -73,6 +74,7 @@ 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 IsInCombat { get; private set; } = false;
|
||||
|
||||
public Lazy<Dictionary<ushort, string>> WorldData { get; private set; }
|
||||
|
||||
@@ -457,19 +459,34 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
Mediator.Publish(new GposeEndMessage());
|
||||
}
|
||||
|
||||
if (_condition[ConditionFlag.InCombat] && !IsInCombat)
|
||||
{
|
||||
_logger.LogDebug("Combat start");
|
||||
IsInCombat = true;
|
||||
Mediator.Publish(new CombatStartMessage());
|
||||
Mediator.Publish(new HaltScanMessage(nameof(IsInCombat)));
|
||||
}
|
||||
else if (!_condition[ConditionFlag.InCombat] && IsInCombat)
|
||||
{
|
||||
_logger.LogDebug("Combat end");
|
||||
IsInCombat = false;
|
||||
Mediator.Publish(new CombatEndMessage());
|
||||
Mediator.Publish(new ResumeScanMessage(nameof(IsInCombat)));
|
||||
}
|
||||
|
||||
if (_condition[ConditionFlag.WatchingCutscene] && !IsInCutscene)
|
||||
{
|
||||
_logger.LogDebug("Cutscene start");
|
||||
IsInCutscene = true;
|
||||
Mediator.Publish(new CutsceneStartMessage());
|
||||
Mediator.Publish(new HaltScanMessage("Cutscene"));
|
||||
Mediator.Publish(new HaltScanMessage(nameof(IsInCutscene)));
|
||||
}
|
||||
else if (!_condition[ConditionFlag.WatchingCutscene] && IsInCutscene)
|
||||
{
|
||||
_logger.LogDebug("Cutscene end");
|
||||
IsInCutscene = false;
|
||||
Mediator.Publish(new CutsceneEndMessage());
|
||||
Mediator.Publish(new ResumeScanMessage("Cutscene"));
|
||||
Mediator.Publish(new ResumeScanMessage(nameof(IsInCutscene)));
|
||||
}
|
||||
|
||||
if (IsInCutscene) { Mediator.Publish(new CutsceneFrameworkUpdateMessage()); return; }
|
||||
@@ -485,7 +502,7 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
_logger.LogDebug("Zone switch/Gpose start");
|
||||
_sentBetweenAreas = true;
|
||||
Mediator.Publish(new ZoneSwitchStartMessage());
|
||||
Mediator.Publish(new HaltScanMessage("Zone switch"));
|
||||
Mediator.Publish(new HaltScanMessage(nameof(ConditionFlag.BetweenAreas)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,9 +514,10 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
_logger.LogDebug("Zone switch/Gpose end");
|
||||
_sentBetweenAreas = false;
|
||||
Mediator.Publish(new ZoneSwitchEndMessage());
|
||||
Mediator.Publish(new ResumeScanMessage("Zone switch"));
|
||||
Mediator.Publish(new ResumeScanMessage(nameof(ConditionFlag.BetweenAreas)));
|
||||
}
|
||||
|
||||
if (!IsInCombat)
|
||||
Mediator.Publish(new FrameworkUpdateMessage());
|
||||
|
||||
if (DateTime.Now < _delayedFrameworkUpdateCheck.AddSeconds(1)) return;
|
||||
@@ -520,6 +538,9 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
Mediator.Publish(new DalamudLogoutMessage());
|
||||
}
|
||||
|
||||
if (IsInCombat)
|
||||
Mediator.Publish(new FrameworkUpdateMessage());
|
||||
|
||||
Mediator.Publish(new DelayedFrameworkUpdateMessage());
|
||||
|
||||
_delayedFrameworkUpdateCheck = DateTime.Now;
|
||||
|
||||
@@ -18,7 +18,7 @@ public record OpenSettingsUiMessage : MessageBase;
|
||||
public record DalamudLoginMessage : MessageBase;
|
||||
public record DalamudLogoutMessage : MessageBase;
|
||||
public record FrameworkUpdateMessage : SameThreadMessage;
|
||||
public record ClassJobChangedMessage(GameObjectHandler gameObjectHandler) : MessageBase;
|
||||
public record ClassJobChangedMessage(GameObjectHandler GameObjectHandler) : MessageBase;
|
||||
public record DelayedFrameworkUpdateMessage : SameThreadMessage;
|
||||
public record ZoneSwitchStartMessage : MessageBase;
|
||||
public record ZoneSwitchEndMessage : MessageBase;
|
||||
@@ -78,6 +78,8 @@ 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 CombatStartMessage : MessageBase;
|
||||
public record CombatEndMessage : MessageBase;
|
||||
|
||||
#pragma warning restore S2094
|
||||
#pragma warning restore MA0048 // File name must match type name
|
||||
@@ -173,7 +173,7 @@ public sealed class PerformanceCollectorService : IHostedService
|
||||
{
|
||||
try
|
||||
{
|
||||
var last = entries.Value.Last();
|
||||
var last = entries.Value.ToList().Last();
|
||||
if (last.Item1.AddMinutes(10) < TimeOnly.FromDateTime(DateTime.Now) && !_performanceCounters.TryRemove(entries.Key, out _))
|
||||
{
|
||||
_logger.LogDebug("Could not remove performance counter {counter}", entries.Key);
|
||||
|
||||
@@ -65,7 +65,7 @@ public partial class FileDownloadManager : DisposableMediatorSubscriberBase
|
||||
|
||||
public async Task DownloadFiles(GameObjectHandler gameObject, List<FileReplacementData> fileReplacementDto, CancellationToken ct)
|
||||
{
|
||||
Mediator.Publish(new HaltScanMessage("Download"));
|
||||
Mediator.Publish(new HaltScanMessage(nameof(DownloadFiles)));
|
||||
try
|
||||
{
|
||||
await DownloadFilesInternal(gameObject, fileReplacementDto, ct).ConfigureAwait(false);
|
||||
@@ -77,7 +77,7 @@ public partial class FileDownloadManager : DisposableMediatorSubscriberBase
|
||||
finally
|
||||
{
|
||||
Mediator.Publish(new DownloadFinishedMessage(gameObject));
|
||||
Mediator.Publish(new ResumeScanMessage("Download"));
|
||||
Mediator.Publish(new ResumeScanMessage(nameof(DownloadFiles)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MareSynchronos.WebAPI.Files
|
||||
namespace MareSynchronos.WebAPI.Files
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for streaming data with throttling support.
|
||||
|
||||
Reference in New Issue
Block a user