private void LoadCatalog() { this.InitCatalog(); var tocFile = this.FileSystem.FindFile("toc.dat"); if (tocFile == null) { Logger.Warn("Couldn't load CoreData catalog: toc.dat"); return; } var stream = tocFile.Open(); var assetsCount = stream.ReadInt32(); while(stream.Position<stream.Length) { var group = (SNOGroup)stream.ReadInt32(); var snoId = stream.ReadInt32(); var name = new byte[128]; stream.Read(name, 0, 128); var asset = new Asset(group, snoId, name); this.Assets[group].Add(snoId, asset); } stream.Close(); Logger.Info("Loaded a total of {0} assets.", assetsCount); }
public static new void AddHelperValue(Asset asset) { var activeSkillEntries = (asset.Data as SkillKit).ActiveSkillEntries; for (int i = 0; i < activeSkillEntries.Count; i++) { PowerToRuneIndex.AddOrUpdate(activeSkillEntries[i].SNOPower, i, (key, oldValue) => i); } }
public static new List<Task> GetTasks(Data data) { List<Task> tasks = new List<Task>(); foreach (var key in data.Assets[SNOGroup.SkillKit].Keys) { Asset asset = new Asset(SNOGroup.SkillKit, -1, ""); if (data.Assets[SNOGroup.SkillKit].TryGetValue(key, out asset)) { tasks.Add(new Task(() => AddHelperValue(asset))); } } return tasks; }
/// <summary> /// Adds the asset to the dictionary and tries to parse it if a parser /// is found and lazy loading is deactivated /// </summary> /// <param name="asset">New asset to be processed</param> private void ProcessAsset(Asset asset) { this.Assets[asset.Group].TryAdd(asset.SNOId, asset); if (!this.Parsers.ContainsKey(asset.Group)) return; asset.Parser = this.Parsers[asset.Group]; // If lazy loading is deactivated, immediatly run parsers sequentially or threaded if (Storage.Config.Instance.LazyLoading == false) { if (Storage.Config.Instance.EnableTasks) this._tasks.Add(new Task(() => asset.RunParser())); else { try { asset.RunParser(); } catch (Exception e) { Logger.Error("Error parsing {0}.\nMessage: {1}\n InnerException:{2}\nStack Trace:{3}", asset.FileName, e.Message, e.InnerException.Message, e.StackTrace); } } } }
private Asset ProcessAsset(SNOGroup group, Int32 snoId, string name) { var asset = new Asset(group, snoId, name); // create the asset. if (!this.Parsers.ContainsKey(asset.Group)) return asset; // if we don't have a proper parser for asset, just give up. var parser = this.Parsers[asset.Group]; // get the type the asset's parser. var file = this.FileSystem.FindFile(asset.FileName); // get the asset file. // if file is in any of the follow groups, try to load the original version - the reason is that assets in those groups got patched to 0 bytes. if (PatchExceptions.Contains(asset.Group)) { foreach (CrystalMpq.MpqArchive archive in this.FileSystem.Archives.Reverse()) //search mpqs starting from base { file = archive.FindFile(asset.FileName); if (file != null) break; } } if (file == null || file.Size < 10) return asset; // if it's empty, give up again. this._tasks.Add(new Task(() => asset.RunParser(parser, file))); // add it to our task list, so we can parse them concurrently. return asset; }
public AssetNode(Asset asset) { this.Asset = asset; this.Text = Path.GetFileName(asset.FileName); }
/// <summary> /// Adds the asset to the dictionary and tries to parse it if a parser /// is found and lazy loading is deactivated /// </summary> /// <param name="asset">New asset to be processed</param> private void ProcessAsset(Asset asset) { this.Assets[asset.Group].TryAdd(asset.SNOId, asset); if (!this.Parsers.ContainsKey(asset.Group)) return; asset.Parser = this.Parsers[asset.Group]; // If lazy loading is deactivated, immediatly run parsers sequentially or threaded if (Storage.Config.Instance.LazyLoading == false) { if (Storage.Config.Instance.EnableTasks) this._tasks.Add(new Task(() => asset.RunParser())); else asset.RunParser(); } }
private Asset ProcessAsset(SNOGroup group, Int32 snoId, string name) { var asset = new Asset(group, snoId, name); // create the asset. if (!this.Parsers.ContainsKey(asset.Group)) return asset; // if we don't have a proper parser for asset, just give up. var parser = this.Parsers[asset.Group]; // get the type the asset's parser. var file = this.FileSystem.FindFile(asset.FileName); // get the asset file. if (file == null || file.Size < 10) return asset; // if it's empty, give up again. this._tasks.Add(new Task(() => asset.RunParser(parser, file))); // add it to our task list, so we can parse them concurrently. return asset; }
private Asset ProcessAsset(SNOGroup group, Int32 snoId, string name) { var asset = new Asset(group, snoId, name); // create the asset. if (!this.Parsers.ContainsKey(asset.Group)) return asset; // if we don't have a proper parser for asset, just give up. var parser = this.Parsers[asset.Group]; // get the type the asset's parser. var file = 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 (file == null || file.Size < 10) return asset; // if it's empty, give up again. if (Storage.Config.Instance.EnableTasks) this._tasks.Add(new Task(() => asset.RunParser(parser, file))); // add it to our task list, so we can parse them concurrently. else asset.RunParser(parser, file); // run the parsers sequentally. return asset; }