private void MakeMod(string path)
        {
            Mod mod = new Mod();

            mod.jobs = new List <Mod.Modjob>();
            Mod.Modjob job = new Mod.Modjob();
            job.name = "Talktable replacement";
            MemoryStream m = new MemoryStream();

            talk.Save(m);
            job.data = new List <byte[]>();
            job.data.Add(m.ToArray());
            job.script = File.ReadAllText(basepath + "templates\\empty_script.cs");
            string uuid = System.Guid.NewGuid().ToString().ToUpper();

            Mod.ModDetail        detail  = new Mod.ModDetail("Talktable replacement", 1, Mod.GetOrSetAuthor(), "replaces dialog text");
            List <Mod.ModBundle> bundles = new List <Mod.ModBundle>();
            TreeNode             t       = treeView1.SelectedNode;
            string rpath = t.Text;

            while (t.Parent.Text != "Talktable Bundles")
            {
                t     = t.Parent;
                rpath = t.Text + "/" + rpath;
            }
            Bundle.restype resource = new Bundle.restype();
            string         bpath    = "";

            foreach (Bundle b in language.bundles)
            {
                if (resource.name != rpath)
                {
                    foreach (Bundle.restype res in b.res)
                    {
                        if (BitConverter.ToUInt32(res.rtype, 0) == 0x5e862e05)
                        {
                            if (res.name == path)
                            {
                                resource = res;
                                bpath    = b.path;
                                break;
                            }
                        }
                    }
                }
            }
            List <Mod.ModBundleEntry> entries = new List <Mod.ModBundleEntry>();

            Mod.ModBundleEntry entry = new Mod.ModBundleEntry(rpath, "modefy", Tools.ByteArrayToString(resource.SHA1), 0);
            entries.Add(entry);
            bundles.Add(new Mod.ModBundle(bpath, "modefy", entries));
            job.meta = new Mod.ModMetaData(1, uuid, detail, new List <Mod.ModReq>(), bundles);
            job.xml  = Mod.MakeXMLfromJobMeta(job.meta);
            mod.jobs.Add(job);
            mod.Save(path);
        }
        private string CompareRES(Bundle.restype res, Bundle.restype res2, bool cdiff, out bool diff)
        {
            StringBuilder sb    = new StringBuilder();
            bool          tdiff = false;

            sb.Append("  D:res " + res.name + "\n");
            if (res.rtype != null && !Helpers.ByteArrayCompare(res.rtype, res2.rtype))
            {
                sb.AppendFormat("  D:-res ressource type is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(res.rtype), Helpers.ByteArrayToHexString(res2.rtype));
                tdiff = true;
            }
            if (res.baseSha1 != null && !Helpers.ByteArrayCompare(res.baseSha1, res2.baseSha1))
            {
                sb.AppendFormat("  D:-res basesha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(res.baseSha1), Helpers.ByteArrayToHexString(res2.baseSha1));
                tdiff = true;
            }
            if (res.deltaSha1 != null && !Helpers.ByteArrayCompare(res.deltaSha1, res2.deltaSha1))
            {
                sb.AppendFormat("  D:-res deltasha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(res.deltaSha1), Helpers.ByteArrayToHexString(res2.deltaSha1));
                tdiff = true;
            }
            if (res.SHA1 != null && !Helpers.ByteArrayCompare(res.SHA1, res2.SHA1))
            {
                sb.AppendFormat("  D:-res sha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(res.SHA1), Helpers.ByteArrayToHexString(res2.SHA1));
                tdiff = true;
            }
            if (res.size != null && res2.size != null && !Helpers.ByteArrayCompare(res.size, res2.size))
            {
                sb.AppendFormat("  D:-res size is different - ({0}) vs ({1})\n", BitConverter.ToInt32(res.size, 0), BitConverter.ToInt32(res2.size, 0));
                tdiff = true;
            }
            if (res.osize != null && res2.osize != null && !Helpers.ByteArrayCompare(res.osize, res2.osize))
            {
                sb.AppendFormat("  D:-res original size is different - ({0}) vs ({1})\n", BitConverter.ToInt32(res.osize, 0), BitConverter.ToInt32(res2.osize, 0));
                tdiff = true;
            }
            if (res.casPatchType != res2.casPatchType)
            {
                sb.AppendFormat("  D:-res caspatchtype is different - ({0}) vs ({1})\n", res.casPatchType, res2.casPatchType);
                tdiff = true;
            }
            if (tdiff)
            {
                diff = true;
                return(sb.ToString());
            }
            else
            {
                diff = cdiff;
                return("");
            }
        }
        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());
                }
            }
        }