private string CompareEBX(Bundle.ebxtype ebx, Bundle.ebxtype ebx2, bool cdiff, out bool diff)
        {
            StringBuilder sb    = new StringBuilder();
            bool          tdiff = false;

            sb.Append("  D:ebx " + ebx.name + "\n");
            if (ebx.baseSha1 != null && !Helpers.ByteArrayCompare(ebx.baseSha1, ebx2.baseSha1))
            {
                sb.AppendFormat("  D:-ebx basesha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(ebx.baseSha1), Helpers.ByteArrayToHexString(ebx2.baseSha1));
                tdiff = true;
            }
            if (ebx.deltaSha1 != null && !Helpers.ByteArrayCompare(ebx.deltaSha1, ebx2.deltaSha1))
            {
                sb.AppendFormat("  D:-ebx deltasha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(ebx.deltaSha1), Helpers.ByteArrayToHexString(ebx2.deltaSha1));
                tdiff = true;
            }
            if (ebx.Sha1 != null && !Helpers.ByteArrayCompare(ebx.Sha1, ebx2.Sha1))
            {
                sb.AppendFormat("  D:-ebx sha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(ebx.Sha1), Helpers.ByteArrayToHexString(ebx2.Sha1));
                tdiff = true;
            }
            if (ebx.size != null && !Helpers.ByteArrayCompare(ebx.size, ebx2.size))
            {
                sb.AppendFormat("  D:-ebx size is different - ({0}) vs ({1})\n", BitConverter.ToInt32(ebx.size, 0), BitConverter.ToInt32(ebx2.size, 0));
                tdiff = true;
            }
            if (ebx.originalSize != null && !Helpers.ByteArrayCompare(ebx.originalSize, ebx2.originalSize))
            {
                sb.AppendFormat("  D:-ebx original size is different - ({0}) vs ({1})\n", BitConverter.ToInt32(ebx.originalSize, 0), BitConverter.ToInt32(ebx2.originalSize, 0));
                tdiff = true;
            }
            if (ebx.casPatchType != ebx2.casPatchType)
            {
                sb.AppendFormat("  D:-ebx caspatchtype is different - ({0}) vs ({1})\n", ebx.casPatchType, ebx2.casPatchType);
                tdiff = true;
            }
            if (tdiff)
            {
                diff = true;
                return(sb.ToString());
            }
            else
            {
                diff = cdiff;
                return("");
            }
        }
Esempio n. 2
0
        private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;
            int m = listBox2.SelectedIndex;

            if (n == -1 || m == -1)
            {
                return;
            }
            Bundle b = sb.bundles[n];
            SoundWaveAssetEntry sound = sounds[m];

            Bundle.ebxtype ebx = b.ebx[sound.Index];
            string         xml = Encoding.UTF8.GetString(Tools.ExtractEbx(new MemoryStream(Tools.GetDataBySHA1(ebx.SHA1, cat))));

            rtb1.Text = xml;
            if (sound.chunks.Count != 0 && sound.chunks[0].sha1 != null)
            {
                hb1.ByteProvider = new DynamicByteProvider(Tools.GetDataBySHA1(sound.chunks[0].sha1, cat));
            }
            if (sound.chunks.Count == 0)
            {
                return;
            }
            foreach (DialogChunk dc in dchunks)
            {
                if (Tools.ByteArrayCompare(sound.chunks[0].id, dc.id))
                {
                    string     basepath = Path.GetDirectoryName(langTOC.MyPath) + "\\" + Path.GetFileNameWithoutExtension(langTOC.MyPath) + ".sb";
                    FileStream fs       = new FileStream(basepath, FileMode.Open, FileAccess.Read);
                    fs.Seek(dc.offset, 0);
                    byte[] buff = new byte[dc.size];
                    fs.Read(buff, 0, (int)dc.size);
                    hb1.ByteProvider = new DynamicByteProvider(buff);
                }
            }
            listBox3.Items.Clear();
            if (sound.segments.Count != 0)
            {
                for (int i = 0; i < sound.segments.Count; i++)
                {
                    listBox3.Items.Add(i.ToString("d4") + " : Segment at 0x" + sound.segments[i].offset.ToString("X"));
                }
            }
        }
Esempio n. 3
0
        private void extractHEXOfEBXToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;
            int m = listBox2.SelectedIndex;

            if (n == -1 || m == -1)
            {
                return;
            }
            Bundle b = sb.bundles[n];

            Bundle.ebxtype ebx  = b.ebx[sounds[m].Index];
            byte[]         data = Tools.GetDataBySHA1(ebx.SHA1, cat);
            SaveFileDialog d    = new SaveFileDialog();

            d.Filter = "*.bin|*.bin";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                File.WriteAllBytes(d.FileName, data);
                MessageBox.Show("Done.");
            }
        }
        private void CompareSB(string file1, string file2)
        {
            if (!File.Exists(file1) || !File.Exists(file2))
            {
                return;
            }
            SBFile sb1 = new SBFile(file1);
            SBFile sb2 = new SBFile(file2);

            foreach (Bundle b in sb1.bundles)
            {
                Bundle b2 = null;
                foreach (Bundle c in sb2.bundles)
                {
                    if (c.path == b.path)
                    {
                        b2 = c;
                        break;
                    }
                }
                if (b2 == null)
                {
                    continue;
                }
                StringBuilder sb = new StringBuilder();
                sb.Append(" D:bundle " + b.path + "\n");
                bool diff = false;
                foreach (Bundle.ebxtype ebx in b.ebx)
                {
                    Bundle.ebxtype ebx2 = new Bundle.ebxtype();
                    ebx2.name = "";
                    foreach (Bundle.ebxtype compare in b2.ebx)
                    {
                        if (ebx.name == compare.name)
                        {
                            ebx2 = compare;
                            break;
                        }
                    }
                    if (ebx2.name == "")
                    {
                        sb.Append("  E:ebx not found - " + ebx.name + "\n");
                        continue;
                    }
                    sb.Append(CompareEBX(ebx, ebx2, diff, out diff));
                }
                foreach (Bundle.restype res in b.res)
                {
                    Bundle.restype res2 = new Bundle.restype();
                    res2.name = "";
                    foreach (Bundle.restype compare in b2.res)
                    {
                        if (res.name == compare.name)
                        {
                            res2 = compare;
                            break;
                        }
                    }
                    if (res2.name == "")
                    {
                        sb.Append("  E:res not found - " + res.name + "\n");
                        continue;
                    }
                    sb.Append(CompareRES(res, res2, diff, out diff));
                }
                foreach (Bundle.chunktype chunk in b.chunk)
                {
                    Bundle.chunktype chunk2 = new Bundle.chunktype();
                    chunk2.id = new byte[0];
                    foreach (Bundle.chunktype compare in b2.chunk)
                    {
                        if (Helpers.ByteArrayCompare(chunk.id, compare.id))
                        {
                            chunk2 = compare;
                            break;
                        }
                    }
                    if (chunk2.id.Length == 0)
                    {
                        sb.Append("  E:chunk not found - " + Helpers.ByteArrayToHexString(chunk.id) + "\n");
                        continue;
                    }
                    sb.Append(CompareCHUNK(chunk, chunk2, diff, out diff));
                }
                if (diff)
                {
                    P(sb.ToString());
                }
            }
        }
