protected void ReadGroupTags(Managers.BlamDefinition gd, IO.EndianReader s)
        {
            uint gt = s.ReadUInt32();

            if (gt != uint.MaxValue)
            {
                GroupTag1 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(gt));
            }
            else
            {
                GroupTag1 = TagInterface.TagGroup.Null;
            }

            gt = s.ReadUInt32();
            if (gt != uint.MaxValue)
            {
                GroupTag2 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(gt));
            }
            else
            {
                GroupTag2 = TagInterface.TagGroup.Null;
            }

            gt = s.ReadUInt32();
            if (gt != uint.MaxValue)
            {
                GroupTag3 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(gt));
            }
            else
            {
                GroupTag3 = TagInterface.TagGroup.Null;
            }
        }
        /// <summary>
        /// Checks to see if <paramref name="file"/> tag is loaded already
        /// </summary>
        /// <param name="file">tag file name (relative to tags directory)</param>
        /// <param name="filter">group tag to use as a filter</param>
        /// <returns>BuilderItem representing <paramref name="file"/></returns>
        public BuilderItem TagIsLoaded(string file, TagInterface.TagGroup filter)
        {
            //foreach (BuilderItem t in tags)
            //	if (t.FileName == file && filter.Test(t.GroupTag))
            //		return t;

            return(null);
        }
Example #3
0
        /// <summary>
        /// Check to verify if the tag group is ignored
        /// </summary>
        /// <param name="tg">tag group t check</param>
        /// <returns>true if we ignore it</returns>
        protected bool Ignore(TagInterface.TagGroup tg)
        {
            if (ignoreList == null)
            {
                return(false);
            }

            return(ignoreList.Contains(tg));
        }
            internal CacheFileHeader(CacheFileHeader old_state)
            {
                if (old_state == null)
                {
                    throw new ArgumentNullException("old_state");
                }

                this.engineSignature = old_state.engineSignature;
            }
            internal CacheFileHeader(BlamVersion engine)
            {
                switch (engine.ToBuild())
                {
                case BlamBuild.Halo1: engineSignature = kHalo1Signature; break;

                case BlamBuild.Halo2: engineSignature = kHalo2Signature; break;
                }
            }
            /// <summary>
            /// Initialize the properties for a feign state
            /// </summary>
            /// <param name="prev_datum">Handle for the datum that precedes this one</param>
            /// <param name="group_tag"></param>
            internal virtual void InitializeForFeigning(DatumIndex prev_datum, TagInterface.TagGroup group_tag)
            {
                datum       = new DatumIndex((ushort)(prev_datum.Index + 1), (short)(prev_datum.Salt + 1));
                GroupTagInt = group_tag.ID;
                groupTag    = group_tag;

                tagNameOffset = address = uint.MaxValue;
                location      = ItemLocation.Unknown;
                size          = offset = bspIndex = -1;
            }
        /// <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));
        }
        // Two "hashes" are used when using a TagDatabase.
        // The first hash (internal) is an actual hash, built from the tag name and group tag's hash code
        // The second hash (public) is just the index of the database Entry item

        #region Hash Methods
        static long CalculateHashCode64(string tag_name, TagInterface.TagGroup group_tag)
        {
            long hash;

            hash   = tag_name.GetHashCode();
            hash <<= 32;

            hash |= group_tag.ID;

            return(hash);
        }
Example #9
0
        /// <summary>
        /// Figures out if the tag is loaded in the tag index
        /// </summary>
        /// <param name="name">name of tag</param>
        /// <param name="tag_group">group tag of tag</param>
        /// <returns>The tag_index of the <see cref="TagManager"/> for the name\tag_group, or <see cref="Blam.DatumIndex.Null"/> if not loaded</returns>
        public Blam.DatumIndex IsLoaded(string name, TagInterface.TagGroup tag_group)
        {
            foreach (TagManager tm in Array)
            {
                if (tm.Compare(this, name, tag_group))
                {
                    return(tm.TagIndex);
                }
            }

            return(Blam.DatumIndex.Null);
        }
        /// <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>
        /// 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);
        }
        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);
            }
        }
        public bool TryAndFind(string name, TagInterface.TagGroup group, out CacheIndex.Item item)
        {
            item = null;

            DatumIndex reference_name;

            if (refManager.TryAndFind(group, name, out reference_name))
            {
                item = Array.Find(Index.Tags, ci => ci.ReferenceName == reference_name);

                if (item != null)
                {
                    return(true);
                }
            }

            return(false);
        }
        public override void Read(BlamLib.IO.EndianReader s)
        {
            DataCacheFile cache = s.Owner as DataCacheFile;

            type = (DataCacheType)s.ReadInt32();
            tagNamesTableOffset     = s.ReadInt32();
            tagInstancesTableOffset = s.ReadInt32();
            tagCount = s.ReadInt32();
            items    = new DataItem[tagCount];

            TagInterface.TagGroup tgroup = null;
            switch (type)
            {
            case DataCacheType.Bitmap: tgroup = TagGroups.bitm; break;

            case DataCacheType.Sound: tgroup = TagGroups.snd_; break;

            case DataCacheType.Loc:
                break;
            }

            s.Seek(TagNamesTableOffset, System.IO.SeekOrigin.Begin);
            DataItem item = null;

            for (int x = 0; x < TagCount; x++)
            {
                item               = new DataItem();
                items[x]           = item;
                item.GroupTag      = tgroup;
                item.ReferenceName = cache.References.AddOptimized(item.GroupTag, s.ReadCString());
            }

            s.Seek(tagInstancesTableOffset, System.IO.SeekOrigin.Begin);
            for (int x = 0; x < TagCount; x++)
            {
                items[x].Read(s);
            }
        }
