Пример #1
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofile     = new OpenFileDialog();
            XmlDocument    Doc       = new XmlDocument();
            string         xmlstring = "";

            string[] files = new string[1];

            files = Directory.GetFiles(Application.StartupPath + "/XmlPatches", "*.xml", SearchOption.TopDirectoryOnly);
            string patchname = "";

            foreach (string file in files)
            {
                errorstring = file.Substring(file.LastIndexOf(@"\") + 1);
                try
                {
                    string[] Lines = new string[1];
                    xmlstring = File.ReadAllText(file, Encoding.UTF8);
                    foreach (string Line in File.ReadAllLines(file))
                    {
                        Lines[Lines.Length - 1] = Line;
                        Array.Resize(ref Lines, Lines.Length + 1);
                    }
                    Doc.LoadXml(xmlstring);

                    XmlNodeList xmlnode;
                    xmlnode = Doc.GetElementsByTagName("Patches");

                    foreach (XmlElement element in xmlnode)         //for all patches
                    {
                        XmlAttributeCollection attributes = element.Attributes;
                        XmlNodeList            patchNodes = element.SelectNodes("Patch");
                        foreach (XmlNode Patch in patchNodes)           //For each Patch node
                        {
                            patchname = Patch.Attributes["name"].InnerText;

                            //if (patchname.Contains("Phoe"))
                            //    break;

                            XmlAttribute ignoreNode = Patch.Attributes["ignore"];
                            if (!(ignoreNode != null && Boolean.Parse(ignoreNode.InnerText)))
                            {
                                foreach (XmlNode Location in Patch)         //For each Description and Location
                                {
                                    if (Location.NodeType != XmlNodeType.Comment && Location.NodeType != XmlNodeType.Text)
                                    {
                                        if (Location.Attributes == null || Location.Attributes["offset"] != null)
                                        {
                                            UInt32 offset = UInt32.Parse(Location.Attributes["offset"].InnerText, System.Globalization.NumberStyles.HexNumber);

                                            string file2 = Location.Attributes["file"].InnerText;

                                            if ((file2.Contains("BATTLE") && (offset < 0xE92AC || offset > 0xF929B || patchname.Contains("Kanji"))) ||
                                                (file2.Contains("WORLD") && (offset < 0x0005D400 || offset > 0x0006B90F || patchname.Contains("Kanji"))))
                                            {
                                                continue;
                                            }

                                            string bytes = Location.InnerText;
                                            if (Location.Name == "Variable")
                                            {
                                                if (Location.Attributes["default"] != null)
                                                {
                                                    bytes = Location.Attributes["default"].InnerText;
                                                }
                                                else
                                                {
                                                    bytes = "00";
                                                }
                                            }
                                            bytes = Validatetext(bytes);
                                            string shortfile = file.Substring(file.LastIndexOf(@"\") + 1);
                                            switch (file2)
                                            {
                                            case "BATTLE_BIN":
                                                BATTLEBIN.AddWrite(offset, bytes.Length / 2, patchname, shortfile);
                                                break;

                                            case "WORLD_WORLD_BIN":
                                                WORLDBIN.AddWrite(offset, bytes.Length / 2, patchname, shortfile);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error in format of " + errorstring + "\n" + ex + "at patch: " + patchname);
                }
            }

            //Array.Sort(BATTLEBIN.startaddress);
            //Array.Sort(BATTLEBIN.endaddress);
            //Array.Sort(WORLDBIN.startaddress);
            //Array.Sort(WORLDBIN.endaddress);
        }
Пример #2
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofile     = new OpenFileDialog();
            XmlDocument    Doc       = new XmlDocument();
            string         xmlstring = "";

            string[] files = new string[1];

            files = Directory.GetFiles(Application.StartupPath + "/XmlPatches", "*.xml", SearchOption.TopDirectoryOnly);

            foreach (string file in files)
            {
                errorstring = file.Substring(file.LastIndexOf(@"\") + 1);
                try
                {
                    string[] Lines = new string[1];
                    xmlstring = File.ReadAllText(file, Encoding.UTF8);
                    foreach (string Line in File.ReadAllLines(file))
                    {
                        Lines[Lines.Length - 1] = Line;
                        Array.Resize(ref Lines, Lines.Length + 1);
                    }
                    Doc.LoadXml(xmlstring);

                    XmlNodeList xmlnode;
                    xmlnode = Doc.GetElementsByTagName("Patches");


                    foreach (XmlElement element in xmlnode)             //for all patches
                    {
                        XmlAttributeCollection attributes = element.Attributes;
                        XmlNodeList            patchNodes = element.SelectNodes("Patch");
                        foreach (XmlNode Patch in patchNodes)               //For each Patch node
                        {
                            string       name       = Patch.Attributes["name"].InnerText;
                            XmlAttribute ignoreNode = Patch.Attributes["ignore"];
                            if (!(ignoreNode != null && Boolean.Parse(ignoreNode.InnerText)))
                            {
                                foreach (XmlNode Location in Patch)             //For each Description and Location
                                {
                                    if (Location.NodeType != XmlNodeType.Comment && Location.NodeType != XmlNodeType.Text)
                                    {
                                        if (Location.Attributes["offset"] != null)
                                        {
                                            UInt32 offset = UInt32.Parse(Location.Attributes["offset"].InnerText, System.Globalization.NumberStyles.HexNumber);
                                            string file2  = Location.Attributes["file"].InnerText;
                                            string bytes  = Location.InnerText;
                                            if (Location.Name == "Variable")
                                            {
                                                if (Location.Attributes["default"] != null)
                                                {
                                                    bytes = Location.Attributes["default"].InnerText;
                                                }
                                                else
                                                {
                                                    bytes = "00";
                                                }
                                            }
                                            bytes = Validatetext(bytes);
                                            string shortfile = file.Substring(file.LastIndexOf(@"\") + 1);
                                            switch (file2)
                                            {
                                            case "BATTLE_BIN":
                                                BATTLEBIN.AddWrite(offset, bytes.Length / 2, name, shortfile);
                                                break;

                                            case "WORLD_WORLD_BIN":
                                                WORLDBIN.AddWrite(offset, bytes.Length / 2, name, shortfile);
                                                break;

                                            case "WORLD_WLDCORE_BIN":
                                                WLDCOREBIN.AddWrite(offset, bytes.Length / 2, name, shortfile);
                                                break;

                                            case "SCUS_942_21":
                                                SCUS.AddWrite(offset, bytes.Length / 2, name, shortfile);
                                                break;

                                            case "EVENT_REQUIRE_OUT":
                                                REQUIREOUT.AddWrite(offset, bytes.Length / 2, name, shortfile);
                                                break;

                                            case "EVENT_EQUIP_OUT":
                                                EQUIPOUT.AddWrite(offset, bytes.Length / 2, name, shortfile);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error in format of " + errorstring + "\n" + ex);
                }
            }

            Filelistbox.Items.Add("Battle.Bin");
            Filelistbox.Items.Add("World.Bin");
            Filelistbox.Items.Add("Wldcore.Bin");
            Filelistbox.Items.Add("Scus.942.21");
            Filelistbox.Items.Add("Require.Out");
            Filelistbox.Items.Add("Equip.Out");
        }