4
4
using Penumbra . GameData . Files ;
5
5
using Penumbra . GameData . Files . Utility ;
6
6
using Penumbra . Interop . Hooks . ResourceLoading ;
7
+ using Penumbra . Mods . Manager ;
8
+ using Penumbra . Services ;
7
9
using Penumbra . String ;
8
10
using Penumbra . String . Classes ;
9
- using Penumbra . UI ;
10
11
11
12
namespace Penumbra . Interop . Processing ;
12
13
13
14
/// <summary>
14
15
/// Path pre-processor for shader packages that reverts redirects to known invalid files, as bad ShPks can crash the game.
15
16
/// </summary>
16
- public sealed class ShpkPathPreProcessor ( ResourceManagerService resourceManager , ChatWarningService chatWarningService ) : IPathPreProcessor
17
+ public sealed class ShpkPathPreProcessor ( ResourceManagerService resourceManager , MessageService messager , ModManager modManager )
18
+ : IPathPreProcessor
17
19
{
18
20
public ResourceType Type
19
21
=> ResourceType . Shpk ;
20
22
21
- public unsafe FullPath ? PreProcess ( ResolveData resolveData , CiByteString path , Utf8GamePath originalGamePath , bool nonDefault , FullPath ? resolved )
23
+ public unsafe FullPath ? PreProcess ( ResolveData resolveData , CiByteString path , Utf8GamePath originalGamePath , bool nonDefault ,
24
+ FullPath ? resolved )
22
25
{
23
- chatWarningService . CleanLastFileWarnings ( false ) ;
26
+ messager . CleanTaggedMessages ( false ) ;
24
27
25
28
if ( ! resolved . HasValue )
26
29
return null ;
@@ -31,16 +34,16 @@ public ResourceType Type
31
34
return resolvedPath ;
32
35
33
36
// If the ShPk is already loaded, it means that it already passed the sanity check.
34
- var existingResource = resourceManager . FindResource ( ResourceCategory . Shader , ResourceType . Shpk , unchecked ( ( uint ) resolvedPath . InternalName . Crc32 ) ) ;
37
+ var existingResource =
38
+ resourceManager . FindResource ( ResourceCategory . Shader , ResourceType . Shpk , unchecked ( ( uint ) resolvedPath . InternalName . Crc32 ) ) ;
35
39
if ( existingResource != null )
36
40
return resolvedPath ;
37
41
38
42
var checkResult = SanityCheck ( resolvedPath . FullName ) ;
39
43
if ( checkResult == SanityCheckResult . Success )
40
44
return resolvedPath ;
41
45
42
- Penumbra . Log . Warning ( $ "Refusing to honor file redirection because of failed sanity check (result: { checkResult } ). Original path: { originalGamePath } Redirected path: { resolvedPath } ") ;
43
- chatWarningService . PrintFileWarning ( resolvedPath . FullName , originalGamePath , WarningMessageComplement ( checkResult ) ) ;
46
+ messager . PrintFileWarning ( modManager , resolvedPath . FullName , originalGamePath , WarningMessageComplement ( checkResult ) ) ;
44
47
45
48
return null ;
46
49
}
@@ -49,8 +52,8 @@ private static SanityCheckResult SanityCheck(string path)
49
52
{
50
53
try
51
54
{
52
- using var file = MmioMemoryManager . CreateFromFile ( path ) ;
53
- var bytes = file . GetSpan ( ) ;
55
+ using var file = MmioMemoryManager . CreateFromFile ( path ) ;
56
+ var bytes = file . GetSpan ( ) ;
54
57
55
58
return ShpkFile . FastIsLegacy ( bytes )
56
59
? SanityCheckResult . Legacy
@@ -69,9 +72,9 @@ private static SanityCheckResult SanityCheck(string path)
69
72
private static string WarningMessageComplement ( SanityCheckResult result )
70
73
=> result switch
71
74
{
72
- SanityCheckResult . IoError => "cannot read the modded file." ,
73
- SanityCheckResult . NotFound => "the modded file does not exist." ,
74
- SanityCheckResult . Legacy => "this mod is not compatible with Dawntrail. Get an updated version, if possible, or disable it." ,
75
+ SanityCheckResult . IoError => "Cannot read the modded file." ,
76
+ SanityCheckResult . NotFound => "The modded file does not exist." ,
77
+ SanityCheckResult . Legacy => "This mod is not compatible with Dawntrail. Get an updated version, if possible, or disable it." ,
75
78
_ => string . Empty ,
76
79
} ;
77
80
0 commit comments