HaloMap.Meta.Meta.ReadMetaFromMap C# (CSharp) Method

ReadMetaFromMap() public method

The read meta from map.
public ReadMetaFromMap ( int tagIndex, bool dontReadRaw ) : void
tagIndex int The tagIndex.
dontReadRaw bool
return void
        public void ReadMetaFromMap(int tagIndex, bool dontReadRaw)
        {
            // set meta properties
            this.Map = Map;
            this.TagIndex = tagIndex;
            this.type = Map.MetaInfo.TagType[tagIndex];
            this.name = Map.FileNames.Name[tagIndex];
            this.offset = Map.MetaInfo.Offset[tagIndex];
            this.size = Map.MetaInfo.Size[tagIndex];
            this.ident = Map.MetaInfo.Ident[tagIndex];

            string temps = this.offset.ToString("X");
            char[] tempc = temps.ToCharArray();
            int xxx = tempc.Length;
            this.padding = tempc[xxx - 1];

            // THIS = Currently Selected Tag
            // Find current Tag Meta and read into memory stream (MS)

            // For figuring out Obfuscated maps (For UGH! tag):
            // this.size = (int)(Map.BR.BaseStream.Length - this.offset);
            // Map.MetaInfo.Size[tagIndex] = this.size;
            this.MS = new MemoryStream(this.size);
            Map.BR.BaseStream.Position = this.offset;
            this.MS.Write(Map.BR.ReadBytes(this.size), 0, this.size);

            // Checks if type has raw data
            this.rawType = Map.Functions.ForMeta.CheckForRaw(this.type);
            if (dontReadRaw == false)
            {
                if (rawType != RawDataContainerType.Empty)
                {
                    this.raw = Map.Functions.ForMeta.ReadRaw(this.TagIndex, dontReadRaw);
                }
            }

            if (this.type == "sbsp")
            {
                int h = Map.BSP.FindBSPNumberByBSPIdent(this.ident);
                this.magic = Map.BSP.sbsp[h].magic;
            }
            else if (this.type == "ltmp")
            {
                int h = Map.BSP.FindBSPNumberByLightMapIdent(this.ident);
                this.magic = Map.BSP.sbsp[h].magic;
            }
            else
            {
                // Not "sbsp" or "ltmp"
                // For Halo 1 or Halo CE
                if (Map.HaloVersion == HaloVersionEnum.HaloCE || Map.HaloVersion == HaloVersionEnum.Halo1)
                {
                    this.magic = Map.PrimaryMagic;
                }
                else
                {
                    // For Halo 2
                    this.magic = Map.SecondaryMagic;
                }
            }
        }

Usage Example

Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MetaItemComparer"/> class.
        /// </summary>
        /// <param name="currentForm">The current form.</param>
        /// <remarks></remarks>
        public MetaItemComparer(MapForm currentForm)
        {
            Map map = currentForm.map;

            int counter = 0;
            for (counter = 0; counter < map.MapHeader.fileCount; counter++)
            {
                currentForm.SetProgressBar(counter * 100 / map.MapHeader.fileCount);

                ifpMeta = new Meta(map);
                manualMeta = new Meta(map);
                manualMeta.ReadMetaFromMap(counter, false);
                ifpMeta.ReadMetaFromMap(counter, false);

                // parse ifp and scan meta with it
                try
                {
                    IFPIO io = IFPHashMap.GetIfp(ifpMeta.type, map.HaloVersion);

                    ifpMeta.headersize = io.headerSize;
                    manualMeta.headersize = io.headerSize;
                    try
                    {
                        ifpMeta.scanner.ScanWithIFP(ref io);
                    }
                    catch (Exception ex)
                    {
                        Global.ShowErrorMsg("Broken IFP - " + ifpMeta.type, ex);
                    }

                    manualMeta.scanner.ScanManually();
                    check(map);
                }
                catch (Exception ex)
                {
                    Globals.Global.ShowErrorMsg(string.Empty, ex);
                }

            }

            currentForm.SetProgressBar(0);
        }
All Usage Examples Of HaloMap.Meta.Meta::ReadMetaFromMap