public static void InteropReadNodes(Blam.CacheFile cf, int cache_offset, TagInterface.IBlock hs_nodes) { cf.InputStream.Seek(cache_offset, System.IO.SeekOrigin.Begin); hs_nodes.ReadHeader(cf); hs_nodes.Read(cf); }
public static void InteropReadTagData(Blam.CacheFile cf, TagInterface.IBlock hs_scripts, int cache_offset_scripts, TagInterface.IBlock hs_globals, int cache_offset_globals) { cf.InputStream.Position = cache_offset_scripts; hs_scripts.ReadHeader(cf); hs_scripts.Read(cf); cf.InputStream.Position = cache_offset_globals; hs_globals.ReadHeader(cf); hs_globals.Read(cf); }
/// <summary> /// 构造函数 /// </summary> /// <param name="client">操作器</param> public EntityInterfaces(Client client) { Account = new AccountInterface(client); Comments = new CommentInterface(client); Common = new CommonInterface(client); Favorites = new FavoriteInterface(client); Friendships = new FriendshipInterface(client); Search = new SearchInterface(client); ShortUrl = new ShortUrlInterface(client); Statuses = new StatusInterface(client); Suggestions = new SuggestionInterface(client); Tags = new TagInterface(client); Trends = new TrendInterface(client); Users = new UserInterface(client); }
static void ExtractImportInfo(string test_results_path, Managers.TagIndex ti, TagInterface.TagGroup group, params string[] files) { int ti_dir_length = ti.Directory.Length; int group_length = group.Name.Length; foreach (string f in files) { var t = f.Substring(ti_dir_length); // remove tags dir t = t.Remove(t.Length - group_length - 1); // remove extension var tag_index = ti.Open(t, group); if (Managers.TagIndex.IsSentinel(tag_index)) continue; Assert.IsTrue(tag_index != Blam.DatumIndex.Null); var tagman = ti[tag_index]; var import_def = tagman.TagDefinition as Blam.Halo2.Tags.ITagImportInfo; ExtractImportInfo(import_def.GetImportInfo(), test_results_path); ti.Unload(tag_index); } }
void ExtractWriteTagDatabase(Blam.CacheExtractionInfo cei, TagManager root_tag, TagInterface.TagGroup database_group, TagInterface.Definition db_definition, bool is_error_db) { if ((db_definition as ITagDatabase).IsEmpty) return; // name the database after the root tag we're extracting string tag_name = root_tag.Name; if (is_error_db) tag_name = string.Format("{0}.errors", tag_name); Blam.CacheIndex.Item tdb_item; // Just in-case someone tries to extract the same root tag twice if (!cacheFile.TryAndFind(tag_name, database_group, out tdb_item)) { tdb_item = cacheFile.AddFeignTagInstance(tag_name, database_group); if (tdb_item == null) { extractionTrace.WriteLine("Couldn't create a tag_database for {0}! Couldn't create tag entry for database", root_tag.Name); return; } } try { var tdb_index = this.Open(tdb_item.Datum); var tdb = this[tdb_index]; tdb.Manage(db_definition); // Even though the tag isn't actually in the cache, the tag // manager needs to operate this way with CacheTagIndex elements tdb.OpenForExtract(cei.Arguments.OutputDirectory, null); tdb.Extract(); tdb.Close(); Unload(tdb_index); } catch(Exception ex) { extractionTrace.WriteLine("Error while trying to write tag_database!"); extractionTrace.WriteLine(ex); } }
void DumpNonTagFilesRecursive(StreamWriter s, System.IO.DirectoryInfo diri, TagInterface.TagGroupCollection coll) { System.IO.FileInfo[] files = diri.GetFiles(); System.IO.DirectoryInfo[] directories = diri.GetDirectories(); if (files.Length == 0 && directories.Length == 0) { s.WriteLine(";empty directory {0}", diri.FullName.Replace(directory, "")); s.WriteLine(); } else { bool is_first = true; foreach (System.IO.FileInfo fi in files) { string ext; if (fi.Extension != "") ext = fi.Extension.Remove(0, 1).ToLowerInvariant(); // remove the '.' else continue; if (coll.FindGroupIndex(ext) == -1) { if (is_first) { s.WriteLine(";{0}", diri.FullName.Replace(directory, "")); is_first = false; } s.WriteLine(fi.FullName.Replace(directory, "")); } } // if we wrote some entries, add a new line if (!is_first) s.WriteLine(); foreach (System.IO.DirectoryInfo di in directories) DumpNonTagFilesRecursive(s, di, coll); } }
/// <summary> /// Open an existing tag /// </summary> /// <param name="name">name of the tag</param> /// <param name="tag_group">group tag of the tag</param> /// <param name="flags">special flags to use when opening</param> /// <returns> /// The tag_index handle associated with the <see cref="TagManager"/> used to load the tag, or <see cref="Blam.DatumIndex.Null"/> if this operations fails /// </returns> /// <remarks> /// Will return existing handles if tag is already open. /// If <paramref name="tag_group"/> is setup to be ignored, we return <see cref="kSkipped"/>. /// </remarks> public Blam.DatumIndex Open(string name, TagInterface.TagGroup tag_group, uint flags) { // HACK: Halo1 PC uses gbx's variant of the model tag if (Engine == BlamVersion.Halo1_CE && tag_group == Blam.Halo1.TagGroups.mode) { tag_group = Blam.Halo1.TagGroups.mod2; } if (Ignore(tag_group)) return kSkipped; // Does this tag even exist on disk? string path = string.Format("{0}.{1}", Path.Combine(directory, name), tag_group.Name); if (!Exists(path)) return kMissing; // Is this tag already loaded? if so, reuse handle Blam.DatumIndex di = IsLoaded(name, tag_group); if (di != Blam.DatumIndex.Null) { Array.IncrementReference(di); return di; } // If the tag had errors, don't try loading it again. // Note that valid tags can exist in the error database since they act as root tags for problem // tags, but since we call [IsLoaded] above this it will catch any valid cases if (ErrorDatabaseContains(name, tag_group)) return Blam.DatumIndex.Null; #region Initialize tag manager TagManager tm = new TagManager(this); tm.ReferenceName = refManager.Add(tm, tag_group, name); tm.Flags.Add(flags); tm.Manage(tag_group); tm.TagIndex = di = Array.Add(tm); // in order to read the tag, the tag index must be setup first (due how TagManager.Path is setup) #endregion #region Stream tag manager tm.OpenForRead(); try { tm.Read(); } catch (TagInterface.Exceptions.InvalidVersion /*ex_version*/) { //indexTrace.WriteLine("Tag Index: Failed to open tag from disk (invalid\\unhandled version): {0}{1}{2}", path, Program.NewLine, ex_version); di = kVersionInvalid; } catch (Exception ex) { indexTrace.WriteLine("Tag Index: Failed to open tag from disk: {0}{1}{2}", path, Program.NewLine, ex); di = Blam.DatumIndex.Null; } finally { tm.Close(); } if(di != tm.TagIndex) { Array.Remove(tm.TagIndex); ErrorDatabaseAddLocalHack(name, tag_group); return di; } #endregion ErrorDatabaseUpdate(tm); base.OnEventOpen(new TagIndexEventArgs(this, tm)); return tm.TagIndex; }
/// <summary> /// Add an existing tag group definition to the index /// </summary> /// <param name="name">name of the tag (relative to the directory this tag index uses)</param> /// <param name="definition">Instance of a tag group definition</param> /// <returns>The tag_index handle associated with the <see cref="TagManager"/> now managing the definition</returns> /// <remarks> /// <paramref name="definition"/> must have a <see cref="TagInterface.TagGroupAttribute"/> applied to it. /// If <paramref name="tag_group"/> is setup to be ignored, we return <see cref="kSkipped"/>. /// If the name\tag_group tag already exists (in memory only), we return <see cref="Blam.DatumIndex.Null"/>. /// </remarks> public Blam.DatumIndex Add(string name, TagInterface.Definition definition) { TagInterface.TagGroupAttribute tga = definition.State.Attribute as TagInterface.TagGroupAttribute; TagInterface.TagGroup tag_group = definition.State.Engine.VersionToTagCollection()[tga.GroupIndex]; if (Ignore(tag_group)) return kSkipped; // Checks to see or if there is one in memory if (IsLoaded(name, tag_group) != Blam.DatumIndex.Null) { indexTrace.WriteLine("Tag Index: Couldn't add an existing tag! '{0}.{1}' already exists", name, tag_group.Name); return Blam.DatumIndex.Null; } #region Initialize tag manager TagManager tm = new TagManager(this); tm.ReferenceName = refManager.Add(tm, tag_group, name); tm.Manage(definition); tm.TagIndex = Array.Add(tm); #endregion base.OnEventOpen(new TagIndexEventArgs(this, tm)); return tm.TagIndex; }
public void TagInstanceBegin(Blam.DatumIndex handle, string name, TagInterface.TagGroup group) { tagsWriter.WriteStartElement("tag"); tagsWriter.WriteAttributeString("group", group.Name); tagsWriter.WriteAttributeString("name", name); }
public void SharedReferencesAddRightIndex(string name, TagInterface.TagGroup group) { TagInstanceBegin(Blam.DatumIndex.Null, name, group); TagInstanceEnd(); }
internal override bool ExtractionTagReferenceChange(TagInterface.TagReference tr) { bool changed = false; if(tr.Datum != DatumIndex.Null) { // if (tr.GroupTag == TagGroups.shad) // { // tr.Datum = invalid_handle_shader; // changed = true; // } } return changed; }
/// <summary> /// Opens the first instance of a specific tag group /// </summary> /// <param name="tag_group">Tag group to search for</param> /// <returns>Returns <see cref="Blam.DatumIndex.Null"/> if no <paramref name="tag_group"/> instances were found</returns> public Blam.DatumIndex OpenFirstInstance(TagInterface.TagGroup tag_group) { foreach (Blam.CacheIndex.Item i in cacheFile.Index.Tags) if (i.GroupTag == tag_group) return Open(i.Datum); return Blam.DatumIndex.Null; }
/// <summary> /// Open an existing a tag /// </summary> /// <param name="name">name of the tag</param> /// <param name="tag_group">group tag of the tag</param> /// <returns>The tag_index handle associated with the <see cref="TagManager"/> used to load the tag</returns> public override Blam.DatumIndex Open(string name, TagInterface.TagGroup tag_group) { Blam.DatumIndex index = FindDatum(name, tag_group); if (index == Blam.DatumIndex.Null) indexTrace.WriteLine("Cache Index: Failed to find the following tag in the cache {0}.{1}{2}.{3}", cacheFile.Header.Name, Program.NewLine, name, tag_group.Name); return Open(index); }
/// <summary> /// Find a cache tag datum based on its name and group tag /// </summary> /// <param name="name">name of the tag</param> /// <param name="tag_group">group tag of tag</param> /// <returns>The tag_datum associated with the name\tag_group, or <see cref="Blam.DatumIndex.Null"/> if no match is found</returns> Blam.DatumIndex FindDatum(string name, TagInterface.TagGroup tag_group) { foreach(Blam.CacheIndex.Item i in cacheFile.Index.Tags) { if (cacheFile.GetReferenceName(i) == name && i.GroupTag.ID == tag_group.ID) return i.Datum; } return Blam.DatumIndex.Null; }
public static ScriptNode[] FromBlock(TagInterface.IBlock block) { TagInterface.IElementArray ea = block.GetElements(); ScriptNode[] value = new ScriptNode[ea.Count]; for (int x = 0; x < value.Length; x++) { var hs = (hs_syntax_datum_block)ea.GetElement(x); var v = value[x] = new ScriptNode(); v.nodeIndex = x; v.index = (short)hs.DatumHeader.Value; v.opcode = (short)hs.TypeUnion.Value; v.type = (short)hs.Type.Value; v.pointerType = (short)hs.Flags.Value; v.nextExpression = hs.NextNodeIndex.Value; v.pointer = hs.Pointer.Value; int temp = hs.Data.Value; v.data[0] = (byte)(temp & 0x000000FF); v.data[1] = (byte)(temp & 0x0000FF00); v.data[2] = (byte)(temp & 0x00FF0000); v.data[3] = (byte)(temp & 0xFF000000); } return value; }
public TagController(TagInterface context) { _db = context; }
public void SharedReferencesAddRightIndex(string name, TagInterface.TagGroup group) { writer.WriteLine(";\t{0}{1}", group.NameToLeftPaddedString(), name); }
/// <summary> /// Open an existing tag /// </summary> /// <param name="name">name of the tag</param> /// <param name="tag_group">group tag of the tag</param> /// <returns> /// The tag_index handle associated with the <see cref="TagManager"/> used to load the tag, or <see cref="Blam.DatumIndex.Null"/> if this operations fails /// </returns> /// <remarks>Will return existing handles if tag is already open.</remarks> public override Blam.DatumIndex Open(string name, TagInterface.TagGroup tag_group) { return Open(name, tag_group, 0); }
public void TagInstanceBegin(Blam.DatumIndex handle, string name, TagInterface.TagGroup group) { switch (type) { case DumpType.Dependencies: WriteIndention(); break; case DumpType.SharedReferences: break; case DumpType.Memory: currentInstanceHandle = handle; currentInstanceName = name; currentInstanceGroup = group.NameToLeftPaddedString(); break; } currentInstanceIndex++; currentIndent++; }
/// <summary> /// Figures out if the tag exists in this tag index's namespace /// </summary> /// <param name="name">name of tag</param> /// <param name="tag_group">group tag of tag</param> /// <returns></returns> public bool Exists(string name, TagInterface.TagGroup tag_group) { return Exists(string.Format("{0}.{1}", Path.Combine(directory, name), tag_group.Name)); }
public void TagInstanceDependentAdd(string name, TagInterface.TagGroup group) { TagInstanceBegin(Blam.DatumIndex.Null, name, group); TagInstanceEnd(); }
void DumpNonTagFilesRecursive(TagIndexDumpUtil util, System.IO.DirectoryInfo diri, TagInterface.TagGroupCollection coll) { System.IO.FileInfo[] files = diri.GetFiles(); System.IO.DirectoryInfo[] directories = diri.GetDirectories(); if (files.Length == 0 && directories.Length == 0) { util.NonTagsDirectoryBegin(diri.FullName.Replace(directory, ""), true); util.NonTagsDirectoryEnd(); } else { bool is_first = true; foreach (System.IO.FileInfo fi in files) { string ext; if (fi.Extension != "") ext = fi.Extension.Remove(0, 1).ToLowerInvariant(); // remove the '.' else continue; if (coll.FindGroupIndex(ext) == -1) { if (is_first) { util.NonTagsDirectoryBegin(diri.FullName.Replace(directory, ""), false); is_first = false; } util.NonTagsEntryAdd(fi.FullName.Replace(directory, "")); } } // if we wrote some entries, close the directory dump... if (!is_first) util.NonTagsDirectoryEnd(); foreach (System.IO.DirectoryInfo di in directories) DumpNonTagFilesRecursive(util, di, coll); } }
public void SharedReferencesAddRightIndex(string name, TagInterface.TagGroup group) { provider.SharedReferencesAddRightIndex(name, group); }
public TagDatabase(string tag_name, TagInterface.TagGroup group_tag) : base(BlamVersion.Halo1, tag_name, group_tag) { }
void ErrorDatabaseAddLocalHack(string path, TagInterface.TagGroup tag_group) { int hash = path.GetHashCode() ^ unchecked((int)tag_group.ID); errorDatabaseBadTagHashes.Add(hash); }
public void TagInstanceBegin(Blam.DatumIndex handle, string name, TagInterface.TagGroup group) { provider.TagInstanceBegin(handle, name, group); }
public void TagInstanceDependentAdd(string name, TagInterface.TagGroup group) { provider.TagInstanceDependentAdd(name, group); }
/// <summary>For changing tag references to different references</summary> /// <param name="tr"></param> /// <returns>true if <paramref name="tr"/> was changed</returns> /// <remarks> /// This is needed for implementing re-mappings, particularly for Halo 2 where /// we haven't coded post-process definition decoding so we'd want to set the /// reference to "rasterizer\invalid". /// /// I've thought about having to update cacheFile's "References" state...but /// I'm undecided on this action... /// </remarks> internal virtual bool ExtractionTagReferenceChange(TagInterface.TagReference tr) { return false; }
bool ErrorDatabaseContains(string path, TagInterface.TagGroup tag_group) { //return errorDatabase == null ? false : errorDatabase.Contains(path, tag_group.ID); if (errorDatabaseBadTagHashes.Count == 0) return false; int hash = path.GetHashCode() ^ unchecked((int)tag_group.ID); return errorDatabaseBadTagHashes.Contains(hash); }
public static ScriptNode[] FromData(TagInterface.Data data) { int position = 56; int node_count = BitConverter.ToInt16(data.Value, 46); ScriptNode[] value = new ScriptNode[node_count]; // element count System.Diagnostics.Debug.WriteLine("node count: " + node_count); for (int x = 0; x < node_count; x++, position += 0x14) { var v = value[x] = new ScriptNode(); v.nodeIndex = x; v.index = BitConverter.ToInt16(data.Value, position + OffsetIndex); //position += 2; v.opcode = BitConverter.ToInt16(data.Value, position + OffsetOpcode); //position += 2; v.type = BitConverter.ToInt16(data.Value, position + OffsetType); //position += 2; v.pointerType = BitConverter.ToInt16(data.Value, position + OffsetPointerType); //position += 2; // TODO: change this to ToInt32 to make it big endian compatible v.nextExpression.Index = BitConverter.ToUInt16(data.Value, position + OffsetNextExp); //position += 2; v.nextExpression.Salt = BitConverter.ToInt16(data.Value, position + OffsetNextExp + 2); //position += 2; v.pointer = BitConverter.ToInt32(data.Value, position + OffsetPointer); //position += 4; v.data[0] = data.Value[position + OffsetData]; //position += 1; v.data[1] = data.Value[position + OffsetData + 1]; //position += 1; v.data[2] = data.Value[position + OffsetData + 2]; //position += 1; v.data[3] = data.Value[position + OffsetData + 3]; //position += 1; } return value; }
/// <summary> /// Create a new tag /// </summary> /// <param name="name">name of the tag (relative to the directory this tag index uses)</param> /// <param name="tag_group">tag group for the tag</param> /// <returns>The tag_index handle associated with the <see cref="TagManager"/> used to create the tag</returns> /// <remarks> /// If <paramref name="tag_group"/> is setup to be ignored, we return <see cref="kSkipped"/>. /// If the name\tag_group tag already exists (either in memory or on disk), we return <see cref="Blam.DatumIndex.Null"/>. /// </remarks> public Blam.DatumIndex New(string name, TagInterface.TagGroup tag_group) { if (Ignore(tag_group)) return kSkipped; // Checks to see if the tag exists on disk string path = string.Format("{0}.{1}", Path.Combine(directory, name), tag_group.Name); if (Exists(path)) { indexTrace.WriteLine("Tag Index: Couldn't create a new tag! '{0}' already exists on disk", path); return Blam.DatumIndex.Null; } // ...or if there is one in memory if (IsLoaded(name, tag_group) != Blam.DatumIndex.Null) { indexTrace.WriteLine("Tag Index: Couldn't create a new tag! '{0}.{1}' already exists", name, tag_group.Name); return Blam.DatumIndex.Null; } TagManager tm = new TagManager(this); tm.ReferenceName = refManager.Add(tm, tag_group, name); tm.Manage(tag_group); // setup the tag group tm.TagIndex = Array.Add(tm); base.OnEventOpen(new TagIndexEventArgs(this, tm)); return tm.TagIndex; }
public static ScriptStringEntry[] FromData(TagInterface.Data data, byte garbage_id) { int offset = 0; System.Text.StringBuilder stringEntry; ScriptStringEntry[] ste; List<ScriptStringEntry> value = new List<ScriptStringEntry>(); for (int x = 0; x < data.Size; x++) { stringEntry = new StringBuilder(); byte btchar = 0; #region (try to) get the string entry... try { do { if (offset < data.Size) { btchar = data[offset]; if (btchar != 0) stringEntry.Append((char)btchar); } offset++; } while ((btchar != 0 || btchar != garbage_id) && offset < data.Size); } catch (IndexOutOfRangeException ex) { throw new Debug.ExceptionLog(ex, "Offset was outside the bounds of the data array."); } #endregion // ...and add it value.Add(new ScriptStringEntry(stringEntry.ToString(), offset - (stringEntry.Length + 1))); // we're in the padding area now if (btchar == garbage_id) break; } bool found_empty = false; for (int x = 0; x < value.Count; x++) { if (!found_empty) // do this shit until we find the first empty string... { found_empty = value[x].Data == ""; continue; } // then do this for every empty string we may find if (value[x].Data == "" && found_empty) value.RemoveAt(x--); } // find the shit we only care for and return it ste = new ScriptStringEntry[value.Count]; for (int x = 0; x < value.Count; x++) ste[x] = value[x]; return ste; }
public GraphStoryService(ContentInterface contentInterface, LocationInterface locationInterface, ProductInterface productInterface, PurchaseInterface purchaseInterface, TagInterface tagInterface, UserInterface userInterface) { this.contentInterface = contentInterface; this.locationInterface = locationInterface; this.productInterface = productInterface; this.purchaseInterface = purchaseInterface; this.tagInterface = tagInterface; this.userInterface = userInterface; }