public Asset(SNOGroup group, Int32 snoId, string name) { this.FileName = group + "\\" + name + FileExtensions.Extensions[(int)group]; this.Group = group; this.SNOId = snoId; this.Name = name; }
public unsafe CoreTOCParser(Stream stream) { using (var br = new BinaryReader(stream)) { TOCHeader hdr = br.Read <TOCHeader>(); for (int i = 0; i < NUM_SNO_GROUPS; i++) { if (hdr.entryCounts[i] > 0) { br.BaseStream.Position = hdr.entryOffsets[i] + Marshal.SizeOf(hdr); for (int j = 0; j < hdr.entryCounts[i]; j++) { SNOGroup snoGroup = (SNOGroup)br.ReadInt32(); int snoId = br.ReadInt32(); int pName = br.ReadInt32(); long oldPos = br.BaseStream.Position; br.BaseStream.Position = hdr.entryOffsets[i] + Marshal.SizeOf(hdr) + 12 * hdr.entryCounts[i] + pName; string name = br.ReadCString(); br.BaseStream.Position = oldPos; snoDic.Add(snoId, new SNOInfo() { GroupId = snoGroup, Name = name, Ext = extensions[snoGroup] }); } } } } }
public Asset(SNOGroup group, Int32 snoId, byte[] name) { this.Data = null; this.Group = group; this.SNOId = snoId; int count = 0; while (count < 128 && name[count] != 0) count++; this.Name = Encoding.UTF8.GetString(name.Take(count).ToArray()); this.FileName = group + "\\" + this.Name + FileFormats.FileExtensions.Extensions[(int)group]; this.Load(); }
public FileFormatAttribute(SNOGroup group) { this.Group = group; }
/// <summary> /// Parses SNOName from given GameBitBuffer. /// </summary> /// <param name="buffer">The GameBitBuffer to parse from.</param> public void Parse(GameBitBuffer buffer) { Group = (SNOGroup)buffer.ReadInt(32); SNOId = buffer.ReadInt(32); }
public DBAsset(SNOGroup group, Int32 snoId, string name) : base(group, snoId, name) { }
public bool IsOfGroup(int id, SNOGroup grp) { return this.Grouped[grp].ContainsKey(id); }
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; }
// Check whether a group is referencing or defining IDs public static bool IsGroupReferencing(SNOGroup grp) { switch (grp) { case SNOGroup.Ungrouped: case SNOGroup.Actors: return false; } return true; }
public SNOHandle(SNOGroup group, int id) { _group = group; Id = id; }
public Scene(SNOGroup snoGroup, int snoId, string name) : base(snoGroup, snoId, name) { }
/// <summary> /// Reads SNOName from given MPQFileStream. /// </summary> /// <param name="stream">The MPQFileStream to read from.</param> public SNOName(MpqFileStream stream) { this.Group = (SNOGroup)stream.ReadValueS32(); this.SNOId = stream.ReadValueS32(); }
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; }
public void LoadSet(SNOGroup grp, string path) { if (this.Sets.ContainsKey(path)) { Logger.Error("Path {0} was already loaded", path); return; } SNOSet snoset = new SNOSet(grp); try { Logger.Info("Loading SNO ID set from {0}", path); snoset.Load(path); MergeSet(snoset); } catch (DirectoryNotFoundException) { Logger.Warn("Could not find directory of file path {0}", path); } catch (FileNotFoundException) { Logger.Warn("Could not open file {0}", path); } catch (Exception e) { Logger.DebugException(e, "LoadSet"); } }
public int RandomID(SNOGroup grp) { int id = RandomHelper.RandomValue(this.Grouped[grp]).ID; //Logger.Debug("Grabbed random ID for group {0}: {1}", Enum.GetName(typeof(SNOGroup), grp), id); return id; }
private Asset ProcessAsset(SNOGroup group, Int32 snoId, string name) { var asset = Storage.Config.Instance.LazyLoading ? new LazyAsset(group, snoId, name) : 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; }
public SNOSet(SNOGroup grp) { this.Group = grp; }
public LazyAsset(SNOGroup group, Int32 snoId, string name) : base(group, snoId, name) { }