public FormLoadCharacter(Database database)
        {
            Characters = new List<CharacterData>();
            this.database = database;
            SelectedCharacter = null;

            InitializeComponent();
        }
        public void Load(Database database)
        {
            characterData = database.ReadCharacterBlob(DatabaseIndex);

            #if DEBUG
            using (BinaryWriter writer = new BinaryWriter(new FileStream("read.bin", FileMode.Create)))
            {
                writer.Write(characterData);
            }
            #endif

            using (BinaryReader reader = new BinaryReader(new MemoryStream(characterData)))
            {
                reader.BaseStream.Seek(0x0028, SeekOrigin.Begin);
                Health = reader.ReadSingle();
                Experience = reader.ReadInt32();
                Level = reader.ReadInt32();
                Class = reader.ReadByte();
                Specialization = reader.ReadByte();

                reader.BaseStream.Seek(0x0D5E + 1, SeekOrigin.Begin);
                PetIndex = reader.ReadByte();
                reader.ReadByte();
                reader.ReadByte();
                PetExperience = reader.ReadInt32();
                reader.ReadInt32();
                reader.ReadInt32();
                PetLevel = reader.ReadInt16();

                reader.BaseStream.Seek(0x0E76, SeekOrigin.Begin);
                Name = reader.ReadLongString();
                Race = reader.ReadInt32();
                Gender = reader.ReadByte();
                reader.BaseStream.Seek(3, SeekOrigin.Current);
                Face = reader.ReadInt32();
                Hair = reader.ReadInt32();
                HairColor = reader.ReadInt32(); // ABGR
            }
        }
        public bool Save(Database database)
        {
            MemoryStream saveDataStream = new MemoryStream();

            using (BinaryWriter writer = new BinaryWriter(saveDataStream))
            {
                Mirror(writer, 0x28);
                writer.Write(Health);
                writer.Write(Experience);
                writer.Write(Level);
                writer.Write(Class);
                writer.Write(Specialization);
                Mirror(writer, 0x0D5E - 0x36);

                if (PetIndex == 0 || PetIndex == 0xFF)
                {
                    writer.Write((byte)0x00);
                    writer.Write((byte)0x00);
                }
                else
                {
                    writer.Write((byte)0x13);
                    writer.Write(PetKinds[PetIndex]);
                }

                writer.Write((byte)0);
                writer.Write((byte)0);
                writer.Write(PetExperience);
                writer.Write(0);
                writer.Write(0);
                writer.Write(PetLevel);
                writer.Write((short)0);
                Mirror(writer, 0xE76 - 0x0D5E - 20);
                writer.ReadLongString(Name);
                writer.Write(Race);
                writer.Write(Gender);
                Mirror(writer, 3);
                writer.Write(Face);
                writer.Write(Hair);
                writer.Write(HairColor);

                // TODO We have to do this since inventory decides to be f*****g stupid sometimes and just not exist
                Mirror(writer, characterData.Length - (int)writer.BaseStream.Position);

                // TODO Shouldn't be a magic number
                /*
                writer.Write(4);
                for (int i = 0; i < 4; ++i)
                {
                    writer.Write(0x32);
                    for (int j = 0; j < 0x32; ++j)
                        Mirror(writer, 0x11C);
                }

                Mirror(writer, characterData.Length - 0xEC89 - 4);
                */
            }

            return database.WriteCharacterBlob(DatabaseIndex, saveDataStream.ToArray());
        }
 public FormEditor()
 {
     database = new Database();
     InitializeComponent();
 }