@@ -84,7 +84,7 @@ public class CUE4ParseViewModel : ViewModel
8484{
8585 private ThreadWorkerViewModel _threadWorkerView => ApplicationService . ThreadWorkerView ;
8686 private ApiEndpointViewModel _apiEndpointView => ApplicationService . ApiEndpointView ;
87- private readonly Regex _fnLive = new ( @"^FortniteGame[/\\]Content[/\\]Paks[/\\]" ,
87+ private readonly Regex _fnLiveRegex = new ( @"^FortniteGame[/\\]Content[/\\]Paks[/\\]" ,
8888 RegexOptions . Compiled | RegexOptions . Singleline | RegexOptions . IgnoreCase | RegexOptions . CultureInvariant ) ;
8989
9090 private string _internalGameName ;
@@ -251,44 +251,38 @@ await _threadWorkerView.Begin(cancellationToken =>
251251 cancellationToken : cancellationToken ,
252252 elementManifestPredicate : x => x . Uri . Host is ( "epicgames-download1.akamaized.net" or "download.epicgames.com" )
253253 ) . GetAwaiter ( ) . GetResult ( ) ;
254- var parseTime = Stopwatch . GetElapsedTime ( startTs ) ;
255254
256- Parallel . ForEach ( manifest . Files , fileManifest =>
255+ if ( manifest . TryFindFile ( "Cloud/IoStoreOnDemand.ini" , out var ioStoreOnDemandFile ) )
257256 {
258- if ( fileManifest . FileName . Equals ( "Cloud/IoStoreOnDemand.ini" , StringComparison . OrdinalIgnoreCase ) )
259- {
260- IoStoreOnDemand . Read ( new StreamReader ( fileManifest . GetStream ( ) ) ) ;
261- return ;
262- }
263-
264- if ( ! _fnLive . IsMatch ( fileManifest . FileName ) )
265- {
266- return ;
267- }
268-
269- p . RegisterVfs ( fileManifest . FileName , [ fileManifest . GetStream ( ) ]
270- , it => new FRandomAccessStreamArchive ( it , manifest . Files . First ( x => x . FileName . Equals ( it ) ) . GetStream ( ) , p . Versions ) ) ;
257+ IoStoreOnDemand . Read ( new StreamReader ( ioStoreOnDemandFile . GetStream ( ) ) ) ;
258+ }
259+
260+ Parallel . ForEach ( manifest . Files . Where ( x => _fnLiveRegex . IsMatch ( x . FileName ) ) , fileManifest =>
261+ {
262+ p . RegisterVfs ( fileManifest . FileName , [ fileManifest . GetStream ( ) ] ,
263+ it => new FRandomAccessStreamArchive ( it , manifest . FindFile ( it ) ! . GetStream ( ) , p . Versions ) ) ;
271264 } ) ;
272265
266+ var elapsedTime = Stopwatch . GetElapsedTime ( startTs ) ;
273267 FLogger . Append ( ELog . Information , ( ) =>
274- FLogger . Text ( $ "Fortnite [LIVE] has been loaded successfully in { parseTime . TotalMilliseconds } ms", Constants . WHITE , true ) ) ;
268+ FLogger . Text ( $ "Fortnite [LIVE] has been loaded successfully in { elapsedTime . TotalMilliseconds : F1 } ms", Constants . WHITE , true ) ) ;
275269 break ;
276270 }
277271 case "ValorantLive" :
278272 {
279- var manifestInfo = _apiEndpointView . ValorantApi . GetManifest ( cancellationToken ) ;
280- if ( manifestInfo == null )
273+ var manifest = _apiEndpointView . ValorantApi . GetManifest ( cancellationToken ) ;
274+ if ( manifest == null )
281275 {
282276 throw new Exception ( "Could not load latest Valorant manifest, you may have to switch to your local installation." ) ;
283277 }
284278
285- Parallel . For ( 0 , manifestInfo . Paks . Length , i =>
279+ Parallel . ForEach ( manifest . Paks , pak =>
286280 {
287- p . RegisterVfs ( manifestInfo . Paks [ i ] . GetFullName ( ) , [ manifestInfo . GetPakStream ( i ) ] ) ;
281+ p . RegisterVfs ( pak . GetFullName ( ) , [ pak . GetStream ( manifest ) ] ) ;
288282 } ) ;
289283
290284 FLogger . Append ( ELog . Information , ( ) =>
291- FLogger . Text ( $ "Valorant '{ manifestInfo . Header . GameVersion } ' has been loaded successfully", Constants . WHITE , true ) ) ;
285+ FLogger . Text ( $ "Valorant '{ manifest . Header . GameVersion } ' has been loaded successfully", Constants . WHITE , true ) ) ;
292286 break ;
293287 }
294288 }
0 commit comments