Exemplo n.º 1
0
        //function display the tag structure
        private void getTagStructureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (map_loaded)
            {
                if (treeView1.SelectedNode != null)
                {
                    string type = DATA_READ.ReadTAG_TYPE(Int32.Parse(treeView1.SelectedNode.Name), map_stream);

                    plugins_field temp = DATA_READ.Get_Tag_stucture_from_plugin(type);
                    if (temp != null)
                    {
                        TreeNode tn = temp.Get_field_structure();

                        tn.Text = type;

                        treeView1.Nodes.Clear();
                        treeView1.Nodes.Add(tn);
                    }
                    else
                    {
                        MessageBox.Show("The plugin of type " + type + " doesn't exist", "ERROR");
                    }

                    map_loaded = false;
                }
                else
                {
                    MessageBox.Show("Select a TAG", "Hint");
                }
            }
            else
            {
                MessageBox.Show("Select a map First", "Hint");
            }
        }
Exemplo n.º 2
0
        private void extractMetaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (map_loaded)
            {
                if (treeView1.SelectedNode != null)
                {
                    int    tag_table_ref = Int32.Parse(treeView1.SelectedNode.Name);
                    string type          = DATA_READ.ReadTAG_TYPE(tag_table_ref, map_stream);
                    int    datum_index   = DATA_READ.ReadINT_LE(tag_table_ref + 4, map_stream);

                    //Meta Extractor
                    MetaExtractor meta_extract;
                    meta_extract = new MetaExtractor(datum_index, type, SID_list, map_stream);
                    meta_extract.Show();
                }
                else
                {
                    MessageBox.Show("Select a TAG", "Hint");
                }
            }
            else
            {
                MessageBox.Show("Select a map First", "Hint");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// return a list all tagRefs mentioned in the meta and the extended meta
        /// </summary>
        /// <returns></returns>
        public List <tagRef> Get_all_tag_refs()
        {
            List <tagRef> ret = new List <tagRef>();

            //first i add all my the tagRefs in the concerned meta
            foreach (int temp_off in ref_tags)
            {
                string type       = DATA_READ.ReadTAG_TYPE(temp_off, data);
                int    temp_datum = DATA_READ.ReadINT_LE(temp_off + 4, data);

                //i only list them if they are valid
                if (temp_datum != -1)
                {
                    tagRef temp_tagref = new tagRef();
                    temp_tagref.type        = type;
                    temp_tagref.datum_index = temp_datum;

                    ret.Add(temp_tagref);
                }
            }
            //list_extended object is only created when we are reading from a map
            if (list_extended != null)
            {
                //then we add the extended_meta dependencies
                List <int> key_list = list_extended.Keys.ToList <int>();
                foreach (int temp_key in key_list)
                {
                    extended_meta temp_meta = list_extended[temp_key];
                    ret.AddRange(temp_meta.Get_all_tag_refs());
                }
            }
            //listing the WCtagRefs
            //we can only do this when we are reading from a map
            if (map_stream != null)
            {
                //some meta reading prologue
                int table_off   = DATA_READ.ReadINT_LE(0x10, map_stream);
                int table_start = table_off + 0xC * DATA_READ.ReadINT_LE(table_off + 4, map_stream) + 0x20;

                foreach (int temp_off in ref_WCtags)
                {
                    int temp_datum = DATA_READ.ReadINT_LE(temp_off, data);//we read it from meta data
                    if (temp_datum != -1)
                    {
                        string type = DATA_READ.ReadTAG_TYPE(table_start + (0xFFFF & temp_datum) * 0x10, map_stream);//we read this from map stream

                        tagRef temp_WCtagref = new tagRef();
                        temp_WCtagref.datum_index = temp_datum;
                        temp_WCtagref.type        = type;

                        ret.Add(temp_WCtagref);
                    }
                }
            }

            return(ret);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initialises tree view upon opening a map file
        /// </summary>
        void initialize_treeview()
        {
            treeView1.Nodes.Clear();

            int tag_count  = 0;
            int path_start = 0;

            for (int i = 0; ; i++)
            {
                int tag_table_REF = table_start + 0x10 * i;

                if (tag_table_REF > table_size + table_start)
                {
                    break;
                }

                string type        = DATA_READ.ReadTAG_TYPE(tag_table_REF, map_stream);
                int    datum_index = DATA_READ.ReadINT_LE(tag_table_REF + 4, map_stream);
                string path        = DATA_READ.ReadSTRING(file_table_offset + path_start, map_stream);

                if (datum_index != -1)
                {
                    //lets check the mem addrs validity before adding it to the list
                    int mem_addr = DATA_READ.ReadINT_LE(tag_table_REF + (datum_index & 0xffff) * 0x10 + 8, map_stream);

                    if (mem_addr != 0x0)
                    {
                        AllTagList.Add(datum_index, path);//Adding only Map Specific tags with Internal Reference only to list
                    }
                    if (treeView1.Nodes.IndexOfKey(type) == -1)
                    {
                        treeView1.Nodes.Add(type, "- " + type);
                    }
                    int index = treeView1.Nodes.IndexOfKey(type);

                    //HEX Values contains ABCDEF
                    treeView1.Nodes[index].Nodes.Add(tag_table_REF.ToString(), "- " + path);

                    //add this stuff to the SID list
                    SID_list.Add(datum_index, path);

                    //ugh! is basically the last tag
                    if (type.CompareTo("ugh!") == 0)
                    {
                        break;
                    }

                    path_start += path.Length + 1;
                }

                tag_count = i;
            }
            treeView1.Sort();
            textBox2.Text = tag_count.ToString() + " Total Tags";
        }
Exemplo n.º 5
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);
        }
        /// <summary>
        /// Gets the list of tags contained in the map
        /// </summary>
        /// <param name="map_loc"></param>
        /// <returns></returns>
        List <tag_info> Get_Tag_list(string map_loc)
        {
            List <tag_info> ret = new List <tag_info>();


            StreamReader map_stream = new StreamReader(map_loc);

            int table_off         = DATA_READ.ReadINT_LE(0x10, map_stream);
            int table_size        = DATA_READ.ReadINT_LE(0x14, map_stream);
            int file_table_offset = DATA_READ.ReadINT_LE(0x2D0, map_stream);
            int table_start       = table_off + 0xC * DATA_READ.ReadINT_LE(table_off + 4, map_stream) + 0x20;


            int path_start = 0;

            for (int i = 0; ; i++)
            {
                int tag_table_REF = table_start + 0x10 * i;

                if (tag_table_REF > table_size + table_start)
                {
                    break;
                }

                string type        = DATA_READ.ReadTAG_TYPE(tag_table_REF, map_stream);
                int    datum_index = DATA_READ.ReadINT_LE(tag_table_REF + 4, map_stream);
                string path        = DATA_READ.ReadSTRING(file_table_offset + path_start, map_stream);

                if (datum_index != -1)
                {
                    tag_info temp = new tag_info();

                    temp.datum_index = datum_index;
                    temp.type        = type;
                    temp.file_loc    = path;

                    ret.Add(temp);

                    //ugh! is basically the last tag
                    if (type.CompareTo("ugh!") == 0)
                    {
                        break;
                    }

                    path_start += path.Length + 1;
                }
            }
            map_stream.Close();

            return(ret);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initialises tree view upon opening a map file
        /// </summary>
        void initialize_treeview()
        {
            treeView1.Nodes.Clear();

            int path_start = 0;

            for (int i = 0; ; i++)
            {
                int tag_table_REF = table_start + 0x10 * i;

                if (tag_table_REF > table_size + table_start)
                {
                    break;
                }

                string type        = DATA_READ.ReadTAG_TYPE(tag_table_REF, map_stream);
                int    datum_index = DATA_READ.ReadINT_LE(tag_table_REF + 4, map_stream);
                string path        = DATA_READ.ReadSTRING(file_table_offset + path_start, map_stream);

                if (datum_index != -1)
                {
                    //lets check the mem addrs validity before adding it to the list
                    int mem_addr = DATA_READ.ReadINT_LE(tag_table_REF + (datum_index & 0xffff) * 0x10 + 8, map_stream);

                    if (mem_addr != 0x0)
                    {
                        datum_list.Add(datum_index);//lets add this to the list
                    }
                    if (treeView1.Nodes.IndexOfKey(type) == -1)
                    {
                        treeView1.Nodes.Add(type, type);
                    }
                    int index = treeView1.Nodes.IndexOfKey(type);
                    //HEX Values contains ABCDEF
                    treeView1.Nodes[index].Nodes.Add(tag_table_REF.ToString(), path);

                    //add this stuff to the SID list
                    SID_list.Add(datum_index, path);

                    //ugh! is basically the last tag
                    if (type.CompareTo("ugh!") == 0)
                    {
                        break;
                    }

                    path_start += path.Length + 1;
                }
            }
        }