Esempio n. 5
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            Bundle b = sb.bundles[n];

            listBox2.Items.Clear();
            sounds = new List <SoundWaveAssetEntry>();
            for (int i = 0; i < b.ebx.Count; i++)
            {
                Bundle.ebxtype ebx = b.ebx[i];
                try
                {
                    string      x   = Encoding.UTF8.GetString(Tools.ExtractEbx(new MemoryStream(Tools.GetDataBySHA1(ebx.SHA1, cat))));
                    XmlDocument xml = new XmlDocument();
                    xml.LoadXml("<xml>" + x + "</xml>");
                    XmlNodeList list = xml.GetElementsByTagName("SoundWaveAsset");
                    foreach (XmlNode node in list)
                    {
                        SoundWaveAssetEntry sound = new SoundWaveAssetEntry();
                        sound.chunks   = new List <SoundChunk>();
                        sound.segments = new List <SoundSegment>();
                        sound.Index    = i;
                        if (node.Name == "SoundWaveAsset")
                        {
                            foreach (XmlNode node2 in node.ChildNodes)
                            {
                                switch (node2.Name)
                                {
                                case "SoundDataAsset":
                                    foreach (XmlNode node3 in node2.ChildNodes)
                                    {
                                        switch (node3.Name)
                                        {
                                        case "Asset":
                                            foreach (XmlNode node4 in node3.ChildNodes)
                                            {
                                                switch (node4.Name)
                                                {
                                                case "Name":
                                                    sound.name = node4.InnerText;
                                                    break;
                                                }
                                            }
                                            break;

                                        case "Chunks":
                                            XmlNode members = node3.ChildNodes[0];
                                            if (members == null)
                                            {
                                                continue;
                                            }
                                            foreach (XmlNode node4 in members)
                                            {
                                                switch (node4.Name)
                                                {
                                                case "SoundDataChunk":
                                                    SoundChunk chunk = new SoundChunk();
                                                    XmlNode    nId   = node4.ChildNodes[0];
                                                    chunk.id = Tools.StringToByteArray(nId.InnerText);
                                                    foreach (CATFile.ChunkType c in cat.chunks)
                                                    {
                                                        if (Tools.ByteArrayCompare(c.id, chunk.id))
                                                        {
                                                            chunk.sha1 = c.sha1;
                                                        }
                                                    }
                                                    sound.chunks.Add(chunk);
                                                    break;
                                                }
                                            }
                                            break;
                                        }
                                    }
                                    break;

                                case "Segments":
                                    foreach (XmlNode node3 in node2.ChildNodes)
                                    {
                                        switch (node3.Name)
                                        {
                                        case "member":
                                            XmlNode swvseg = node3.ChildNodes[0];
                                            if (swvseg != null && swvseg.Name == "SoundWaveVariationSegment")
                                            {
                                                SoundSegment seg    = new SoundSegment();
                                                XmlNode      offset = swvseg.ChildNodes[0];
                                                seg.offset = Convert.ToInt32(offset.InnerText, 16);
                                                sound.segments.Add(seg);
                                            }
                                            break;
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                        sounds.Add(sound);
                    }
                }
                catch (Exception)
                {
                }
            }
            foreach (SoundWaveAssetEntry sound in sounds)
            {
                listBox2.Items.Add(sound.name);
            }
        }