Example #15
0
        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);
            }
        }
 protected TagDatabase(BlamVersion engine, string tag_name, TagInterface.TagGroup group_tag) : this(engine)
 { SetRoot(tag_name, group_tag); }
Example #17
0
			internal CacheFileHeader(BlamVersion engine)
			{
				switch (engine.ToBuild())
				{
					case BlamBuild.Halo1: engineSignature = kHalo1Signature; break;
					case BlamBuild.Halo2: engineSignature = kHalo2Signature; break;
				}
			}
Example #18
0
			internal CacheFileHeader(CacheFileHeader old_state)
			{
				if (old_state == null) throw new ArgumentNullException("old_state");

				this.engineSignature = old_state.engineSignature;
			}
 protected BuilderItem(BuilderTagIndexBase owner, Managers.TagManager source)
 {
     this.sourceIndexDatum = source.TagIndex;
     this.groupTag         = source.GroupTag;
     this.referenceName    = Managers.ReferenceManager.CopyHandle(/*this,*/ owner.References, owner.SourceIndex.References, source.ReferenceName);
 }
Example #20
0
		protected void ReadGroupTags(Managers.BlamDefinition gd, IO.EndianReader s)
		{
			uint gt = s.ReadUInt32();
			if (gt != uint.MaxValue)	GroupTag1 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(gt));
			else						GroupTag1 = TagInterface.TagGroup.Null;

			gt = s.ReadUInt32();
			if (gt != uint.MaxValue)	GroupTag2 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(gt));
			else						GroupTag2 = TagInterface.TagGroup.Null;

			gt = s.ReadUInt32();
			if (gt != uint.MaxValue)	GroupTag3 = gd.TagGroupFind(TagInterface.TagGroup.FromUInt(gt));
			else						GroupTag3 = TagInterface.TagGroup.Null;
		}
Example #21
0
 /// <summary>
 /// Open an existing a tag
 /// </summary>
 /// <param name="name">name of the tag</param>
 /// <param name="tag_group">tag group of the tag</param>
 /// <returns>handle of the tag</returns>
 public abstract Blam.DatumIndex Open(string name, TagInterface.TagGroup tag_group);
 /// <summary>
 /// Don't call me directly. Call <see cref="CacheFile.AddFeignTagInstance"/>
 /// </summary>
 /// <param name="cf">Owner of this tag index</param>
 /// <param name="tag_name"></param>
 /// <param name="group_tag"></param>
 /// <returns></returns>
 internal virtual CacheIndex.Item AddFeignItem(CacheFile cf, string tag_name, TagInterface.TagGroup group_tag)
 {
     return(null);
 }
Example #23
0
 public ModelTestDefinition(string type, string name, TagInterface.TagGroup group)
 {
     TypeString = type;
     Name       = name;
     Group      = group;
 }
Example #24
0
 public TagDatabase(string tag_name, TagInterface.TagGroup group_tag) : base(BlamVersion.Halo2, tag_name, group_tag)
 {
 }
 public void SetRoot(string tag_name, TagInterface.TagGroup group_tag)
 {
     Add(rootData = new HandleData(tag_name, group_tag));
 }
 /// <summary>
 /// Add a feign (fake) tag instance to the tag index
 /// </summary>
 /// <param name="tag_name"></param>
 /// <param name="group_tag"></param>
 /// <returns>Null if engine doesn't implement support this functionality</returns>
 /// <remarks>
 /// Currently only used (and needed) for tag extraction cases where a tag reference may need
 /// to be changed to a different reference (like an invalid tag so the tag is still usable)
 /// that doesn't exist in the cache
 /// </remarks>
 internal CacheIndex.Item AddFeignTagInstance(string tag_name, TagInterface.TagGroup group_tag)
 {
     return(Index.AddFeignItem(this, tag_name, group_tag));
 }
 /// <summary>
 /// Does nothing
 /// </summary>
 /// <param name="name"></param>
 /// <param name="tag_group"></param>
 /// <returns><see cref="Blam.DatumIndex.Null"/></returns>
 Blam.DatumIndex Managers.ITagIndex.Open(string name, TagInterface.TagGroup tag_group)
 {
     return(DatumIndex.Null);
 }
 public HandleData(string tag_name, TagInterface.TagGroup group_tag)
 {
     Hash     = CalculateHashCode64(this.Name = tag_name, group_tag);
     GroupTag = group_tag.Tag;
 }