コード例 #1
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog browseFile = new OpenFileDialog();
            browseFile.Filter = "Xenoverse msg (*.msg)|*.msg";
            browseFile.Title = "Browse for msg File";
            if (browseFile.ShowDialog() == DialogResult.Cancel)
                return;

            FileName = browseFile.FileName;
            file = msgStream.Load2(FileName);

            slctBox.Items.Clear();
            for (int i = 0; i < file.data.Length; i++)
                slctBox.Items.Add(file.data[i].ID.ToString() + " - " + file.data[i].NameID);
        }
コード例 #2
0
        public static msg Load(string FileName)
        {
            byte[] filedata = File.ReadAllBytes(FileName);
            msg file = new msg();
            file.type = BitConverter.ToInt16(filedata,4);
            file.data = new msgData[BitConverter.ToInt32(filedata,8)];

            //read NameID
            int startaddress = BitConverter.ToInt32(filedata, 12);
            int readpoint;
            for (int i = 0; i < file.data.Length; i++)
            {
                readpoint = startaddress + (i * 16);
                int textaddress = BitConverter.ToInt32(filedata, readpoint);
                int charCount = BitConverter.ToInt32(filedata, readpoint + 4);
                if (file.type == 256)
                    file.data[i].NameID = new string(ReadChars(filedata, textaddress, charCount));
                else
                    file.data[i].NameID = new string(ReadChars2(filedata, textaddress, charCount));
            }

            //read ID
            startaddress = BitConverter.ToInt32(filedata, 16);
            for (int i = 0; i < file.data.Length; i++)
                file.data[i].ID = BitConverter.ToInt32(filedata, startaddress + (i * 4));

            //read line/s
            startaddress = BitConverter.ToInt32(filedata, 20);
            int address2,address3;
            for (int i = 0; i < file.data.Length; i++)
            {
                readpoint = startaddress + (i * 8);
                file.data[i].Lines = new string[BitConverter.ToInt32(filedata, readpoint)];
                address2 = BitConverter.ToInt32(filedata, readpoint + 4);
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    address3 = BitConverter.ToInt32(filedata, address2);
                    int charCount = BitConverter.ToInt32(filedata, address2 + 4);
                    file.data[i].Lines[j] = new string(ReadChars(filedata, address3, charCount));
                }
            }

            for (int i = 0; i < file.data.Length; i++)
            {
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace(@"&apos;", @"'");
                }
            }

            return file;
        }
