Exemplo n.º 1
0
        Dictionary <int, extended_meta> list_extended; //<mem_off,extended_meta obj>,a dictionary containing the extended meta by their memory address to prevent redundancy.

        /// <summary>
        /// use to read meta data from a map file
        /// </summary>
        /// <param name="datum_index">the datum index of the tag</param>
        /// <param name="sr">the path of the tag.eg: characters/elite/elite_mp</param>
        /// <param name="sr">the stream object</param>
        public meta(int datum_index, string path, StreamReader sr)
        {
            //initialise some stuff
            this.datum_index = datum_index;
            this.path        = path;
            map_stream       = sr;

            //some meta reading prologue
            int table_off    = DATA_READ.ReadINT_LE(0x10, map_stream);
            int table_size   = DATA_READ.ReadINT_LE(0x14, map_stream);
            int table_start  = table_off + 0xC * DATA_READ.ReadINT_LE(table_off + 4, map_stream) + 0x20;
            int scnr_off     = table_off + table_size;
            int scnr_memaddr = DATA_READ.ReadINT_LE(table_start + 0x8, map_stream);//scnr tag index is 0x0(mostly)

            //steps concerned with the specified meta
            type    = DATA_READ.ReadTAG_TYPE(table_start + (0xFFFF & datum_index) * 0x10, map_stream);
            mem_off = DATA_READ.ReadINT_LE(table_start + ((0xFFFF & datum_index) * 0x10) + 0x8, map_stream);

            size = DATA_READ.ReadINT_LE(table_start + ((0xFFFF & datum_index) * 0x10) + 0xC, map_stream);

            //read the meta from the map
            data = new byte[size];

            if (!DATA_READ.Check_shared(sr))
            {
                //normal map
                map_stream.BaseStream.Position = scnr_off + (mem_off - scnr_memaddr);
            }
            else
            {
                //shared map
                map_stream.BaseStream.Position = scnr_off + (mem_off - 0x3c000);
                //0x3c000 is a hardcoded value in blam engine
            }

            map_stream.BaseStream.Read(data, 0, size);

            //read and store the plugin structure
            plugin = DATA_READ.Get_Tag_stucture_from_plugin(type);

            //lets initialise some lists and dictionaries
            ref_data      = new List <int>();
            ref_tags      = new List <int>();
            ref_reflexive = new List <int>();
            ref_stringID  = new List <int>();
            ref_extended  = new Dictionary <int, int>();
            list_extended = new Dictionary <int, extended_meta>();
            ref_WCtags    = new List <int>();


            //now lets search for all kinds of stuff
            List_deps(0x0, plugin);
        }
Exemplo n.º 2
0
        Dictionary <int, extended_meta> list_extended; //<mem_off,extended_meta obj>,a dictionary containing the extended meta by their memory address to prevent redundancy.

        /// <summary>
        /// extended meta is similar to the meta
        /// </summary>
        /// <param name="mem_address"></param>
        /// <param name="size">the total size of the extended meta containg all occurences</param>
        /// <param name="count"></param>
        /// <param name="plugin"></param>
        /// <param name="sr"></param>
        public extended_meta(int mem_address, int size, int count, plugins_field plugin, StreamReader sr)
        {
            this.mem_off    = mem_address;
            this.size       = size;
            this.plugin     = plugin;
            this.map_stream = sr;
            this.entry_size = size / count;

            //some meta reading prologue
            int table_off    = DATA_READ.ReadINT_LE(0x10, map_stream);
            int table_size   = DATA_READ.ReadINT_LE(0x14, map_stream);
            int table_start  = table_off + 0xC * DATA_READ.ReadINT_LE(table_off + 4, map_stream) + 0x20;
            int scnr_off     = table_off + table_size;
            int scnr_memaddr = DATA_READ.ReadINT_LE(table_start + 0x8, map_stream);//scnr tag index is 0x0(mostly)

            //read the extended_meta from the map
            data = new byte[this.size];

            if (!DATA_READ.Check_shared(sr))
            {
                //normal map
                map_stream.BaseStream.Position = scnr_off + (mem_off - scnr_memaddr);
            }
            else
            {
                //shared map
                map_stream.BaseStream.Position = scnr_off + (mem_off - 0x3c000);
                //0x3c000 is a hardcoded value in blam engine
            }

            map_stream.BaseStream.Read(data, 0, this.size);

            //lets initialise some lists and dictionaries
            ref_data      = new List <int>();
            ref_tags      = new List <int>();
            ref_stringID  = new List <int>();
            ref_reflexive = new List <int>();
            ref_extended  = new Dictionary <int, int>();
            list_extended = new Dictionary <int, extended_meta>();
            ref_WCtags    = new List <int>();

            //we we have loop through the extended meta stuff
            for (int i = 0; i < count; i++)
            {
                List_deps(i * entry_size, plugin);
            }
        }