diff --git a/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs b/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs index 741d0d2..41faedb 100644 --- a/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs +++ b/MareSynchronos/PlayerData/Factories/PlayerDataFactory.cs @@ -257,63 +257,62 @@ public class PlayerDataFactory private async Task VerifyPlayerAnimationBones(Dictionary>? boneIndices, CharacterData previousData, ObjectKind objectKind) { - if (boneIndices != null) + if (boneIndices == null) return; + + foreach (var kvp in boneIndices) { - foreach (var kvp in boneIndices) - { - _logger.LogDebug("Found {skellyname} ({idx} bone indices) on player: {bones}", kvp.Key, kvp.Value.Any() ? kvp.Value.Max() : 0, string.Join(',', kvp.Value)); - } + _logger.LogDebug("Found {skellyname} ({idx} bone indices) on player: {bones}", kvp.Key, kvp.Value.Any() ? kvp.Value.Max() : 0, string.Join(',', kvp.Value)); + } - if (boneIndices.All(u => u.Value.Count == 0)) return; + if (boneIndices.All(u => u.Value.Count == 0)) return; - int noValidationFailed = 0; - foreach (var file in previousData.FileReplacements[objectKind].Where(f => !f.IsFileSwap && f.GamePaths.First().EndsWith("pap", StringComparison.OrdinalIgnoreCase)).ToList()) + int noValidationFailed = 0; + foreach (var file in previousData.FileReplacements[objectKind].Where(f => !f.IsFileSwap && f.GamePaths.First().EndsWith("pap", StringComparison.OrdinalIgnoreCase)).ToList()) + { + var skeletonIndices = await _dalamudUtil.RunOnFrameworkThread(() => _modelAnalyzer.GetBoneIndicesFromPap(file.Hash)).ConfigureAwait(false); + bool validationFailed = false; + if (skeletonIndices != null) { - var skeletonIndices = await _dalamudUtil.RunOnFrameworkThread(() => _modelAnalyzer.GetBoneIndicesFromPap(file.Hash)).ConfigureAwait(false); - bool validationFailed = false; - if (skeletonIndices != null) + // 105 is the maximum vanilla skellington spoopy bone index + if (skeletonIndices.All(k => k.Value.Max() <= 105)) { - // 105 is the maximum vanilla skellington spoopy bone index - if (skeletonIndices.All(k => k.Value.Max() <= 105)) - { - _logger.LogTrace("All indices of {path} are <= 105, ignoring", file.ResolvedPath); - continue; - } - - _logger.LogDebug("Verifying bone indices for {path}, found {x} skeletons", file.ResolvedPath, skeletonIndices.Count); - - foreach (var boneCount in skeletonIndices.Select(k => k).ToList()) - { - if (boneCount.Value.Max() > boneIndices.SelectMany(b => b.Value).Max()) - { - _logger.LogWarning("Found more bone indices on the animation {path} skeleton {skl} (max indice {idx}) than on any player related skeleton (max indice {idx2})", - file.ResolvedPath, boneCount.Key, boneCount.Value.Max(), boneIndices.SelectMany(b => b.Value).Max()); - validationFailed = true; - break; - } - } + _logger.LogTrace("All indices of {path} are <= 105, ignoring", file.ResolvedPath); + continue; } - if (validationFailed) + _logger.LogDebug("Verifying bone indices for {path}, found {x} skeletons", file.ResolvedPath, skeletonIndices.Count); + + foreach (var boneCount in skeletonIndices.Select(k => k).ToList()) { - noValidationFailed++; - _logger.LogDebug("Removing {file} from sent file replacements and transient data", file.ResolvedPath); - previousData.FileReplacements[objectKind].Remove(file); - foreach (var gamePath in file.GamePaths) + if (boneCount.Value.Max() > boneIndices.SelectMany(b => b.Value).Max()) { - _transientResourceManager.RemoveTransientResource(objectKind, gamePath); + _logger.LogWarning("Found more bone indices on the animation {path} skeleton {skl} (max indice {idx}) than on any player related skeleton (max indice {idx2})", + file.ResolvedPath, boneCount.Key, boneCount.Value.Max(), boneIndices.SelectMany(b => b.Value).Max()); + validationFailed = true; + break; } } - } - if (noValidationFailed > 0) + if (validationFailed) { - _mareMediator.Publish(new NotificationMessage("Invalid Skeleton Setup", - $"Your client is attempting to send {noValidationFailed} animation files with invalid bone data. Those animation files have been removed from your sent data. " + - $"Verify that you are using the correct skeleton for those animation files (Check /xllog for more information).", - Dalamud.Interface.Internal.Notifications.NotificationType.Warning, TimeSpan.FromSeconds(10))); + noValidationFailed++; + _logger.LogDebug("Removing {file} from sent file replacements and transient data", file.ResolvedPath); + previousData.FileReplacements[objectKind].Remove(file); + foreach (var gamePath in file.GamePaths) + { + _transientResourceManager.RemoveTransientResource(objectKind, gamePath); + } } + + } + + if (noValidationFailed > 0) + { + _mareMediator.Publish(new NotificationMessage("Invalid Skeleton Setup", + $"Your client is attempting to send {noValidationFailed} animation files with invalid bone data. Those animation files have been removed from your sent data. " + + $"Verify that you are using the correct skeleton for those animation files (Check /xllog for more information).", + Dalamud.Interface.Internal.Notifications.NotificationType.Warning, TimeSpan.FromSeconds(10))); } } diff --git a/MareSynchronos/Services/XivDataAnalyzer.cs b/MareSynchronos/Services/XivDataAnalyzer.cs index bc11312..8263cbd 100644 --- a/MareSynchronos/Services/XivDataAnalyzer.cs +++ b/MareSynchronos/Services/XivDataAnalyzer.cs @@ -59,7 +59,7 @@ public sealed class XivDataAnalyzer _logger.LogWarning(ex, "Could not process skeleton data"); } - return outputIndices; + return (outputIndices.Count != 0 && outputIndices.Values.All(u => u.Count > 0)) ? outputIndices : null; } public unsafe Dictionary>? GetBoneIndicesFromPap(string hash)