コード例 #3
0
        public static void Save2(msg file, string FileName)
        {
            for (int i = 0; i < file.data.Length; i++)
            {
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace(@"'", @"&apos;");
                }
            }

            //MessageBox.Show("setup");
            int byteCount = 0;
            int TopLength = 32;
            int Mid1Length = file.data.Length * 16;
            int Mid2Length = file.data.Length * 4;
            int Mid3Length = file.data.Length * 8;
            int lineCount = 0;
            for (int i = 0; i < file.data.Length; i++)
                lineCount += file.data[i].Lines.Length;
            int Mid4Length = lineCount * 16;
            byteCount = TopLength + Mid1Length + Mid2Length + Mid3Length + Mid4Length;
            byte[] fileData1 = new byte[byteCount];
            List<byte> fileDataText = new List<byte>();
            int TopStart = 0;
            int Mid1Start = 32;
            int Mid2Start = Mid1Start + Mid1Length;
            int Mid3Start = Mid2Start + Mid2Length;
            int Mid4Start = Mid3Start + Mid3Length;
            int LastStart = Mid4Start + Mid4Length;
            //MessageBox.Show("setup");
            //generate top
            fileData1[0] = 0x23; fileData1[1] = 0x4D; fileData1[2] = 0x53; fileData1[3] = 0x47;
            if (file.type == 256)
            { fileData1[4] = 0x00; fileData1[5] = 0x01; fileData1[6] = 0x01; fileData1[7] = 0x00; }
            else
            { fileData1[4] = 0x00; fileData1[5] = 0x00; fileData1[6] = 0x01; fileData1[7] = 0x00; }

            byte[] pass;
            pass = BitConverter.GetBytes(file.data.Length);
            Applybyte(ref fileData1, pass, 8, 4);
            pass = BitConverter.GetBytes(32);
            Applybyte(ref fileData1, pass, 12, 4);
            pass = BitConverter.GetBytes(Mid2Start);
            Applybyte(ref fileData1, pass, 16, 4);
            pass = BitConverter.GetBytes(Mid3Start);
            Applybyte(ref fileData1, pass, 20, 4);
            pass = BitConverter.GetBytes(file.data.Length);
            Applybyte(ref fileData1, pass, 24, 4);
            pass = BitConverter.GetBytes(Mid4Start);
            Applybyte(ref fileData1, pass, 28, 4);
            //MessageBox.Show("setup 1");
            //generate Mid section 1
            for (int i = 0; i < file.data.Length; i++)
            {
                Applybyte(ref fileData1,
                          GenWordsBytes(file.data[i].NameID, file.type == 256, ref fileDataText, LastStart),
                          Mid1Start + (i * 16),
                          16);
            }
            //MessageBox.Show("setup 2");
            //generate Mid section 2
            for (int i = 0; i < file.data.Length; i++)
            {
                Applybyte(ref fileData1, BitConverter.GetBytes(file.data[i].ID), Mid2Start + (i * 4), 4);
            }
            //MessageBox.Show("setup 3 4");
            //generate Mid section 3 & 4
            int ListCount = 0;
            int address3;
            for (int i = 0; i < file.data.Length; i++)
            {
                address3 = Mid4Start + (ListCount * 16);
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    Applybyte(ref fileData1,
                          GenWordsBytes(file.data[i].Lines[j], true, ref fileDataText, LastStart),
                          Mid4Start + (ListCount * 16),
                          16);
                    ListCount++;
                }
                Applybyte(ref fileData1, BitConverter.GetBytes(file.data[i].Lines.Length), Mid3Start + (i * 8), 4);
                Applybyte(ref fileData1, BitConverter.GetBytes(address3), Mid3Start + (i * 8) + 4, 4);
            }
            //MessageBox.Show("setup final");
            List<byte> finalize = new List<byte>();
            finalize.AddRange(fileData1);
            finalize.AddRange(fileDataText);

            FileStream fs = new FileStream(FileName, FileMode.Create);
            fs.Write(finalize.ToArray(), 0, finalize.Count);
            fs.Close();
        }
コード例 #4
0
        public static msg Load2(string FileName)
        {
            msg file = new msg();
            using (BinaryReader br = new BinaryReader(File.Open(FileName, FileMode.Open)))
            {
                br.BaseStream.Seek(4, SeekOrigin.Begin);
                file.type = br.ReadInt16();
                br.BaseStream.Seek(2, SeekOrigin.Current);
                file.data = new msgData[br.ReadInt32()];

                //read NameID
                int startaddress = br.ReadInt32();
                for (int i = 0; i < file.data.Length; i++)
                {
                    br.BaseStream.Seek(startaddress + (i * 16),SeekOrigin.Begin);
                    int textaddress = br.ReadInt32();
                    br.BaseStream.Seek(4,SeekOrigin.Current);
                    int charCount = br.ReadInt32();
                    br.BaseStream.Seek(textaddress, SeekOrigin.Begin);
                    if (file.type == 256)
                        file.data[i].NameID = Encoding.Unicode.GetString(br.ReadBytes(charCount - 2));
                    else
                        file.data[i].NameID = Encoding.ASCII.GetString(br.ReadBytes(charCount - 1));
                }

                // read ID
                br.BaseStream.Seek(16, SeekOrigin.Begin);
                startaddress = br.ReadInt32();
                for (int i = 0; i < file.data.Length; i++)
                {
                    br.BaseStream.Seek(startaddress + (i * 4), SeekOrigin.Begin);
                    file.data[i].ID = br.ReadInt32();
                }

                //read line/s
                br.BaseStream.Seek(20, SeekOrigin.Begin);
                startaddress = br.ReadInt32();
                int address;
                for (int i = 0; i < file.data.Length; i++)
                {
                    br.BaseStream.Seek(startaddress + (i * 8),SeekOrigin.Begin);
                    file.data[i].Lines = new string[br.ReadInt32()];
                    address = br.ReadInt32();
                    int address2;
                    for (int j = 0; j < file.data[i].Lines.Length; j++)
                    {
                        br.BaseStream.Seek(address + (j * 16), SeekOrigin.Begin);
                        address2 = br.ReadInt32();
                        br.BaseStream.Seek(4, SeekOrigin.Current);
                        int charCount = br.ReadInt32();
                        br.BaseStream.Seek(address2, SeekOrigin.Begin);
                        file.data[i].Lines[j] = Encoding.Unicode.GetString(br.ReadBytes(charCount - 2));
                    }
                }

                for (int i = 0; i < file.data.Length; i++)
                {
                    for (int j = 0; j < file.data[i].Lines.Length; j++)
                    {
                        file.data[i].Lines[j] = file.data[i].Lines[j].Replace(@"&apos;", @"'");
                    }
                }

            }

            return file;
        }
