Esempio n. 1
0
        public void Read(BinaryReader br)
        {
            Unknown1 = br.ReadByte();
            ID       = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
            Unknown2 = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
            Unknown3 = Ultily.ReadIntFrom2Bytes(br.ReadBytes(2));
            Size     = br.ReadInt32();

            long offsetStart = br.BaseStream.Position;

            Collection = new BDAT_COLLECTION();
            Collection.Read(br);
            long offsetEnd = br.BaseStream.Position;

            if (offsetStart + Size != offsetEnd)
            {
                br.BaseStream.Seek(offsetStart + Size, SeekOrigin.Begin);
            }
        }
Esempio n. 2
0
        public void ExportTranslate(string FileName, string saveFolder, BXML_TYPE format, bool is64)
        {
            FileStream   fs = new FileStream(FileName, FileMode.Open);
            BinaryReader br = new BinaryReader(fs);

            Load(br, format, is64);

            using (StreamWriter outfile = new StreamWriter(saveFolder))
            {
                outfile.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                int    empty = 0;
                string alias = string.Empty;
                string text  = string.Empty;
                for (int l = 0; l < _content.ListCount; l++)
                {
                    BDAT_LIST       blist       = _content.Lists[l];
                    BDAT_COLLECTION bcollection = blist.Collection;
                    if (bcollection.Compressed > 0)
                    {
                        outfile.WriteLine("<table>");
                        int          autoId   = 1;
                        BDAT_ARCHIVE barchive = bcollection.Archive;
                        for (int a = 0; a < barchive.SubArchiveCount; a++)
                        {
                            BDAT_SUBARCHIVE bsubarchive = barchive.SubArchives[a];
                            for (int f = 0; f < bsubarchive.FieldLookupCount; f++)
                            {
                                BDAT_FIELDTABLE  bfield  = bsubarchive.Fields[f];
                                BDAT_LOOKUPTABLE blookup = bsubarchive.Lookups[f];
                                string[]         words   = LookupSplitToWords(blookup.Data, blookup.Size);
                                empty = 0;
                                alias = string.Empty;
                                text  = string.Empty;
                                for (int w = 0; w < words.Length; w++)
                                {
                                    if (words[w] != null && words[w].Length > 0)
                                    {
                                        switch (w)
                                        {
                                        case 0:
                                            alias = string.Format("\t<text autoId=\"{0}\" alias=\"{1}\" priority=\"0\">", autoId, words[w]);
                                            autoId++;
                                            break;

                                        default:
                                            text = "<![CDATA[" + words[w] + "]]>";    //System.Web.HttpUtility.HtmlEncode(words[w]);
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        empty++;
                                    }
                                }
                                if (!string.IsNullOrEmpty(alias) && !string.IsNullOrEmpty(text))
                                {
                                    outfile.WriteLine(alias);
                                    outfile.WriteLine("\t\t<original>" + text + "</original>");
                                    outfile.WriteLine("\t\t<replacement>" + text + "</replacement>");
                                    outfile.WriteLine("\t</text>");
                                }
                            }
                        }
                        outfile.WriteLine("</table>");
                    }
                }
            }

            fs.Close();
            br.Close();
        }
Esempio n. 3
0
        public void DumpXML(string dir)
        {
            for (int l = 0; l < _content.ListCount; l++)
            {
                BDAT_LIST blist = _content.Lists[l];

                using (StreamWriter outfile = new StreamWriter(dir + "\\datafile_" + blist.ID + ".xml"))
                {
                    outfile.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    outfile.WriteLine(string.Format("<list id=\"{0}\" size=\"{1}\" unk1=\"{2}\" unk2=\"{3}\" unk3=\"{4}\">", blist.ID, blist.Size, blist.Unknown1, blist.Unknown2, blist.Unknown3));
                    BDAT_COLLECTION bcollection = blist.Collection;
                    outfile.WriteLine(string.Format("\t<collection compressed=\"{0}\">", bcollection.Compressed));
                    if (bcollection.Compressed > 0)
                    {
                        BDAT_ARCHIVE barchive = bcollection.Archive;
                        outfile.WriteLine(string.Format("\t\t<archive count=\"{0}\">", barchive.SubArchiveCount));
                        for (int a = 0; a < barchive.SubArchiveCount; a++)
                        {
                            BDAT_SUBARCHIVE bsubarchive = barchive.SubArchives[a];
                            outfile.WriteLine(string.Format("\t\t\t<subarchive count=\"{0}\" StartAndEndFieldId=\"{1}\">", bsubarchive.FieldLookupCount, m_bnsDat.BytesToHex(bsubarchive.StartAndEndFieldId)));
                            for (int f = 0; f < bsubarchive.FieldLookupCount; f++)
                            {
                                BDAT_FIELDTABLE bfield = bsubarchive.Fields[f];
                                outfile.Write(string.Format("\t\t\t\t<field ID=\"{3}\" size=\"{0}\" unk1=\"{1}\" unk2=\"{2}\">", bfield.Size, bfield.Unknown1, bfield.Unknown2, bfield.ID));
                                outfile.Write(m_bnsDat.BytesToHex(bfield.Data));//00 00 00 00 00 00 00 00 0c 00 00 00 50 00 00 00
                                outfile.WriteLine("</field>");

                                BDAT_LOOKUPTABLE blookup = bsubarchive.Lookups[f];
                                string[]         words   = LookupSplitToWords(blookup.Data, blookup.Size);
                                outfile.WriteLine(string.Format("\t\t\t\t<lookup count=\"{0}\">", words.Length));
                                int empty = 0;
                                for (int w = 0; w < words.Length; w++)
                                {
                                    if (words[w] != null && words[w].Length > 0)
                                    {
                                        outfile.Write("\t\t\t\t\t<word>");
                                        outfile.Write(words[w]);
                                        outfile.WriteLine("</word>");
                                    }
                                    else
                                    {
                                        empty++;
                                    }
                                }
                                outfile.WriteLine(string.Format("\t\t\t\t\t<empty count=\"{0}\"/>", empty));
                                outfile.WriteLine("\t\t\t\t</lookup>");
                            }
                            outfile.WriteLine("\t\t\t</subarchive>");
                        }
                        outfile.WriteLine("\t\t</archive>");
                    }
                    else
                    {
                        BDAT_LOOSE bloose = bcollection.Loose;
                        outfile.WriteLine(string.Format("\t\t<loose countFields=\"{0}\" sizeFields=\"{1}\" sizePadding=\"{2}\" sizeLookup=\"{3}\" unk=\"{4}\">", bloose.FieldCount, bloose.SizeFields, bloose.SizePadding, bloose.SizeLookup, bloose.Unknown));
                        for (int f = 0; f < bloose.FieldCount; f++)
                        {
                            BDAT_FIELDTABLE bfield = bloose.Fields[f];
                            outfile.Write(string.Format("\t\t\t<field size=\"{0}\" unk1=\"{1}\" unk2=\"{2}\">", bfield.Size, bfield.Unknown1, bfield.Unknown2));
                            outfile.Write(m_bnsDat.BytesToHex(bfield.Data));
                            outfile.WriteLine("</field>");
                        }
                        outfile.Write("\t\t\t<padding>");
                        if (bloose.Padding != null)
                        {
                            outfile.Write(m_bnsDat.BytesToHex(bloose.Padding));
                        }
                        outfile.WriteLine("</padding>");

                        string[] words = LookupSplitToWords(bloose.Lookup.Data, bloose.Lookup.Size);
                        outfile.WriteLine(string.Format("\t\t\t<lookup count=\"{0}\">", words.Length));

                        int empty = 0;
                        for (int w = 0; w < words.Length; w++)
                        {
                            // only add non-empty words
                            if (words[w] != null && words[w].Length > 0)
                            {
                                outfile.Write("\t\t\t\t<word>");
                                outfile.Write(words[w]);//WebUtility.HtmlEncode(
                                outfile.WriteLine("</word>");
                            }
                            else
                            {
                                empty++;
                            }
                        }
                        outfile.WriteLine(string.Format("\t\t\t\t<empty count=\"{0}\"/>", empty));
                        outfile.WriteLine("\t\t\t</lookup>");
                        outfile.WriteLine("\t\t</loose>");
                    }
                    outfile.WriteLine("\t</collection>");
                    outfile.WriteLine("</list>");
                }
            }
        }