Exemplo n.º 1
0
        public static void Write(string path, List <OCT_Char> data)
        {
            using (BinaryWriter bw = new BinaryWriter(File.Open(path, FileMode.Create)))
            {
                bw.Write(new byte[] { 0x23, 0x4F, 0x43, 0x54, 0xFE, 0xFF, 0x10, 0x00 });
                bw.Write(data.Count);
                bw.BaseStream.Seek(4, SeekOrigin.Current);
                int address    = 16 + (data.Count * 16);
                int indexStart = 0;
                for (int i = 0; i < data.Count; i++)
                {
                    OCT_Char w = data[i];
                    bw.Write(w.data.Count);
                    bw.Write(address - 16);
                    bw.Write(indexStart);
                    bw.Write(w.id);
                    indexStart += w.data.Count;
                }

                for (int i = 0; i < data.Count; i++)
                {
                    OCT_Char w = data[i];
                    for (int j = 0; j < w.data.Count; j++)
                    {
                        OCT_Talisman t = w.data[j];
                        bw.Write(t.unk1);
                        bw.Write(t.unk2);
                        bw.Write(t.unk3);
                        bw.Write(t.unk4);
                        bw.Write(t.unk5);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public static List <OCT_Char> Read(string path)
        {
            List <OCT_Char> data = new List <OCT_Char>();

            using (BinaryReader br = new BinaryReader(File.Open(path, FileMode.Open)))
            {
                br.BaseStream.Seek(8, SeekOrigin.Begin);
                int count = br.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    OCT_Char n = new OCT_Char();
                    br.BaseStream.Seek(16 + (i * 16), SeekOrigin.Begin);
                    int count2  = br.ReadInt32();
                    int address = br.ReadInt32();
                    int index   = br.ReadInt32();
                    n.id = br.ReadInt32();

                    br.BaseStream.Seek(16 + address + (index * 20), SeekOrigin.Begin);
                    n.data = new List <OCT_Talisman>();
                    for (int j = 0; j < count2; j++)
                    {
                        OCT_Talisman t = new OCT_Talisman();
                        t.unk1 = br.ReadInt32();
                        t.unk2 = br.ReadInt32();
                        t.unk3 = br.ReadInt32();
                        t.unk4 = br.ReadInt32();
                        t.unk5 = br.ReadInt32();
                        n.data.Add(t);
                    }
                    data.Add(n);
                }
            }
            return(data);
        }