11using Hi3Helper . Sophon ;
22using Hi3Helper . Sophon . Infos ;
3+ using Hi3Helper . Sophon . Structs ;
34using System ;
45using System . Buffers ;
56using System . Collections . Generic ;
@@ -29,47 +30,16 @@ public override async Task FilterAssetList<T>(
2930 Func < T , string ? > itemPathSelector ,
3031 CancellationToken token )
3132 {
32- HashSet < int > exceptMatchFieldHashSet = await GetExceptMatchFieldHashSet ( token ) ;
33+ HashSet < string > exceptMatchFieldHashSet = await GetExceptMatchFieldHashSet ( token ) ;
3334 if ( exceptMatchFieldHashSet . Count == 0 )
3435 {
3536 return ;
3637 }
3738
38- FilterSophonAsset ( itemList , Selector , exceptMatchFieldHashSet ) ;
39- return ;
40-
41- string ? Selector ( T item )
42- {
43- // For Game Update
44- if ( item is SophonPatchAsset asset )
45- {
46- if ( asset . MainAssetInfo is not { } assetSelected )
47- {
48- return null ;
49- }
50-
51- token . ThrowIfCancellationRequested ( ) ;
52- ref SophonChunksInfo chunkInfo = ref Unsafe . IsNullRef ( ref assetSelected )
53- ? ref Unsafe . NullRef < SophonChunksInfo > ( )
54- : ref GetChunkAssetChunksInfo ( assetSelected ) ;
55-
56- if ( Unsafe . IsNullRef ( ref chunkInfo ) )
57- {
58- chunkInfo = ref GetChunkAssetChunksInfoAlt ( assetSelected ) ;
59- }
60-
61- return Unsafe . IsNullRef ( ref chunkInfo )
62- ? asset . MainAssetInfo . AssetName
63- : chunkInfo . ChunksBaseUrl ;
64- }
65-
66- // TODO: For Game Repair handle
67-
68- return null ;
69- }
39+ FilterSophonAsset ( itemList , exceptMatchFieldHashSet ) ;
7040 }
7141
72- private async Task < HashSet < int > > GetExceptMatchFieldHashSet ( CancellationToken token )
42+ private async Task < HashSet < string > > GetExceptMatchFieldHashSet ( CancellationToken token )
7343 {
7444 string gameExecDataName =
7545 Path . GetFileNameWithoutExtension ( GameVersionManager . GamePreset . GameExecutableName ) ?? "ZenlessZoneZero" ;
@@ -82,38 +52,20 @@ private async Task<HashSet<int>> GetExceptMatchFieldHashSet(CancellationToken to
8252 return [ ] ;
8353 }
8454
85- string exceptMatchFieldContent = await File . ReadAllTextAsync ( gameExceptMatchFieldFile , token ) ;
86- HashSet < int > exceptMatchFieldHashSet = CreateExceptMatchFieldHashSet < int > ( exceptMatchFieldContent ) ;
55+ string exceptMatchFieldContent = await File . ReadAllTextAsync ( gameExceptMatchFieldFile , token ) ;
56+ HashSet < string > exceptMatchFieldHashSet = CreateExceptMatchFieldHashSet ( exceptMatchFieldContent ) ;
8757
8858 return exceptMatchFieldHashSet ;
8959 }
9060
9161 // ReSharper disable once IdentifierTypo
92- private static void FilterSophonAsset < T > ( List < T > itemList , Func < T , string ? > assetSelector , HashSet < int > exceptMatchFieldHashSet )
62+ private static void FilterSophonAsset < T > ( List < T > itemList , HashSet < string > exceptMatchFieldHashSet )
9363 {
94- const string separators = "/\\ " ;
95- scoped Span < Range > urlPathRanges = stackalloc Range [ 32 ] ;
96-
9764 List < T > filteredList = [ ] ;
9865 foreach ( T asset in itemList )
9966 {
100- string ? assetPath = assetSelector ( asset ) ;
101- if ( assetPath == null )
102- {
103- filteredList . Add ( asset ) ;
104- continue ;
105- }
106-
107- ReadOnlySpan < char > manifestUrl = assetPath ;
108- int rangeLen = manifestUrl . SplitAny ( urlPathRanges , separators , SplitOptions ) ;
109- if ( rangeLen <= 0 )
110- {
111- continue ;
112- }
113-
114- ReadOnlySpan < char > manifestStr = manifestUrl [ urlPathRanges [ rangeLen - 1 ] ] ;
115- if ( int . TryParse ( manifestStr , null , out int lookupNumber ) &&
116- exceptMatchFieldHashSet . Contains ( lookupNumber ) )
67+ if ( asset is SophonIdentifiableProperty { MatchingField : { } assetMatchingField } &&
68+ exceptMatchFieldHashSet . Contains ( assetMatchingField ) )
11769 {
11870 continue ;
11971 }
@@ -130,11 +82,10 @@ private static void FilterSophonAsset<T>(List<T> itemList, Func<T, string?> asse
13082 itemList . AddRange ( filteredList ) ;
13183 }
13284
133- internal static HashSet < T > CreateExceptMatchFieldHashSet < T > ( string exceptMatchFieldContent )
134- where T : ISpanParsable < T >
85+ internal static HashSet < string > CreateExceptMatchFieldHashSet ( string exceptMatchFieldContent )
13586 {
13687 const string lineFeedSeparators = "\r \n " ;
137- HashSet < T > hashSetReturn = [ ] ;
88+ HashSet < string > hashSetReturn = new ( StringComparer . OrdinalIgnoreCase ) ;
13889 scoped Span < Range > contentLineRange = stackalloc Range [ 2 ] ;
13990
14091 ReadOnlySpan < char > contentSpan = exceptMatchFieldContent . AsSpan ( ) ;
@@ -157,10 +108,7 @@ internal static HashSet<T> CreateExceptMatchFieldHashSet<T>(string exceptMatchFi
157108 }
158109
159110 ReadOnlySpan < char > contentMatch = contentSpan [ contentMatchRange ] . Trim ( separatorsChars ) ;
160- if ( T . TryParse ( contentMatch , null , out T ? result ) )
161- {
162- hashSetReturn . Add ( result ) ;
163- }
111+ hashSetReturn . Add ( contentMatch . ToString ( ) ) ;
164112 }
165113
166114 return hashSetReturn ;
0 commit comments