idk some cleanup
This commit is contained in:
@@ -257,63 +257,62 @@ public class PlayerDataFactory
|
|||||||
|
|
||||||
private async Task VerifyPlayerAnimationBones(Dictionary<string, List<ushort>>? boneIndices, CharacterData previousData, ObjectKind objectKind)
|
private async Task VerifyPlayerAnimationBones(Dictionary<string, List<ushort>>? 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;
|
int noValidationFailed = 0;
|
||||||
foreach (var file in previousData.FileReplacements[objectKind].Where(f => !f.IsFileSwap && f.GamePaths.First().EndsWith("pap", StringComparison.OrdinalIgnoreCase)).ToList())
|
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);
|
// 105 is the maximum vanilla skellington spoopy bone index
|
||||||
bool validationFailed = false;
|
if (skeletonIndices.All(k => k.Value.Max() <= 105))
|
||||||
if (skeletonIndices != null)
|
|
||||||
{
|
{
|
||||||
// 105 is the maximum vanilla skellington spoopy bone index
|
_logger.LogTrace("All indices of {path} are <= 105, ignoring", file.ResolvedPath);
|
||||||
if (skeletonIndices.All(k => k.Value.Max() <= 105))
|
continue;
|
||||||
{
|
|
||||||
_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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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++;
|
if (boneCount.Value.Max() > boneIndices.SelectMany(b => b.Value).Max())
|
||||||
_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);
|
_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",
|
noValidationFailed++;
|
||||||
$"Your client is attempting to send {noValidationFailed} animation files with invalid bone data. Those animation files have been removed from your sent data. " +
|
_logger.LogDebug("Removing {file} from sent file replacements and transient data", file.ResolvedPath);
|
||||||
$"Verify that you are using the correct skeleton for those animation files (Check /xllog for more information).",
|
previousData.FileReplacements[objectKind].Remove(file);
|
||||||
Dalamud.Interface.Internal.Notifications.NotificationType.Warning, TimeSpan.FromSeconds(10)));
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public sealed class XivDataAnalyzer
|
|||||||
_logger.LogWarning(ex, "Could not process skeleton data");
|
_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<string, List<ushort>>? GetBoneIndicesFromPap(string hash)
|
public unsafe Dictionary<string, List<ushort>>? GetBoneIndicesFromPap(string hash)
|
||||||
|
|||||||
Reference in New Issue
Block a user