fix pet spaghetti
This commit is contained in:
@@ -69,6 +69,8 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase
|
|||||||
_semiTransientResources = new();
|
_semiTransientResources = new();
|
||||||
PlayerConfig.JobSpecificCache.TryGetValue(_dalamudUtil.ClassJobId, out var jobSpecificData);
|
PlayerConfig.JobSpecificCache.TryGetValue(_dalamudUtil.ClassJobId, out var jobSpecificData);
|
||||||
_semiTransientResources[ObjectKind.Player] = PlayerConfig.GlobalPersistentCache.Concat(jobSpecificData ?? []).ToHashSet(StringComparer.Ordinal);
|
_semiTransientResources[ObjectKind.Player] = PlayerConfig.GlobalPersistentCache.Concat(jobSpecificData ?? []).ToHashSet(StringComparer.Ordinal);
|
||||||
|
PlayerConfig.JobSpecificPetCache.TryGetValue(_dalamudUtil.ClassJobId, out var petSpecificData);
|
||||||
|
_semiTransientResources[ObjectKind.Pet] = [.. petSpecificData ?? []];
|
||||||
}
|
}
|
||||||
|
|
||||||
return _semiTransientResources;
|
return _semiTransientResources;
|
||||||
@@ -131,6 +133,20 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
_configurationService.Save();
|
_configurationService.Save();
|
||||||
}
|
}
|
||||||
|
else if (objectKind == ObjectKind.Pet && newlyAddedGamePaths.Any())
|
||||||
|
{
|
||||||
|
foreach (var item in newlyAddedGamePaths.Where(f => !string.IsNullOrEmpty(f)))
|
||||||
|
{
|
||||||
|
if (!PlayerConfig.JobSpecificPetCache.TryGetValue(_dalamudUtil.ClassJobId, out var petPerma))
|
||||||
|
{
|
||||||
|
PlayerConfig.JobSpecificPetCache[_dalamudUtil.ClassJobId] = petPerma = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
petPerma.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
_configurationService.Save();
|
||||||
|
}
|
||||||
|
|
||||||
TransientResources[objectKind].Clear();
|
TransientResources[objectKind].Clear();
|
||||||
}
|
}
|
||||||
@@ -148,15 +164,19 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AddSemiTransientResource(ObjectKind objectKind, string item)
|
internal bool AddTransientResource(ObjectKind objectKind, string item)
|
||||||
{
|
{
|
||||||
if (!SemiTransientResources.TryGetValue(objectKind, out HashSet<string>? value))
|
if (SemiTransientResources.TryGetValue(objectKind, out var semiTransient) && semiTransient != null && semiTransient.Contains(item))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!TransientResources.TryGetValue(objectKind, out HashSet<string>? value))
|
||||||
{
|
{
|
||||||
value = new HashSet<string>(StringComparer.Ordinal);
|
value = new HashSet<string>(StringComparer.Ordinal);
|
||||||
SemiTransientResources[objectKind] = value;
|
TransientResources[objectKind] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
value.Add(item.ToLowerInvariant());
|
value.Add(item.ToLowerInvariant());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ClearTransientPaths(ObjectKind objectKind, List<string> list)
|
internal void ClearTransientPaths(ObjectKind objectKind, List<string> list)
|
||||||
@@ -204,7 +224,7 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase
|
|||||||
|
|
||||||
private void DalamudUtil_FrameworkUpdate()
|
private void DalamudUtil_FrameworkUpdate()
|
||||||
{
|
{
|
||||||
_cachedFrameAddresses = _cachedFrameAddresses = new ConcurrentDictionary<nint, ObjectKind>(_playerRelatedPointers.Where(k => k.Address != nint.Zero).ToDictionary(c => c.CurrentAddress(), c => c.ObjectKind));
|
_cachedFrameAddresses = _cachedFrameAddresses = new(_playerRelatedPointers.Where(k => k.Address != nint.Zero).ToDictionary(c => c.CurrentAddress(), c => c.ObjectKind));
|
||||||
lock (_cacheAdditionLock)
|
lock (_cacheAdditionLock)
|
||||||
{
|
{
|
||||||
_cachedHandledPaths.Clear();
|
_cachedHandledPaths.Clear();
|
||||||
@@ -221,6 +241,8 @@ public sealed class TransientResourceManager : DisposableMediatorSubscriberBase
|
|||||||
// reload config for current new classjob
|
// reload config for current new classjob
|
||||||
PlayerConfig.JobSpecificCache.TryGetValue(_dalamudUtil.ClassJobId, out var jobSpecificData);
|
PlayerConfig.JobSpecificCache.TryGetValue(_dalamudUtil.ClassJobId, out var jobSpecificData);
|
||||||
SemiTransientResources[ObjectKind.Player] = PlayerConfig.GlobalPersistentCache.Concat(jobSpecificData ?? []).ToHashSet(StringComparer.OrdinalIgnoreCase);
|
SemiTransientResources[ObjectKind.Player] = PlayerConfig.GlobalPersistentCache.Concat(jobSpecificData ?? []).ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||||
|
PlayerConfig.JobSpecificPetCache.TryGetValue(_dalamudUtil.ClassJobId, out var petSpecificData);
|
||||||
|
SemiTransientResources[ObjectKind.Pet] = [.. petSpecificData ?? []];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var kind in Enum.GetValues(typeof(ObjectKind)))
|
foreach (var kind in Enum.GetValues(typeof(ObjectKind)))
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public class TransientConfig : IMareConfiguration
|
|||||||
{
|
{
|
||||||
public List<string> GlobalPersistentCache { get; set; } = [];
|
public List<string> GlobalPersistentCache { get; set; } = [];
|
||||||
public Dictionary<uint, List<string>> JobSpecificCache { get; set; } = [];
|
public Dictionary<uint, List<string>> JobSpecificCache { get; set; } = [];
|
||||||
|
public Dictionary<uint, List<string>> JobSpecificPetCache { get; set; } = [];
|
||||||
|
|
||||||
public TransientPlayerConfig()
|
public TransientPlayerConfig()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -168,13 +168,18 @@ public class PlayerDataFactory
|
|||||||
// or we get into redraw city for every change and nothing works properly
|
// or we get into redraw city for every change and nothing works properly
|
||||||
if (objectKind == ObjectKind.Pet)
|
if (objectKind == ObjectKind.Pet)
|
||||||
{
|
{
|
||||||
foreach (var item in previousData.FileReplacements[objectKind].Where(i => i.HasFileReplacement).SelectMany(p => p.GamePaths))
|
foreach (var item in previousData.FileReplacements[ObjectKind.Pet].Where(i => i.HasFileReplacement).SelectMany(p => p.GamePaths))
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Persisting {item}", item);
|
if (_transientResourceManager.AddTransientResource(objectKind, item))
|
||||||
_transientResourceManager.AddSemiTransientResource(objectKind, item);
|
{
|
||||||
|
_logger.LogDebug("Marking static {item} for Pet as transient", item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.LogTrace("Clearing {count} Static Replacements for Pet", previousData.FileReplacements[ObjectKind.Pet].Count);
|
||||||
|
previousData.FileReplacements[ObjectKind.Pet].Clear();
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogDebug("Handling transient update for {obj}", playerRelatedObject);
|
_logger.LogDebug("Handling transient update for {obj}", playerRelatedObject);
|
||||||
|
|
||||||
// remove all potentially gathered paths from the transient resource manager that are resolved through static resolving
|
// remove all potentially gathered paths from the transient resource manager that are resolved through static resolving
|
||||||
|
|||||||
Reference in New Issue
Block a user