List <UnisonRefs> type_ref_list;//they are used to universally reference a tag depending on the type of tagRef

        /// <summary>
        /// constructor to intialize stuff
        /// </summary>
        /// <param name="file"></param>
        /// <param name="type"></param>
        public Resyncer(string file, string type)
        {
            directory   = DATA_READ.ReadDirectory_from_file_location(file);
            resync_type = type;

            XmlDocument xd = new XmlDocument();

            xd.Load(file);

            compile_list  = new List <injectRefs>();
            scneario_list = new List <string>();
            type_ref_list = new List <UnisonRefs>();

            foreach (XmlNode Xn in xd.SelectNodes("config/tag"))
            {
                injectRefs temp = new injectRefs();

                temp.old_datum = int.Parse(Xn.SelectSingleNode("datum").InnerText, NumberStyles.HexNumber);
                temp.new_datum = -1;
                temp.file_name = Xn.SelectSingleNode("name").InnerText;
                temp.type      = DATA_READ.ReadTAG_TYPE_form_name(temp.file_name);

                scneario_list.Add(Xn.SelectSingleNode("scenario").InnerText);

                //lets add the tag to the list
                compile_list.Add(temp);
            }

            sync();
        }
        public Rebase_meta(string file)
        {
            InitializeComponent();

            XmlDocument xd = new XmlDocument();

            xd.Load(file);
            compile_list = new List <injectRefs>();

            directory = DATA_READ.ReadDirectory_from_file_location(file);
            int new_index = 0x3BA4;//new datum_indexes starting from 0x3BA4

            foreach (XmlNode Xn in xd.SelectNodes("config/tag"))
            {
                injectRefs temp = new injectRefs();

                temp.old_datum = int.Parse(Xn.SelectSingleNode("datum").InnerText, NumberStyles.HexNumber);
                temp.new_datum = new_index++;
                temp.file_name = Xn.SelectSingleNode("name").InnerText;
                temp.type      = DATA_READ.ReadTAG_TYPE_form_name(temp.file_name);

                //lets add the tag to the list
                compile_list.Add(temp);
            }
        }
Example #3
0
        List <UnisonRefs> type_ref_list;//they are used to universally reference a tag depending on the type of tagRef


        public Rebase_meta(string file)
        {
            InitializeComponent();

            XmlDocument xd = new XmlDocument();

            xd.Load(file);
            compile_list  = new List <injectRefs>();
            tag_scenarios = new List <string>();
            type_ref_list = new List <UnisonRefs>();

            directory = DATA_READ.ReadDirectory_from_file_location(file);
            int new_index = 0x3BA4;//new datum_indexes starting from 0x3BA4

            foreach (XmlNode Xn in xd.SelectNodes("config/tag"))
            {
                injectRefs temp = new injectRefs();

                temp.old_datum = int.Parse(Xn.SelectSingleNode("datum").InnerText, NumberStyles.HexNumber);
                temp.new_datum = new_index++;
                temp.file_name = Xn.SelectSingleNode("name").InnerText;
                temp.type      = DATA_READ.ReadTAG_TYPE_form_name(temp.file_name);

                tag_scenarios.Add(Xn.SelectSingleNode("scenario").InnerText);

                //lets add the tag to the list
                compile_list.Add(temp);
            }
            //now lets fill the unison List
            List <string> blacklisted_type = new List <string>();

            foreach (injectRefs inj_temp in compile_list)
            {
                if (!blacklisted_type.Contains(inj_temp.type))
                {
                    bool any_occurence = false;
                    for (int i = 0; i < type_ref_list.Count(); i++)
                    {
                        UnisonRefs uni_temp = type_ref_list[i];
                        if (uni_temp.type == inj_temp.type)
                        {
                            any_occurence = true;
                            blacklisted_type.Add(inj_temp.type);
                            type_ref_list.Remove(uni_temp);
                        }
                    }
                    if (!any_occurence)
                    {
                        UnisonRefs my_temp_ref = new UnisonRefs();
                        my_temp_ref.type      = inj_temp.type;
                        my_temp_ref.new_datum = inj_temp.new_datum;
                        my_temp_ref.file_name = inj_temp.file_name;

                        type_ref_list.Add(my_temp_ref);
                    }
                }
            }
        }
        /// <summary>
        /// Generates a list resynced tags
        /// </summary>
        /// <param name="parent_map_loc"></param>
        /// <param name="new_map_loc"></param>
        /// <returns></returns>
        List <injectRefs> Get_Resync_List(string parent_map_loc, string new_map_loc)
        {
            List <injectRefs> ret = new List <injectRefs>();

            List <tag_info> Parent_map_tags = Get_Tag_list(parent_map_loc);
            List <tag_info> New_map_tags    = Get_Tag_list(new_map_loc);


            List <tag_info> reduced_A = new List <tag_info>();
            List <tag_info> reduced_B = new List <tag_info>();

            foreach (tag_info tempA in Parent_map_tags)
            {
                if (tempA.type.CompareTo(resync_type) == 0)
                {
                    reduced_A.Add(tempA);
                }
            }

            foreach (tag_info tempB in New_map_tags)
            {
                if (tempB.type.CompareTo(resync_type) == 0)
                {
                    reduced_B.Add(tempB);
                }
            }

            for (int i = 0; i < reduced_A.Count; i++)
            {
                for (int j = 0; j < reduced_B.Count; j++)
                {
                    if (reduced_A[i].file_loc.CompareTo(reduced_B[j].file_loc) == 0)
                    {
                        injectRefs temp = new injectRefs();

                        temp.old_datum = reduced_A[i].datum_index;
                        temp.new_datum = reduced_B[j].datum_index;
                        temp.type      = reduced_A[i].type;

                        ret.Add(temp);

                        reduced_A.RemoveAt(i--);
                        reduced_B.RemoveAt(j);

                        break;
                    }
                }
            }

            return(ret);
        }