コード例 #5
0
        public static void Save(msg file, string FileName)
        {
            for (int i = 0; i < file.data.Length; i++)
            {
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace(@"'", @"&apos;");
                }
            }

            //MessageBox.Show("setup");
            int byteCount  = 0;
            int TopLength  = 32;
            int Mid1Length = file.data.Length * 16;
            int Mid2Length = file.data.Length * 4;
            int Mid3Length = file.data.Length * 8;
            int lineCount  = 0;

            for (int i = 0; i < file.data.Length; i++)
            {
                lineCount += file.data[i].Lines.Length;
            }
            int Mid4Length = lineCount * 16;

            byteCount = TopLength + Mid1Length + Mid2Length + Mid3Length + Mid4Length;
            byte[]      fileData1    = new byte[byteCount];
            List <byte> fileDataText = new List <byte>();
            int         TopStart     = 0;
            int         Mid1Start    = 32;
            int         Mid2Start    = Mid1Start + Mid1Length;
            int         Mid3Start    = Mid2Start + Mid2Length;
            int         Mid4Start    = Mid3Start + Mid3Length;
            int         LastStart    = Mid4Start + Mid4Length;

            //MessageBox.Show("setup");
            //generate top
            fileData1[0] = 0x23; fileData1[1] = 0x4D; fileData1[2] = 0x53; fileData1[3] = 0x47;
            if (file.type == 256)
            {
                fileData1[4] = 0x00; fileData1[5] = 0x01; fileData1[6] = 0x01; fileData1[7] = 0x00;
            }
            else
            {
                fileData1[4] = 0x00; fileData1[5] = 0x00; fileData1[6] = 0x01; fileData1[7] = 0x00;
            }

            byte[] pass;
            pass = BitConverter.GetBytes(file.data.Length);
            Applybyte(ref fileData1, pass, 8, 4);
            pass = BitConverter.GetBytes(32);
            Applybyte(ref fileData1, pass, 12, 4);
            pass = BitConverter.GetBytes(Mid2Start);
            Applybyte(ref fileData1, pass, 16, 4);
            pass = BitConverter.GetBytes(Mid3Start);
            Applybyte(ref fileData1, pass, 20, 4);
            pass = BitConverter.GetBytes(file.data.Length);
            Applybyte(ref fileData1, pass, 24, 4);
            pass = BitConverter.GetBytes(Mid4Start);
            Applybyte(ref fileData1, pass, 28, 4);
            //MessageBox.Show("setup 1");
            //generate Mid section 1
            for (int i = 0; i < file.data.Length; i++)
            {
                Applybyte(ref fileData1,
                          GenWordsBytes(file.data[i].NameID, file.type == 256, ref fileDataText, LastStart),
                          Mid1Start + (i * 16),
                          16);
            }
            //MessageBox.Show("setup 2");
            //generate Mid section 2
            for (int i = 0; i < file.data.Length; i++)
            {
                Applybyte(ref fileData1, BitConverter.GetBytes(file.data[i].ID), Mid2Start + (i * 4), 4);
            }
            //MessageBox.Show("setup 3 4");
            //generate Mid section 3 & 4
            int ListCount = 0;
            int address3;

            for (int i = 0; i < file.data.Length; i++)
            {
                address3 = Mid4Start + (ListCount * 16);
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    Applybyte(ref fileData1,
                              GenWordsBytes(file.data[i].Lines[j], true, ref fileDataText, LastStart),
                              Mid4Start + (ListCount * 16),
                              16);
                    ListCount++;
                }
                Applybyte(ref fileData1, BitConverter.GetBytes(file.data[i].Lines.Length), Mid3Start + (i * 8), 4);
                Applybyte(ref fileData1, BitConverter.GetBytes(address3), Mid3Start + (i * 8) + 4, 4);
            }
            //MessageBox.Show("setup final");
            List <byte> finalize = new List <byte>();

            finalize.AddRange(fileData1);
            finalize.AddRange(fileDataText);

            FileStream fs = new FileStream(FileName, FileMode.Create);

            fs.Write(finalize.ToArray(), 0, finalize.Count);
            fs.Close();
        }
