private void LoadCatalog(string fileName, bool useBaseMPQ = false, List <SNOGroup> groupsToLoad = null) { var catalogFile = this.GetFile(fileName, useBaseMPQ); this._tasks.Clear(); if (catalogFile == null) { Logger.Error("Couldn't load catalog file: {0}.", fileName); return; } var stream = catalogFile.Open(); var assetsCount = stream.ReadValueS32(); var timerStart = DateTime.Now; // read all assets from the catalog first and process them (ie. find the parser if any available). while (stream.Position < stream.Length) { var group = (SNOGroup)stream.ReadValueS32(); var snoId = stream.ReadValueS32(); var name = stream.ReadString(128, true); if (groupsToLoad != null && !groupsToLoad.Contains(group)) // if we're handled groups to load, just ignore the ones not in the list. { continue; } var asset = new MPQAsset(group, snoId, name); asset.MpqFile = this.GetFile(asset.FileName, PatchExceptions.Contains(asset.Group)); // get the file. note: if file is in any of the groups in PatchExceptions it'll from load the original version - the reason is that assets in those groups got patched to 0 bytes. /raist. if (asset.MpqFile != null) { this.ProcessAsset(asset); // process the asset. } } stream.Close(); // Run the parsers for assets (that have a parser). if (this._tasks.Count > 0) // if we're running in tasked mode, run the parser tasks. { foreach (var task in this._tasks) { task.Start(); } Task.WaitAll(this._tasks.ToArray()); // Wait all tasks to finish. } GC.Collect(); // force a garbage collection. GC.WaitForPendingFinalizers(); var elapsedTime = DateTime.Now - timerStart; if (Storage.Config.Instance.LazyLoading) { Logger.Trace("Found a total of {0} assets from {1} catalog and postponed loading because lazy loading is activated.", assetsCount, fileName); } else { Logger.Trace("Found a total of {0} assets from {1} catalog and parsed {2} of them in {3:c}.", assetsCount, fileName, this._tasks.Count, elapsedTime); } }
private void LoadCatalog(string fileName, bool useBaseMPQ = false, List<SNOGroup> groupsToLoad = null) { var catalogFile = this.GetFile(fileName, useBaseMPQ); this._tasks.Clear(); if (catalogFile == null) { Logger.Error("Couldn't load catalog file: {0}.", fileName); return; } var stream = catalogFile.Open(); var assetsCount = stream.ReadValueS32(); var timerStart = DateTime.Now; // read all assets from the catalog first and process them (ie. find the parser if any available). while (stream.Position < stream.Length) { var group = (SNOGroup)stream.ReadValueS32(); var snoId = stream.ReadValueS32(); var name = stream.ReadString(128, true); if (groupsToLoad != null && !groupsToLoad.Contains(group)) // if we're handled groups to load, just ignore the ones not in the list. continue; var asset = new MPQAsset(group, snoId, name); asset.MpqFile = this.GetFile(asset.FileName, PatchExceptions.Contains(asset.Group)); // get the file. note: if file is in any of the groups in PatchExceptions it'll from load the original version - the reason is that assets in those groups got patched to 0 bytes. /raist. this.ProcessAsset(asset); // process the asset. } stream.Close(); // Run the parsers for assets (that have a parser). if (this._tasks.Count > 0) // if we're running in tasked mode, run the parser tasks. { foreach (var task in this._tasks) { task.Start(); } Task.WaitAll(this._tasks.ToArray()); // Wait all tasks to finish. } GC.Collect(); // force a garbage collection. GC.WaitForPendingFinalizers(); var elapsedTime = DateTime.Now - timerStart; if(Storage.Config.Instance.LazyLoading) Logger.Info("Found a total of {0} assets from {1} catalog and postponed loading because lazy loading is activated.", assetsCount, fileName); else Logger.Info("Found a total of {0} assets from {1} catalog and parsed {2} of them in {3:c}.", assetsCount, fileName, this._tasks.Count, elapsedTime); }