Beispiel #1
0
        public static HCI_File Parse(byte[] bytes)
        {
            if (BitConverter.ToUInt32(bytes, 0) != HCI_SIGNATURE)
            {
                throw new InvalidDataException("HCI signature not found!");
            }

            HCI_File hci = new HCI_File();

            int numEntries = BitConverter.ToInt32(bytes, 8);
            int offset     = BitConverter.ToInt32(bytes, 12);

            for (int i = 0; i < numEntries; i++)
            {
                HCI_Entry entry = new HCI_Entry();

                entry.CharId   = BitConverter.ToUInt16(bytes, offset + 0);
                entry.Costume  = BitConverter.ToUInt16(bytes, offset + 2);
                entry.State1   = BitConverter.ToUInt16(bytes, offset + 4);
                entry.State2   = BitConverter.ToUInt16(bytes, offset + 6);
                entry.EmbIndex = BitConverter.ToInt32(bytes, offset + 8);
                entry.I_12     = BitConverter.ToInt32(bytes, offset + 12);

                offset += 16;
                hci.Entries.Add(entry);
            }

            return(hci);
        }
Beispiel #2
0
        public static HCI_File Parse(string path, bool writeXml)
        {
            HCI_File file = Parse(File.ReadAllBytes(path));

            if (writeXml)
            {
                YAXSerializer serializer = new YAXSerializer(typeof(HCI_File));
                serializer.SerializeToFile(file, path + ".xml");
            }

            return(file);
        }