コード例 #6
0
        public static msg Load(string FileName)
        {
            byte[] filedata = File.ReadAllBytes(FileName);
            msg    file     = new msg();

            file.type = BitConverter.ToInt16(filedata, 4);
            file.data = new msgData[BitConverter.ToInt32(filedata, 8)];

            //read NameID
            int startaddress = BitConverter.ToInt32(filedata, 12);
            int readpoint;

            for (int i = 0; i < file.data.Length; i++)
            {
                readpoint = startaddress + (i * 16);
                int textaddress = BitConverter.ToInt32(filedata, readpoint);
                int charCount   = BitConverter.ToInt32(filedata, readpoint + 4);
                if (file.type == 256)
                {
                    file.data[i].NameID = new string(ReadChars(filedata, textaddress, charCount));
                }
                else
                {
                    file.data[i].NameID = new string(ReadChars2(filedata, textaddress, charCount));
                }
            }


            //read ID
            startaddress = BitConverter.ToInt32(filedata, 16);
            for (int i = 0; i < file.data.Length; i++)
            {
                file.data[i].ID = BitConverter.ToInt32(filedata, startaddress + (i * 4));
            }

            //read line/s
            startaddress = BitConverter.ToInt32(filedata, 20);
            int address2, address3;

            for (int i = 0; i < file.data.Length; i++)
            {
                readpoint          = startaddress + (i * 8);
                file.data[i].Lines = new string[BitConverter.ToInt32(filedata, readpoint)];
                address2           = BitConverter.ToInt32(filedata, readpoint + 4);
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    address3 = BitConverter.ToInt32(filedata, address2);
                    int charCount = BitConverter.ToInt32(filedata, address2 + 4);
                    file.data[i].Lines[j] = new string(ReadChars(filedata, address3, charCount));
                }
            }

            for (int i = 0; i < file.data.Length; i++)
            {
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace(@"&apos;", @"'");
                }
            }

            return(file);
        }
