From 47268ab377db99a91cfc14e7560e459bbb095171 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 11 Aug 2024 23:22:42 +0200 Subject: [PATCH] Prevent loading crashy shpks. --- Penumbra/Interop/PathResolving/PathResolver.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Penumbra/Interop/PathResolving/PathResolver.cs b/Penumbra/Interop/PathResolving/PathResolver.cs index 67ec4fc3..63bbc8d8 100644 --- a/Penumbra/Interop/PathResolving/PathResolver.cs +++ b/Penumbra/Interop/PathResolving/PathResolver.cs @@ -61,7 +61,7 @@ public class PathResolver : IDisposable, IService ResourceCategory.GameScript => (null, ResolveData.Invalid), // Use actual resolving. ResourceCategory.Chara => Resolve(path, resourceType), - ResourceCategory.Shader => Resolve(path, resourceType), + ResourceCategory.Shader => ResolveShader(path, resourceType), ResourceCategory.Vfx => Resolve(path, resourceType), ResourceCategory.Sound => Resolve(path, resourceType), // EXD Modding in general should probably be prohibited but is currently used for fan translations. @@ -83,6 +83,19 @@ public class PathResolver : IDisposable, IService }; } + /// Replacing the characterstockings.shpk or the characterocclusion.shpk files currently causes crashes, so we just entirely prevent that. + private (FullPath?, ResolveData) ResolveShader(Utf8GamePath gamePath, ResourceType type) + { + if (type is not ResourceType.Shpk) + return Resolve(gamePath, type); + + if (gamePath.Path.EndsWith("occlusion.shpk"u8) + || gamePath.Path.EndsWith("stockings.shpk"u8)) + return (null, ResolveData.Invalid); + + return Resolve(gamePath, type); + } + public (FullPath?, ResolveData) Resolve(Utf8GamePath gamePath, ResourceType type) { using var performance = _performance.Measure(PerformanceType.CharacterResolver);