Merge tag '0.9.21' into mare-classic

* tag '0.9.21':
  fix combat situations not redrawing every time after combat ends
  add more resilience to MCDF export and loading
  disable data application and scanner in combat
  fix bug
  add lock around adding to cached handled paths
  disable target in pvp
  add click to target in ui
  change tooltip for penumbra version to 0.8.2.1
  add file storage validation
  add experimental resolving of data through penumbra
  adjust initial dialog to opt in/out into census with buttons
This commit is contained in:
Loporrit
2023-12-09 12:06:10 +00:00
23 changed files with 352 additions and 129 deletions

View File

@@ -51,18 +51,27 @@ public sealed class CharacterAnalyzer : MediatorSubscriberBase, IDisposable
CurrentFile = 1;
Logger.LogDebug("=== Computing {amount} remaining files ===", remaining.Count);
Mediator.Publish(new HaltScanMessage("CharacterAnalyzer"));
foreach (var file in remaining)
Mediator.Publish(new HaltScanMessage(nameof(CharacterAnalyzer)));
try
{
Logger.LogDebug("Computing file {file}", file.FilePaths[0]);
await file.ComputeSizes(_fileCacheManager, cancelToken).ConfigureAwait(false);
CurrentFile++;
foreach (var file in remaining)
{
Logger.LogDebug("Computing file {file}", file.FilePaths[0]);
await file.ComputeSizes(_fileCacheManager, cancelToken).ConfigureAwait(false);
CurrentFile++;
}
_fileCacheManager.WriteOutFullCsv();
}
catch (Exception ex)
{
Logger.LogWarning(ex, "Failed to analyze files");
}
finally
{
Mediator.Publish(new ResumeScanMessage(nameof(CharacterAnalyzer)));
}
_fileCacheManager.WriteOutFullCsv();
Mediator.Publish(new ResumeScanMessage("CharacterAnalzyer"));
}
Mediator.Publish(new CharacterDataAnalyzedMessage());

View File