コード例 #7
0
        public static void Save(msg file, string FileName)
        {
            for (int i = 0; i < file.data.Length; i++)
            {
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    //DEMON: Took me longer than it should have to figure out that order of how it replaces these is important when saving.
                    //Gotta replace all instances of "&" to "&amp;" first else you start messing up the apostrophies and whatnot.
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace(@"&", @"&amp;");
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace(@"'", @"&apos;");
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace("\"", @"&quot;");
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace("\r\n", "\n");
                }
            }

            //MessageBox.Show("setup");
            int byteCount  = 0;
            int TopLength  = 32;
            int Mid1Length = file.data.Length * 16;
            int Mid2Length = file.data.Length * 4;
            int Mid3Length = file.data.Length * 8;
            int lineCount  = 0;

            for (int i = 0; i < file.data.Length; i++)
            {
                lineCount += file.data[i].Lines.Length;
            }

            int Mid4Length = lineCount * 16;

            byteCount = TopLength + Mid1Length + Mid2Length + Mid3Length + Mid4Length;

            byte[]      fileData1    = new byte[byteCount];
            List <byte> fileDataText = new List <byte>();
            //int TopStart = 0;
            int Mid1Start = 32;
            int Mid2Start = Mid1Start + Mid1Length;
            int Mid3Start = Mid2Start + Mid2Length;
            int Mid4Start = Mid3Start + Mid3Length;
            int LastStart = Mid4Start + Mid4Length;

            //MessageBox.Show("setup");
            //generate top
            fileData1[0] = 0x23; fileData1[1] = 0x4D; fileData1[2] = 0x53; fileData1[3] = 0x47;
            if (file.type == 256)
            {
                fileData1[4] = 0x00; fileData1[5] = 0x01; fileData1[6] = 0x01; fileData1[7] = 0x00;
            }
            else
            {
                fileData1[4] = 0x00; fileData1[5] = 0x00; fileData1[6] = 0x01; fileData1[7] = 0x00;
            }

            byte[] pass;
            pass = BitConverter.GetBytes(file.data.Length);
            Applybyte(ref fileData1, pass, 8, 4);
            pass = BitConverter.GetBytes(32);
            Applybyte(ref fileData1, pass, 12, 4);
            pass = BitConverter.GetBytes(Mid2Start);
            Applybyte(ref fileData1, pass, 16, 4);
            pass = BitConverter.GetBytes(Mid3Start);
            Applybyte(ref fileData1, pass, 20, 4);
            pass = BitConverter.GetBytes(file.data.Length);
            Applybyte(ref fileData1, pass, 24, 4);
            pass = BitConverter.GetBytes(Mid4Start);
            Applybyte(ref fileData1, pass, 28, 4);
            //MessageBox.Show("setup 1");
            //generate Mid section 1
            for (int i = 0; i < file.data.Length; i++)
            {
                Applybyte(ref fileData1,
                          GenWordsBytes(file.data[i].NameID, file.type == 256, ref fileDataText, LastStart),
                          Mid1Start + (i * 16),
                          16);
            }
            //MessageBox.Show("setup 2");
            //generate Mid section 2
            for (int i = 0; i < file.data.Length; i++)
            {
                Applybyte(ref fileData1, BitConverter.GetBytes(file.data[i].ID), Mid2Start + (i * 4), 4);
            }
            //MessageBox.Show("setup 3 4");
            //generate Mid section 3 & 4
            int ListCount = 0;
            int address3;

            for (int i = 0; i < file.data.Length; i++)
            {
                address3 = Mid4Start + (ListCount * 16);
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    Applybyte(ref fileData1,
                              GenWordsBytes(file.data[i].Lines[j], true, ref fileDataText, LastStart),
                              Mid4Start + (ListCount * 16),
                              16);
                    ListCount++;
                }
                Applybyte(ref fileData1, BitConverter.GetBytes(file.data[i].Lines.Length), Mid3Start + (i * 8), 4);
                Applybyte(ref fileData1, BitConverter.GetBytes(address3), Mid3Start + (i * 8) + 4, 4);
            }
            //MessageBox.Show("setup final");
            List <byte> finalize = new List <byte>();

            finalize.AddRange(fileData1);
            finalize.AddRange(fileDataText);

            FileStream fs = new FileStream(FileName, FileMode.Create);

            fs.Write(finalize.ToArray(), 0, finalize.Count);
            for (int i = 0; i < file.data.Length; i++)

            //DEMON: This part exists here so that the too will re-replace the ampersands and apostrophies after saving.
            //Why do it like this? Cause I dunno how else to do it. It just works, ok

            {
                for (int j = 0; j < file.data[i].Lines.Length; j++)
                {
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace(@"&apos;", @"'");
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace(@"&quot;", "\"");
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace(@"&amp;", @"&");
                    file.data[i].Lines[j] = file.data[i].Lines[j].Replace("\n", "\r\n");
                }
            }
            fs.Close();
        }
