Meta Access Information

Discuss Halo 2 modding, progress on figuring things out, mapfiles...you know the drill. Cheating discussion not allowed.
Post Reply
jlddodger





Posts: 106
Joined: Mon May 22, 2006 6:04 pm
Contact:

Meta Access Information

Post by jlddodger »

I am working on an application. I need to access meta data. I have successfully calculated the secondary magic. And I understand that the data location is the following:
start of the meta + meta offset + value offset

However, I have found conflicting reports of how to calculate the meta start. One involved subtracting the secondary magic from the meta offset. This makes no sense to me.

I have also been told that one simply adds the secondary magic to the meta offset; however, the secondary magic is greater than the file size. On the other hand, the output of the secondary magic matches the output of DotHalo.

So, what gives?
Image
User avatar
Prey




Connoisseur Snitch! Pyre Articulatist 500

Posts: 1026
Joined: Wed Dec 27, 2006 6:49 am
Location: UK
Contact:

Post by Prey »

Ok, first of all there are some values you need to take frm the Header:

Code: Select all

            br.BaseStream.Position = 16;

            //the offset of the index
            indexOffset = br.ReadInt32();

            //the total length in bytes of the index
            indexSize = br.ReadInt32();

            //the start of the meta (straight after the index)
            metaStart = indexOffset + indexSize;

            //the total length in bytes of the meta
            metaSize = br.ReadInt32();

            //MetaSize + index Size + BSP Size
            nonRawSize = br.ReadInt32();
Then you goto the index and this is where you get the secondaryMagic:

Code: Select all

            //start of tags + 8 (skips matg tags tagtype and ident)
            br.BaseStream.Position = offsetOfObjectIndex + 8;

            //constant is raw meta offset of matg tag
            secondaryMagicConstant = br.ReadInt32();
            secondaryMagic = secondaryMagicConstant - map.header.metaStart;
Then you read all the tagInfo from the index and subtract the secondaryMagic frm the raw offset each time:

Code: Select all

            for (int x = 0; x < map.index.objectCount; x++)
            {
                //this is the tagtype, they are backward in map so we reverse
                string tt = map.Reverse(new string(br.ReadChars(4)));

                //if its not in the list add it
                if (!tagTypes.Contains(tt)) tagTypes.Add(tt);

                //and this is the rest of the info
                tagsList[x].Type = tt;
                tagsList[x].Ident = br.ReadInt32();
                tagsList[x].MetaOffset = br.ReadInt32() - map.index.secondaryMagic;
                tagsList[x].MetaSize = br.ReadInt32();
            }
Now w/e you need to access the meta of a tag you just need to go to its stored offset - 'br.BaseStream.Position = tagsList[45].MetaOffset;'
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
jlddodger





Posts: 106
Joined: Mon May 22, 2006 6:04 pm
Contact:

Post by jlddodger »

Thank you!
Image
Post Reply