@@ -1,4 +1,5 @@
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.Character;
@@ -15,7 +16,7 @@ using GameObject = FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject;
namespace MareSynchronos.Services;
public class DalamudUtilService : IHostedService
public class DalamudUtilService : IHostedService, IMediatorSubscriber
{
private readonly List<uint> _classJobIdsIgnoredForPets = [30];
private readonly IClientState _clientState;
@@ -23,7 +24,6 @@ public class DalamudUtilService : IHostedService
private readonly IFramework _framework;
private readonly IGameGui _gameGui;
private readonly ILogger<DalamudUtilService> _logger;
private readonly MareMediator _mediator;
private readonly IObjectTable _objectTable;
private readonly PerformanceCollectorService _performanceCollector;
private uint? _classJobId = 0;
@@ -35,7 +35,8 @@ public class DalamudUtilService : IHostedService
private bool _sentBetweenAreas = false;
public DalamudUtilService(ILogger<DalamudUtilService> logger, IClientState clientState, IObjectTable objectTable, IFramework framework,
IGameGui gameGui, ICondition condition, IDataManager gameData, MareMediator mediator, PerformanceCollectorService performanceCollector)
IGameGui gameGui, ICondition condition, IDataManager gameData, ITargetManager targetManager,
MareMediator mediator, PerformanceCollectorService performanceCollector)
{
_logger = logger;
_clientState = clientState;
@@ -43,7 +44,7 @@ public class DalamudUtilService : IHostedService
_framework = framework;
_gameGui = gameGui;
_condition = condition;
_mediator = mediator;
Mediator = mediator;
_performanceCollector = performanceCollector;
WorldData = new(() =>
{
@@ -51,6 +52,18 @@ public class DalamudUtilService : IHostedService
.Where(w => w.IsPublic && !w.Name.RawData.IsEmpty)
.ToDictionary(w => (ushort)w.RowId, w => w.Name.ToString());
});
mediator.Subscribe<TargetPairMessage>(this, async (msg) =>
{
if (clientState.IsPvP) return;
var name = msg.Pair.PlayerName;
if (string.IsNullOrEmpty(name)) return;
var addr = _playerCharas.FirstOrDefault(f => string.Equals(f.Value.Name, name, StringComparison.Ordinal)).Value.Address;
if (addr == nint.Zero) return;
await RunOnFrameworkThread(() =>
{
targetManager.Target = CreateGameObject(addr);
}).ConfigureAwait(false);
});
}
public unsafe GameObject* GposeTarget => TargetSystem.Instance()->GPoseTarget;
@@ -61,9 +74,12 @@ public class DalamudUtilService : IHostedService
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; }
public MareMediator Mediator { get; }
public Dalamud.Game.ClientState.Objects.Types.GameObject? CreateGameObject(IntPtr reference)
{
EnsureIsOnFramework();
@@ -279,6 +295,7 @@ public class DalamudUtilService : IHostedService
{
_logger.LogTrace("Stopping {type}", GetType());
Mediator.UnsubscribeAll(this);
_framework.Update -= FrameworkOnUpdate;
return Task.CompletedTask;
}
@@ -433,31 +450,46 @@ public class DalamudUtilService : IHostedService
{
_logger.LogDebug("Gpose start");
IsInGpose = true;
_mediator.Publish(new GposeStartMessage());
Mediator.Publish(new GposeStartMessage());
}
else if (GposeTarget == null && IsInGpose)
{
_logger.LogDebug("Gpose end");
IsInGpose = false;
_mediator.Publish(new GposeEndMessage());
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 CutsceneStartMessage());
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 CutsceneEndMessage());
Mediator.Publish(new ResumeScanMessage(nameof(IsInCutscene)));
}
if (IsInCutscene) { _mediator.Publish(new CutsceneFrameworkUpdateMessage()); return; }
if (IsInCutscene) { Mediator.Publish(new CutsceneFrameworkUpdateMessage()); return; }
if (_condition[ConditionFlag.BetweenAreas] || _condition[ConditionFlag.BetweenAreas51])
{
@@ -469,8 +501,8 @@ public class DalamudUtilService : IHostedService
{
_logger.LogDebug("Zone switch/Gpose start");
_sentBetweenAreas = true;
_mediator.Publish(new ZoneSwitchStartMessage());
_mediator.Publish(new HaltScanMessage("Zone switch"));
Mediator.Publish(new ZoneSwitchStartMessage());
Mediator.Publish(new HaltScanMessage(nameof(ConditionFlag.BetweenAreas)));
}
}
@@ -481,11 +513,12 @@ public class DalamudUtilService : IHostedService
{
_logger.LogDebug("Zone switch/Gpose end");
_sentBetweenAreas = false;
_mediator.Publish(new ZoneSwitchEndMessage());
_mediator.Publish(new ResumeScanMessage("Zone switch"));
Mediator.Publish(new ZoneSwitchEndMessage());
Mediator.Publish(new ResumeScanMessage(nameof(ConditionFlag.BetweenAreas)));
}
_mediator.Publish(new FrameworkUpdateMessage());
if (!IsInCombat)
Mediator.Publish(new FrameworkUpdateMessage());
if (DateTime.Now < _delayedFrameworkUpdateCheck.AddSeconds(1)) return;
@@ -496,16 +529,19 @@ public class DalamudUtilService : IHostedService
_logger.LogDebug("Logged in");
IsLoggedIn = true;
_lastZone = _clientState.TerritoryType;
_mediator.Publish(new DalamudLoginMessage());
Mediator.Publish(new DalamudLoginMessage());
}
else if (localPlayer == null && IsLoggedIn)
{
_logger.LogDebug("Logged out");
IsLoggedIn = false;
_mediator.Publish(new DalamudLogoutMessage());
Mediator.Publish(new DalamudLogoutMessage());
}
_mediator.Publish(new DelayedFrameworkUpdateMessage());
if (IsInCombat)
Mediator.Publish(new FrameworkUpdateMessage());
Mediator.Publish(new DelayedFrameworkUpdateMessage());
_delayedFrameworkUpdateCheck = DateTime.Now;
}

View File

@@ -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;
@@ -75,6 +75,9 @@ public record OpenSyncshellAdminPanel(GroupFullInfoDto GroupInfo) : MessageBase;
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

View File

@@ -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);