コード例 #8
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            byte[] idbfile = new byte[1];
            eList = new EffectList();
            aList = new ActivationList();

            //640
            //load talisman
            OpenFileDialog browseFile = new OpenFileDialog();
            browseFile.Filter = "Xenoverse idb (*.idb)|*.idb";
            browseFile.Title = "Browse for  idb File";
            if (browseFile.ShowDialog() == DialogResult.Cancel)
                return;

            int count = 0;
               // if (browseFile.FileName.Contains("tal"))
            //{
                FileName = browseFile.FileName;
                //MessageBox.Show(FileName);
                idbfile = File.ReadAllBytes(FileName);
                count = BitConverter.ToInt32(idbfile, 8);
            //}

            if (chkMsgName.Checked)
            {
                //load msgfile for names
                browseFile = new OpenFileDialog();
                browseFile.Filter = "Xenoverse msg (*.msg)|*.msg";
                browseFile.Title = "Browse for msg name File";
                if (!(browseFile.ShowDialog() == DialogResult.Cancel))
                    NamesLoaded = true;

                if (browseFile.FileName.Contains("name") && NamesLoaded)
                {
                    FileNameMsgN = browseFile.FileName;
                    Names = msgStream.Load(FileNameMsgN);
                }
            }

            if (chkMsgDesc.Checked)
            {
                //load msgfile for names
                browseFile = new OpenFileDialog();
                browseFile.Filter = "Xenoverse msg (*.msg)|*.msg";
                browseFile.Title = "Browse for msg info File";
                if (!(browseFile.ShowDialog() == DialogResult.Cancel))
                    DescsLoaded = true;

                if (browseFile.FileName.Contains("info") && DescsLoaded)
                {
                    FileNameMsgD = browseFile.FileName;
                    Descs = msgStream.Load(FileNameMsgD);
                }
            }

            //idbItems set
            Items = new idbItem[count];
            for (int i = 0; i < Items.Length; i++)
            {
                Items[i].Data = new byte[640];
                Array.Copy(idbfile, 16 + (i * 640), Items[i].Data, 0, 640);
                if (NamesLoaded)
                    Items[i].msgIndexName = FindmsgIndex(ref Names, BitConverter.ToInt16(Items[i].Data, 4));
                if (DescsLoaded)
                    Items[i].msgIndexDesc = FindmsgIndex(ref Descs, BitConverter.ToInt16(Items[i].Data, 6));
            }

            itemList.Items.Clear();
            for (int i = 0; i < count; i++)
            {
                if (NamesLoaded)
                    itemList.Items.Add(BitConverter.ToInt16(Items[i].Data, 0).ToString() + " / " + String.Format("{0:X}", BitConverter.ToInt16(Items[i].Data, 0)) + "-" + Names.data[Items[i].msgIndexName].Lines[0]);
                else
                    itemList.Items.Add(BitConverter.ToInt16(Items[i].Data, 0).ToString() + " / " + String.Format("{0:X}", BitConverter.ToInt16(Items[i].Data, 0)));
            }
            EffectData();
            itemList.SelectedIndex = 0;
        }
コード例 #9
0
 public int FindmsgIndex(ref msg msgdata,int id)
 {
     for (int i = 0; i < msgdata.data.Length; i++)
     {
         if (msgdata.data[i].ID == id)
             return i;
     }
     return 0;
 }