示例#1
0
        private static void Main()
        {
            Console.WriteLine("  {0,-24}___{1,-16}___{2,-24}", new string('_', 24), new string('_', 16), new string('_', 24));
            Console.WriteLine(" /{0,-24}   {1,-16}   {2,-24}\\", "Data", "Count", "Time");
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", new string('-', 24), new string('-', 16), new string('-', 24));
            PerformanceTimer timer = new PerformanceTimer();
            timer.Unpause();

            using (BinaryWriter writer = new BinaryWriter(new FileStream("Data.bin", FileMode.Create, FileAccess.Write), Encoding.ASCII))
            {
                AbilityExport.Export(writer);
                SkillExport.Export(writer);
                NPCExport.Export(writer);
                ReactorExport.Export(writer);
                MobExport.Export(writer);
                QuestExport.Export(writer);
                ItemExport.Export(writer);
                MapExport.Export(writer);
            }

            timer.Pause();
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", new string('-', 24), new string('-', 16), new string('-', 24));
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", "All", AllDataCounter, timer.Duration);
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", new string('-', 24), new string('-', 16), new string('-', 24));
            Console.WriteLine(" \\{0,-24}___{1,-16}___{2,-24}/", new string('_', 24), new string('_', 16), new string('_', 24));
            Console.WriteLine();
            Console.Write("Press Any Key To Exit");
            Console.ReadKey(true);
        }
        public static void Export(BinaryWriter pWriter)
        {
            PerformanceTimer timer = new PerformanceTimer();
            long dataCount = 0;
            timer.Unpause();

            List<ItemData> datas = new List<ItemData>();
            using (MySqlConnection connection1 = new MySqlConnection(Program.Database))
            {
                connection1.Open();
                MySqlCommand command1 = connection1.CreateCommand();
                command1.CommandText = "SELECT COUNT(*) FROM item_data";
                Program.ResetCounter((int)(long)command1.ExecuteScalar());
                command1.CommandText = "SELECT * FROM item_data ORDER BY itemid ASC";
                using (MySqlDataReader reader1 = command1.ExecuteReader())
                {
                    while (reader1.Read())
                    {
                        ItemData data = new ItemData();
                        data.Identifier = (int)Convert.ChangeType(reader1["itemid"], TypeCode.Int32);
                        if ((string)Convert.ChangeType(reader1["flags"], TypeCode.String) != "") data.Flags = (ItemData.EItemFlags)Enum.Parse(typeof(ItemData.EItemFlags), (string)Convert.ChangeType(reader1["flags"], TypeCode.String), true);
                        data.Price = (int)Convert.ChangeType(reader1["price"], TypeCode.Int32);
                        data.MaxSlotQuantity = (ushort)Convert.ChangeType(reader1["max_slot_quantity"], TypeCode.UInt16);
                        data.MaxPossessionCount = (byte)Convert.ChangeType(reader1["max_possession_count"], TypeCode.Byte);
                        data.MinLevel = (byte)Convert.ChangeType(reader1["min_level"], TypeCode.Byte);
                        data.MaxLevel = (byte)Convert.ChangeType(reader1["max_level"], TypeCode.Byte);
                        data.Experience = (int)Convert.ChangeType(reader1["exp"], TypeCode.Int32);
                        data.MakerLevel = (byte)Convert.ChangeType(reader1["level_for_maker"], TypeCode.Byte);
                        data.Money = (int)Convert.ChangeType(reader1["money"], TypeCode.Int32);
                        data.StateChangeItem = (int)Convert.ChangeType(reader1["state_change_item"], TypeCode.Int32);
                        data.NPC = (int)Convert.ChangeType(reader1["npc"], TypeCode.Int32);
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM item_equip_data WHERE equipid=@equipid";
                            command2.Parameters.AddWithValue("@equipid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                if (reader2.Read())
                                {
                                    data.Equipment = new ItemData.ItemEquipmentData();
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") data.Equipment.Flags = (ItemData.ItemEquipmentData.EItemEquipmentFlags)Enum.Parse(typeof(ItemData.ItemEquipmentData.EItemEquipmentFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    data.Equipment.Slots = (ItemData.ItemEquipmentData.EItemEquipmentSlots)Enum.Parse(typeof(ItemData.ItemEquipmentData.EItemEquipmentSlots), (string)Convert.ChangeType(reader2["equip_slots"], TypeCode.String), true);
                                    data.Equipment.AttackSpeed = (byte)Convert.ChangeType(reader2["attack_speed"], TypeCode.Byte);
                                    data.Equipment.HealHP = (byte)Convert.ChangeType(reader2["heal_hp"], TypeCode.Byte);
                                    data.Equipment.Scrolls = (byte)Convert.ChangeType(reader2["scroll_slots"], TypeCode.Byte);
                                    data.Equipment.RequiredStrength = (ushort)Convert.ChangeType(reader2["req_str"], TypeCode.UInt16);
                                    data.Equipment.RequiredDexterity = (ushort)Convert.ChangeType(reader2["req_dex"], TypeCode.UInt16);
                                    data.Equipment.RequiredIntellect = (ushort)Convert.ChangeType(reader2["req_int"], TypeCode.UInt16);
                                    data.Equipment.RequiredLuck = (ushort)Convert.ChangeType(reader2["req_luk"], TypeCode.UInt16);
                                    data.Equipment.RequiredFame = (byte)Convert.ChangeType(reader2["req_fame"], TypeCode.Byte);
                                    data.Equipment.RequiredJob = (ItemData.ItemEquipmentData.EItemEquipmentJobFlags)Enum.Parse(typeof(ItemData.ItemEquipmentData.EItemEquipmentJobFlags), (string)Convert.ChangeType(reader2["req_job"], TypeCode.String), true);
                                    data.Equipment.HP = (ushort)Convert.ChangeType(reader2["hp"], TypeCode.UInt16);
                                    data.Equipment.MP = (ushort)Convert.ChangeType(reader2["mp"], TypeCode.UInt16);
                                    data.Equipment.Strength = (ushort)Convert.ChangeType(reader2["str"], TypeCode.UInt16);
                                    data.Equipment.Dexterity = (ushort)Convert.ChangeType(reader2["dex"], TypeCode.UInt16);
                                    data.Equipment.Intellect = (ushort)Convert.ChangeType(reader2["int"], TypeCode.UInt16);
                                    data.Equipment.Luck = (ushort)Convert.ChangeType(reader2["luk"], TypeCode.UInt16);
                                    data.Equipment.Hands = (byte)Convert.ChangeType(reader2["hands"], TypeCode.Byte);
                                    data.Equipment.WeaponAttack = (byte)Convert.ChangeType(reader2["weapon_attack"], TypeCode.Byte);
                                    data.Equipment.MagicAttack = (byte)Convert.ChangeType(reader2["magic_attack"], TypeCode.Byte);
                                    data.Equipment.WeaponDefense = (byte)Convert.ChangeType(reader2["weapon_defense"], TypeCode.Byte);
                                    data.Equipment.MagicDefense = (byte)Convert.ChangeType(reader2["magic_defense"], TypeCode.Byte);
                                    data.Equipment.Accuracy = (byte)Convert.ChangeType(reader2["accuracy"], TypeCode.Byte);
                                    data.Equipment.Avoidance = (byte)Convert.ChangeType(reader2["avoid"], TypeCode.Byte);
                                    data.Equipment.Speed = (byte)Convert.ChangeType(reader2["speed"], TypeCode.Byte);
                                    data.Equipment.Jump = (byte)Convert.ChangeType(reader2["jump"], TypeCode.Byte);
                                    data.Equipment.Traction = (byte)Convert.ChangeType(reader2["traction"], TypeCode.Byte);
                                    data.Equipment.TamingMob = (byte)Convert.ChangeType(reader2["taming_mob"], TypeCode.Byte);
                                    data.Equipment.IceDamage = (byte)Convert.ChangeType(reader2["inc_ice_damage"], TypeCode.Byte);
                                    data.Equipment.FireDamage = (byte)Convert.ChangeType(reader2["inc_fire_damage"], TypeCode.Byte);
                                    data.Equipment.PoisonDamage = (byte)Convert.ChangeType(reader2["inc_poison_damage"], TypeCode.Byte);
                                    data.Equipment.LightningDamage = (byte)Convert.ChangeType(reader2["inc_lightning_damage"], TypeCode.Byte);
                                    data.Equipment.ElementalDefault = (byte)Convert.ChangeType(reader2["elemental_default"], TypeCode.Byte);
                                    data.Equipment.TimelessLevels = new List<ItemData.ItemEquipmentData.ItemEquipmentTimelessLevelData>();
                                    using (MySqlConnection connection3 = new MySqlConnection(Program.Database))
                                    {
                                        connection3.Open();
                                        MySqlCommand command3 = connection3.CreateCommand();
                                        command3.CommandText = "SELECT * FROM item_timeless_levels WHERE equipid=@equipid ORDER BY level ASC";
                                        command3.Parameters.AddWithValue("@equipid", data.Identifier);
                                        using (MySqlDataReader reader3 = command3.ExecuteReader())
                                        {
                                            while (reader3.Read())
                                            {
                                                ItemData.ItemEquipmentData.ItemEquipmentTimelessLevelData levelData = new ItemData.ItemEquipmentData.ItemEquipmentTimelessLevelData();
                                                levelData.Level = (byte)Convert.ChangeType(reader3["level"], TypeCode.Byte);
                                                levelData.Experience = (byte)Convert.ChangeType(reader3["exp"], TypeCode.Byte);
                                                levelData.MinStrength = (byte)Convert.ChangeType(reader3["str_min"], TypeCode.Byte);
                                                levelData.MaxStrength = (byte)Convert.ChangeType(reader3["str_max"], TypeCode.Byte);
                                                levelData.MinDexterity = (byte)Convert.ChangeType(reader3["dex_min"], TypeCode.Byte);
                                                levelData.MaxDexterity = (byte)Convert.ChangeType(reader3["dex_max"], TypeCode.Byte);
                                                levelData.MinIntellect = (byte)Convert.ChangeType(reader3["int_min"], TypeCode.Byte);
                                                levelData.MaxIntellect = (byte)Convert.ChangeType(reader3["int_max"], TypeCode.Byte);
                                                levelData.MinLuck = (byte)Convert.ChangeType(reader3["luk_min"], TypeCode.Byte);
                                                levelData.MaxLuck = (byte)Convert.ChangeType(reader3["luk_max"], TypeCode.Byte);
                                                levelData.MinSpeed = (byte)Convert.ChangeType(reader3["speed_min"], TypeCode.Byte);
                                                levelData.MaxSpeed = (byte)Convert.ChangeType(reader3["speed_max"], TypeCode.Byte);
                                                levelData.MinJump = (byte)Convert.ChangeType(reader3["jump_min"], TypeCode.Byte);
                                                levelData.MaxJump = (byte)Convert.ChangeType(reader3["jump_max"], TypeCode.Byte);
                                                levelData.MinWeaponAttack = (byte)Convert.ChangeType(reader3["weapon_attack_min"], TypeCode.Byte);
                                                levelData.MaxWeaponAttack = (byte)Convert.ChangeType(reader3["weapon_attack_max"], TypeCode.Byte);
                                                levelData.MinWeaponDefense = (byte)Convert.ChangeType(reader3["weapon_defense_min"], TypeCode.Byte);
                                                levelData.MaxWeaponDefense = (byte)Convert.ChangeType(reader3["weapon_defense_max"], TypeCode.Byte);
                                                levelData.MinMagicAttack = (byte)Convert.ChangeType(reader3["magic_attack_min"], TypeCode.Byte);
                                                levelData.MaxMagicAttack = (byte)Convert.ChangeType(reader3["magic_attack_max"], TypeCode.Byte);
                                                levelData.MinMagicDefense = (byte)Convert.ChangeType(reader3["magic_defense_min"], TypeCode.Byte);
                                                levelData.MaxMagicDefense = (byte)Convert.ChangeType(reader3["magic_defense_max"], TypeCode.Byte);
                                                levelData.MinHP = (byte)Convert.ChangeType(reader3["hp_min"], TypeCode.Byte);
                                                levelData.MaxHP = (byte)Convert.ChangeType(reader3["hp_max"], TypeCode.Byte);
                                                levelData.MinMP = (byte)Convert.ChangeType(reader3["mp_min"], TypeCode.Byte);
                                                levelData.MaxMP = (byte)Convert.ChangeType(reader3["mp_max"], TypeCode.Byte);
                                                levelData.MinAccuracy = (byte)Convert.ChangeType(reader3["accuracy_min"], TypeCode.Byte);
                                                levelData.MaxAccuracy = (byte)Convert.ChangeType(reader3["accuracy_max"], TypeCode.Byte);
                                                levelData.MinAvoidance = (byte)Convert.ChangeType(reader3["avoidability_min"], TypeCode.Byte);
                                                levelData.MaxAvoidance = (byte)Convert.ChangeType(reader3["avoidability_max"], TypeCode.Byte);

                                                data.Equipment.TimelessLevels.Add(levelData);
                                            }
                                        }
                                    }
                                    data.Equipment.TimelessSkills = new List<ItemData.ItemEquipmentData.ItemEquipmentTimelessSkillData>();
                                    using (MySqlConnection connection3 = new MySqlConnection(Program.Database))
                                    {
                                        connection3.Open();
                                        MySqlCommand command3 = connection3.CreateCommand();
                                        command3.CommandText = "SELECT * FROM item_timeless_skills WHERE equipid=@equipid ORDER BY item_level ASC";
                                        command3.Parameters.AddWithValue("@equipid", data.Identifier);
                                        using (MySqlDataReader reader3 = command3.ExecuteReader())
                                        {
                                            while (reader3.Read())
                                            {
                                                ItemData.ItemEquipmentData.ItemEquipmentTimelessSkillData skillData = new ItemData.ItemEquipmentData.ItemEquipmentTimelessSkillData();
                                                skillData.Level = (byte)Convert.ChangeType(reader3["item_level"], TypeCode.Byte);
                                                skillData.SkillIdentifier = (int)Convert.ChangeType(reader3["skillid"], TypeCode.Int32);
                                                skillData.SkillLevel = (byte)Convert.ChangeType(reader3["skill_level"], TypeCode.Byte);
                                                skillData.Probability = (byte)Convert.ChangeType(reader3["probability"], TypeCode.Byte);

                                                data.Equipment.TimelessSkills.Add(skillData);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM item_consume_data WHERE itemid=@itemid";
                            command2.Parameters.AddWithValue("@itemid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                if (reader2.Read())
                                {
                                    data.Consume = new ItemData.ItemConsumeData();
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") data.Consume.Flags = (ItemData.ItemConsumeData.EItemConsumeFlags)Enum.Parse(typeof(ItemData.ItemConsumeData.EItemConsumeFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    data.Consume.Effect = (byte)Convert.ChangeType(reader2["effect"], TypeCode.Byte);
                                    data.Consume.HP = (ushort)Convert.ChangeType(reader2["hp"], TypeCode.UInt16);
                                    data.Consume.MP = (ushort)Convert.ChangeType(reader2["mp"], TypeCode.UInt16);
                                    data.Consume.HPPercent = (short)Convert.ChangeType(reader2["hp_percentage"], TypeCode.Int16);
                                    data.Consume.MPPercent = (short)Convert.ChangeType(reader2["mp_percentage"], TypeCode.Int16);
                                    data.Consume.MoveTo = (int)Convert.ChangeType(reader2["move_to"], TypeCode.Int32);
                                    data.Consume.DecreaseHunger = (byte)Convert.ChangeType(reader2["decrease_hunger"], TypeCode.Byte);
                                    data.Consume.DecreaseFatigue = (byte)Convert.ChangeType(reader2["decrease_fatigue"], TypeCode.Byte);
                                    data.Consume.CarnivalPoints = (byte)Convert.ChangeType(reader2["carnival_points"], TypeCode.Byte);
                                    data.Consume.CreateItem = (int)Convert.ChangeType(reader2["create_item"], TypeCode.Int32);
                                    data.Consume.Probability = (byte)Convert.ChangeType(reader2["prob"], TypeCode.Byte);
                                    data.Consume.Time = (ushort)Convert.ChangeType(reader2["time"], TypeCode.UInt16);
                                    data.Consume.WeaponAttack = (short)Convert.ChangeType(reader2["weapon_attack"], TypeCode.Int16);
                                    data.Consume.MagicAttack = (short)Convert.ChangeType(reader2["magic_attack"], TypeCode.Int16);
                                    data.Consume.WeaponDefense = (short)Convert.ChangeType(reader2["weapon_defense"], TypeCode.Int16);
                                    data.Consume.MagicDefense = (short)Convert.ChangeType(reader2["magic_defense"], TypeCode.Int16);
                                    data.Consume.Accuracy = (short)Convert.ChangeType(reader2["accuracy"], TypeCode.Int16);
                                    data.Consume.Avoidance = (byte)Convert.ChangeType(reader2["avoid"], TypeCode.Byte);
                                    data.Consume.Speed = (byte)Convert.ChangeType(reader2["speed"], TypeCode.Byte);
                                    data.Consume.Jump = (byte)Convert.ChangeType(reader2["jump"], TypeCode.Byte);
                                    data.Consume.Morph = (byte)Convert.ChangeType(reader2["morph"], TypeCode.Byte);
                                    data.Consume.LootIncrease = (ItemData.ItemConsumeData.EItemConsumeLootIncrease)Enum.Parse(typeof(ItemData.ItemConsumeData.EItemConsumeLootIncrease), (string)Convert.ChangeType(reader2["drop_up"], TypeCode.String), true);
                                    data.Consume.LootIncreaseItemIdentifier = (int)Convert.ChangeType(reader2["drop_up_item"], TypeCode.Int32);
                                    data.Consume.LootIncreaseItemIdentifierRange = (ushort)Convert.ChangeType(reader2["drop_up_item_range"], TypeCode.UInt16);
                                    data.Consume.LootIncreaseMapIdentifierRange = (byte)Convert.ChangeType(reader2["drop_up_map_ranges"], TypeCode.Byte);
                                    data.Consume.IceDefense = (byte)Convert.ChangeType(reader2["defense_vs_ice"], TypeCode.Byte);
                                    data.Consume.FireDefense = (byte)Convert.ChangeType(reader2["defense_vs_fire"], TypeCode.Byte);
                                    data.Consume.PoisonDefense = (byte)Convert.ChangeType(reader2["defense_vs_poison"], TypeCode.Byte);
                                    data.Consume.LightningDefense = (byte)Convert.ChangeType(reader2["defense_vs_lightning"], TypeCode.Byte);
                                    data.Consume.DarknessDefense = (byte)Convert.ChangeType(reader2["defense_vs_darkness"], TypeCode.Byte);
                                    data.Consume.CurseDefense = (byte)Convert.ChangeType(reader2["defense_vs_curse"], TypeCode.Byte);
                                    data.Consume.SealDefense = (byte)Convert.ChangeType(reader2["defense_vs_seal"], TypeCode.Byte);
                                    data.Consume.WeaknessDefense = (byte)Convert.ChangeType(reader2["defense_vs_weakness"], TypeCode.Byte);
                                    data.Consume.StunDefense = (byte)Convert.ChangeType(reader2["defense_vs_stun"], TypeCode.Byte);
                                }
                            }
                        }
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM item_monster_card_map_ranges WHERE itemid=@itemid";
                            command2.Parameters.AddWithValue("@itemid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                if (reader2.Read())
                                {
                                    data.Card = new ItemData.ItemCardData();
                                    data.Card.StartMapIdentifier = (int)Convert.ChangeType(reader2["startmap"], TypeCode.Int32);
                                    data.Card.EndMapIdentifier = (int)Convert.ChangeType(reader2["endmap"], TypeCode.Int32);
                                }
                            }
                        }
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM item_pet_data WHERE id=@id";
                            command2.Parameters.AddWithValue("@id", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                if (reader2.Read())
                                {
                                    data.Pet = new ItemData.ItemPetData();
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") data.Pet.Flags = (ItemData.ItemPetData.EItemPetFlags)Enum.Parse(typeof(ItemData.ItemPetData.EItemPetFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    data.Pet.Hunger = (byte)Convert.ChangeType(reader2["hunger"], TypeCode.Byte);
                                    data.Pet.Life = (byte)Convert.ChangeType(reader2["life"], TypeCode.Byte);
                                    data.Pet.LimitedLife = (ushort)Convert.ChangeType(reader2["limited_life"], TypeCode.UInt16);
                                    data.Pet.EvolutionItemIdentifier = (int)Convert.ChangeType(reader2["evolution_item"], TypeCode.Int32);
                                    data.Pet.RequiredLevelToEvolve = (byte)Convert.ChangeType(reader2["req_level_for_evolution"], TypeCode.Byte);
                                    data.Pet.Evolutions = new List<ItemData.ItemPetData.ItemPetEvolutionData>();
                                    using (MySqlConnection connection3 = new MySqlConnection(Program.Database))
                                    {
                                        connection3.Open();
                                        MySqlCommand command3 = connection3.CreateCommand();
                                        command3.CommandText = "SELECT * FROM item_pet_evolutions WHERE itemid=@itemid ORDER BY evolution_itemid ASC";
                                        command3.Parameters.AddWithValue("@itemid", data.Identifier);
                                        using (MySqlDataReader reader3 = command3.ExecuteReader())
                                        {
                                            while (reader3.Read())
                                            {
                                                ItemData.ItemPetData.ItemPetEvolutionData evolutionData = new ItemData.ItemPetData.ItemPetEvolutionData();
                                                evolutionData.NextEvolutionItemIdentifier = (int)Convert.ChangeType(reader3["evolution_itemid"], TypeCode.Int32);
                                                evolutionData.Chance = (ushort)Convert.ChangeType(reader3["chance"], TypeCode.UInt16);

                                                data.Pet.Evolutions.Add(evolutionData);
                                            }
                                        }
                                    }
                                    data.Pet.Interactions = new List<ItemData.ItemPetData.ItemPetInteractionData>();
                                    using (MySqlConnection connection3 = new MySqlConnection(Program.Database))
                                    {
                                        connection3.Open();
                                        MySqlCommand command3 = connection3.CreateCommand();
                                        command3.CommandText = "SELECT * FROM item_pet_interactions WHERE itemid=@itemid ORDER BY command ASC";
                                        command3.Parameters.AddWithValue("@itemid", data.Identifier);
                                        using (MySqlDataReader reader3 = command3.ExecuteReader())
                                        {
                                            while (reader3.Read())
                                            {
                                                ItemData.ItemPetData.ItemPetInteractionData interactionData = new ItemData.ItemPetData.ItemPetInteractionData();
                                                interactionData.Closeness = (byte)Convert.ChangeType(reader3["closeness"], TypeCode.Byte);
                                                interactionData.Success = (byte)Convert.ChangeType(reader3["success"], TypeCode.Byte);

                                                data.Pet.Interactions.Add(interactionData);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM item_rechargeable_data WHERE itemid=@itemid";
                            command2.Parameters.AddWithValue("@itemid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                if (reader2.Read())
                                {
                                    data.Recharge = new ItemData.ItemRechargeData();
                                    data.Recharge.Price = (float)Convert.ChangeType(reader2["unit_price"], TypeCode.Single);
                                    data.Recharge.WeaponAttack = (byte)Convert.ChangeType(reader2["weapon_attack"], TypeCode.Byte);
                                }
                            }
                        }
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM item_scroll_data WHERE itemid=@itemid";
                            command2.Parameters.AddWithValue("@itemid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                if (reader2.Read())
                                {
                                    data.Scroll = new ItemData.ItemScrollData();
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") data.Scroll.Flags = (ItemData.ItemScrollData.EItemScrollFlags)Enum.Parse(typeof(ItemData.ItemScrollData.EItemScrollFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    data.Scroll.Success = (byte)Convert.ChangeType(reader2["success"], TypeCode.Byte);
                                    data.Scroll.BreakItem = (byte)Convert.ChangeType(reader2["break_item"], TypeCode.Byte);
                                    data.Scroll.Strength = (byte)Convert.ChangeType(reader2["istr"], TypeCode.Byte);
                                    data.Scroll.Dexterity = (byte)Convert.ChangeType(reader2["idex"], TypeCode.Byte);
                                    data.Scroll.Intellect = (byte)Convert.ChangeType(reader2["iint"], TypeCode.Byte);
                                    data.Scroll.Luck = (byte)Convert.ChangeType(reader2["iluk"], TypeCode.Byte);
                                    data.Scroll.HP = (byte)Convert.ChangeType(reader2["ihp"], TypeCode.Byte);
                                    data.Scroll.MP = (byte)Convert.ChangeType(reader2["imp"], TypeCode.Byte);
                                    data.Scroll.WeaponAttack = (byte)Convert.ChangeType(reader2["iwatk"], TypeCode.Byte);
                                    data.Scroll.MagicAttack = (byte)Convert.ChangeType(reader2["imatk"], TypeCode.Byte);
                                    data.Scroll.WeaponDefense = (byte)Convert.ChangeType(reader2["iwdef"], TypeCode.Byte);
                                    data.Scroll.MagicDefense = (byte)Convert.ChangeType(reader2["imdef"], TypeCode.Byte);
                                    data.Scroll.Accuracy = (byte)Convert.ChangeType(reader2["iacc"], TypeCode.Byte);
                                    data.Scroll.Avoidance = (byte)Convert.ChangeType(reader2["iavo"], TypeCode.Byte);
                                    data.Scroll.Speed = (byte)Convert.ChangeType(reader2["ispeed"], TypeCode.Byte);
                                    data.Scroll.Jump = (byte)Convert.ChangeType(reader2["ijump"], TypeCode.Byte);
                                    data.Scroll.Targets = new List<int>();
                                    using (MySqlConnection connection3 = new MySqlConnection(Program.Database))
                                    {
                                        connection3.Open();
                                        MySqlCommand command3 = connection3.CreateCommand();
                                        command3.CommandText = "SELECT * FROM item_scroll_targets WHERE scrollid=@scrollid ORDER BY id ASC";
                                        command3.Parameters.AddWithValue("@scrollid", data.Identifier);
                                        using (MySqlDataReader reader3 = command3.ExecuteReader())
                                        {
                                            while (reader3.Read()) data.Scroll.Targets.Add((int)Convert.ChangeType(reader3["req_itemid"], TypeCode.Int32));
                                        }
                                    }
                                }
                            }
                        }
                        data.Morphs = new List<ItemData.ItemMorphData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM item_random_morphs WHERE itemid=@itemid ORDER BY morphid ASC";
                            command2.Parameters.AddWithValue("@itemid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    ItemData.ItemMorphData morphData = new ItemData.ItemMorphData();
                                    morphData.Morph = (byte)Convert.ChangeType(reader2["morphid"], TypeCode.Byte);
                                    morphData.Success = (byte)Convert.ChangeType(reader2["success"], TypeCode.Byte);

                                    data.Morphs.Add(morphData);
                                }
                            }
                        }
                        data.Skills = new List<ItemData.ItemSkillData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM item_skills WHERE itemid=@itemid ORDER BY skillid ASC";
                            command2.Parameters.AddWithValue("@itemid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    ItemData.ItemSkillData skillData = new ItemData.ItemSkillData();
                                    skillData.SkillIdentifier = (int)Convert.ChangeType(reader2["skillid"], TypeCode.Int32);
                                    skillData.SkillLevel = (byte)Convert.ChangeType(reader2["required_skill_level"], TypeCode.Byte);
                                    skillData.MasterSkillLevel = (byte)Convert.ChangeType(reader2["master_level"], TypeCode.Byte);

                                    data.Skills.Add(skillData);
                                }
                            }
                        }
                        data.Summons = new List<ItemData.ItemSummonData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM item_summons WHERE itemid=@itemid ORDER BY id ASC";
                            command2.Parameters.AddWithValue("@itemid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    ItemData.ItemSummonData summonData = new ItemData.ItemSummonData();
                                    summonData.MobIdentifier = (int)Convert.ChangeType(reader2["mobid"], TypeCode.Int32);
                                    summonData.Chance = (byte)Convert.ChangeType(reader2["chance"], TypeCode.Byte);

                                    data.Summons.Add(summonData);
                                }
                            }
                        }

                        datas.Add(data);
                        ++dataCount;
                        ++Program.AllDataCounter;
                        Program.IncrementCounter();
                    }
                }
            }

            pWriter.Write(datas.Count);
            datas.ForEach(d => d.Save(pWriter));

            timer.Pause();
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", "ItemData", dataCount, timer.Duration);
        }
        public static void Export(BinaryWriter pWriter)
        {
            PerformanceTimer timer = new PerformanceTimer();
            long dataCount = 0;
            timer.Unpause();

            List<QuestData> datas = new List<QuestData>();
            using (MySqlConnection connection1 = new MySqlConnection(Program.Database))
            {
                connection1.Open();
                MySqlCommand command1 = connection1.CreateCommand();
                command1.CommandText = "SELECT COUNT(*) FROM quest_data";
                Program.ResetCounter((int)(long)command1.ExecuteScalar());
                command1.CommandText = "SELECT * FROM quest_data ORDER BY questid ASC";
                using (MySqlDataReader reader1 = command1.ExecuteReader())
                {
                    while (reader1.Read())
                    {
                        QuestData data = new QuestData();
                        data.Identifier = (ushort)Convert.ChangeType(reader1["questid"], TypeCode.UInt16);
                        data.NextIdentifier = (ushort)Convert.ChangeType(reader1["next_quest"], TypeCode.UInt16);
                        data.Area = (byte)Convert.ChangeType(reader1["quest_area"], TypeCode.Byte);
                        data.MinLevel = (byte)Convert.ChangeType(reader1["min_level"], TypeCode.Byte);
                        data.MaxLevel = (byte)Convert.ChangeType(reader1["max_level"], TypeCode.Byte);
                        data.PetCloseness = (ushort)Convert.ChangeType(reader1["pet_closeness"], TypeCode.UInt16);
                        data.TamingMobLevel = (byte)Convert.ChangeType(reader1["taming_mob_level"], TypeCode.Byte);
                        data.RepeatWait = (int)Convert.ChangeType(reader1["repeat_wait"], TypeCode.Int32);
                        data.Fame = (ushort)Convert.ChangeType(reader1["fame"], TypeCode.UInt16);
                        data.Jobs = new List<ushort>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM quest_required_jobs WHERE questid=@questid ORDER BY valid_jobid ASC";
                            command2.Parameters.AddWithValue("@questid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    data.Jobs.Add((ushort)Convert.ChangeType(reader2["valid_jobid"], TypeCode.UInt16));
                                }
                            }
                        }
                        data.Requirements = new List<QuestData.QuestRequirementData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM quest_requests WHERE questid=@questid ORDER BY quest_state+0 ASC,request_type+0 ASC";
                            command2.Parameters.AddWithValue("@questid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    QuestData.QuestRequirementData requirementData = new QuestData.QuestRequirementData();
                                    requirementData.State = (QuestData.QuestRequirementData.EQuestRequirementState)Enum.Parse(typeof(QuestData.QuestRequirementData.EQuestRequirementState), (string)Convert.ChangeType(reader2["quest_state"], TypeCode.String), true);
                                    requirementData.Type = (QuestData.QuestRequirementData.EQuestRequirementType)Enum.Parse(typeof(QuestData.QuestRequirementData.EQuestRequirementType), (string)Convert.ChangeType(reader2["request_type"], TypeCode.String), true);
                                    requirementData.Parameter1 = (int)Convert.ChangeType(reader2["objectid"], TypeCode.Int32);
                                    requirementData.Parameter2 = (int)Convert.ChangeType(reader2["count"], TypeCode.Int32);

                                    data.Requirements.Add(requirementData);
                                }
                            }
                        }
                        data.Rewards = new List<QuestData.QuestRewardData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM quest_rewards WHERE questid=@questid ORDER BY quest_state+0 ASC,reward_type+0 ASC";
                            command2.Parameters.AddWithValue("@questid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    QuestData.QuestRewardData rewardData = new QuestData.QuestRewardData();
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") rewardData.Flags = (QuestData.QuestRewardData.EQuestRewardFlags)Enum.Parse(typeof(QuestData.QuestRewardData.EQuestRewardFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    rewardData.State = (QuestData.QuestRewardData.EQuestRewardState)Enum.Parse(typeof(QuestData.QuestRewardData.EQuestRewardState), (string)Convert.ChangeType(reader2["quest_state"], TypeCode.String), true);
                                    rewardData.Type = (QuestData.QuestRewardData.EQuestRewardType)Enum.Parse(typeof(QuestData.QuestRewardData.EQuestRewardType), (string)Convert.ChangeType(reader2["reward_type"], TypeCode.String), true);
                                    rewardData.Parameter1 = (int)Convert.ChangeType(reader2["rewardid"], TypeCode.Int32);
                                    rewardData.Parameter2 = (int)Convert.ChangeType(reader2["count"], TypeCode.Int32);
                                    rewardData.MasterLevel = (byte)Convert.ChangeType(reader2["master_level"], TypeCode.Byte);
                                    rewardData.Gender = (QuestData.QuestRewardData.EQuestRewardGender)Enum.Parse(typeof(QuestData.QuestRewardData.EQuestRewardGender), (string)Convert.ChangeType(reader2["gender"], TypeCode.String), true);
                                    if ((string)Convert.ChangeType(reader2["job_tracks"], TypeCode.String) != "") rewardData.Tracks = (QuestData.QuestRewardData.EQuestRewardTracks)Enum.Parse(typeof(QuestData.QuestRewardData.EQuestRewardTracks), (string)Convert.ChangeType(reader2["job_tracks"], TypeCode.String), true);
                                    rewardData.Job = (short)Convert.ChangeType(reader2["job"], TypeCode.Int16);
                                    rewardData.Prop = (int)Convert.ChangeType(reader2["prop"], TypeCode.Int32);

                                    data.Rewards.Add(rewardData);
                                }
                            }
                        }

                        datas.Add(data);
                        ++dataCount;
                        ++Program.AllDataCounter;
                        Program.IncrementCounter();
                    }
                }
            }

            pWriter.Write(datas.Count);
            datas.ForEach(d => d.Save(pWriter));

            timer.Pause();
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", "QuestData", dataCount, timer.Duration);
        }
        public static void Export(BinaryWriter pWriter)
        {
            PerformanceTimer timer = new PerformanceTimer();
            long dataCount = 0;
            timer.Unpause();

            List<MobData> datas = new List<MobData>();
            using (MySqlConnection connection1 = new MySqlConnection(Program.Database))
            {
                connection1.Open();
                MySqlCommand command1 = connection1.CreateCommand();
                command1.CommandText = "SELECT COUNT(*) FROM mob_data";
                Program.ResetCounter((int)(long)command1.ExecuteScalar());
                command1.CommandText = "SELECT * FROM mob_data ORDER BY mobid ASC";
                using (MySqlDataReader reader1 = command1.ExecuteReader())
                {
                    while (reader1.Read())
                    {
                        MobData data = new MobData();
                        data.Identifier = (int)Convert.ChangeType(reader1["mobid"], TypeCode.Int32);
                        if ((string)Convert.ChangeType(reader1["flags"], TypeCode.String) != "") data.Flags = (MobData.EMobFlags)Enum.Parse(typeof(MobData.EMobFlags), (string)Convert.ChangeType(reader1["flags"], TypeCode.String), true);
                        data.Level = (byte)(ushort)Convert.ChangeType(reader1["level"], TypeCode.UInt16);
                        data.HP = (int)Convert.ChangeType(reader1["hp"], TypeCode.Int32);
                        data.MP = (int)Convert.ChangeType(reader1["mp"], TypeCode.Int32);
                        data.HPRecovery = (int)Convert.ChangeType(reader1["hp_recovery"], TypeCode.Int32);
                        data.MPRecovery = (ushort)Convert.ChangeType(reader1["mp_recovery"], TypeCode.UInt16);
                        data.ExplodeHP = (int)Convert.ChangeType(reader1["explode_hp"], TypeCode.Int32);
                        data.Experience = (int)Convert.ChangeType(reader1["exp"], TypeCode.Int32);
                        data.LinkIdentifier = (int)Convert.ChangeType(reader1["link"], TypeCode.Int32);
                        data.SummonType = (byte)Convert.ChangeType(reader1["summon_type"], TypeCode.Byte);
                        data.Knockback = (int)Convert.ChangeType(reader1["knockback"], TypeCode.Int32);
                        data.FixedDamage = (ushort)Convert.ChangeType(reader1["fixed_damage"], TypeCode.UInt16);
                        data.DeathBuffIdentifier = (int)Convert.ChangeType(reader1["death_buff"], TypeCode.Int32);
                        data.DeathAfter = (int)Convert.ChangeType(reader1["death_after"], TypeCode.Int32);
                        data.Traction = (byte)Convert.ChangeType(reader1["traction"], TypeCode.Byte);
                        data.DamagedBySkillIdentifierOnly = (int)Convert.ChangeType(reader1["damaged_by_skill_only"], TypeCode.Int32);
                        data.DamagedByMobIdentifierOnly = (int)Convert.ChangeType(reader1["damaged_by_mob_only"], TypeCode.Int32);
                        data.HPBarColor = (byte)Convert.ChangeType(reader1["hp_bar_color"], TypeCode.Byte);
                        data.HPBarBackgroundColor = (byte)Convert.ChangeType(reader1["hp_bar_bg_color"], TypeCode.Byte);
                        data.CarnivalPoints = (byte)Convert.ChangeType(reader1["carnival_points"], TypeCode.Byte);
                        data.PhysicalAttack = (ushort)Convert.ChangeType(reader1["physical_attack"], TypeCode.UInt16);
                        data.PhysicalDefense = (ushort)Convert.ChangeType(reader1["physical_defense"], TypeCode.UInt16);
                        data.MagicalAttack = (ushort)Convert.ChangeType(reader1["magical_attack"], TypeCode.UInt16);
                        data.MagicalDefense = (ushort)Convert.ChangeType(reader1["magical_defense"], TypeCode.UInt16);
                        data.Accuracy = (short)Convert.ChangeType(reader1["accuracy"], TypeCode.Int16);
                        data.Avoidance = (ushort)Convert.ChangeType(reader1["avoidability"], TypeCode.UInt16);
                        data.Speed = (short)Convert.ChangeType(reader1["speed"], TypeCode.Int16);
                        data.ChaseSpeed = (short)Convert.ChangeType(reader1["chase_speed"], TypeCode.Int16);
                        data.IceModifier = (MobData.EMobMagicModifier)Enum.Parse(typeof(MobData.EMobMagicModifier), (string)Convert.ChangeType(reader1["ice_modifier"], TypeCode.String), true);
                        data.FireModifier = (MobData.EMobMagicModifier)Enum.Parse(typeof(MobData.EMobMagicModifier), (string)Convert.ChangeType(reader1["fire_modifier"], TypeCode.String), true);
                        data.PoisonModifier = (MobData.EMobMagicModifier)Enum.Parse(typeof(MobData.EMobMagicModifier), (string)Convert.ChangeType(reader1["poison_modifier"], TypeCode.String), true);
                        data.LightningModifier = (MobData.EMobMagicModifier)Enum.Parse(typeof(MobData.EMobMagicModifier), (string)Convert.ChangeType(reader1["lightning_modifier"], TypeCode.String), true);
                        data.HolyModifier = (MobData.EMobMagicModifier)Enum.Parse(typeof(MobData.EMobMagicModifier), (string)Convert.ChangeType(reader1["holy_modifier"], TypeCode.String), true);
                        data.NonElementalModifier = (MobData.EMobMagicModifier)Enum.Parse(typeof(MobData.EMobMagicModifier), (string)Convert.ChangeType(reader1["nonelemental_modifier"], TypeCode.String), true);
                        data.Abilities = new List<MobData.MobAbilityData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM mob_skills WHERE mobid=@mobid ORDER BY skillid ASC,level ASC";
                            command2.Parameters.AddWithValue("@mobid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    MobData.MobAbilityData abilityData = new MobData.MobAbilityData();
                                    abilityData.AbilityIdentifier = (byte)Convert.ChangeType(reader2["skillid"], TypeCode.Byte);
                                    abilityData.AbilityLevel = (byte)Convert.ChangeType(reader2["level"], TypeCode.Byte);
                                    abilityData.EffectDelay = (ushort)Convert.ChangeType(reader2["effect_delay"], TypeCode.UInt16);

                                    data.Abilities.Add(abilityData);
                                }
                            }
                        }
                        data.Attacks = new List<MobData.MobAttackData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM mob_attacks WHERE mobid=@mobid ORDER BY attackid ASC";
                            command2.Parameters.AddWithValue("@mobid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    MobData.MobAttackData attackData = new MobData.MobAttackData();
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") attackData.Flags = (MobData.MobAttackData.EMobAttackFlags)Enum.Parse(typeof(MobData.MobAttackData.EMobAttackFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    attackData.MPCost = (byte)Convert.ChangeType(reader2["mp_cost"], TypeCode.Byte);
                                    attackData.MPBurn = (ushort)Convert.ChangeType(reader2["mp_burn"], TypeCode.UInt16);
                                    attackData.AbilityIdentifier = (byte)Convert.ChangeType(reader2["disease"], TypeCode.Byte);
                                    attackData.AbilityLevel = (byte)Convert.ChangeType(reader2["level"], TypeCode.Byte);

                                    data.Attacks.Add(attackData);
                                }
                            }
                        }
                        data.Summons = new List<int>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM mob_summons WHERE mobid=@mobid ORDER BY id ASC";
                            command2.Parameters.AddWithValue("@mobid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    data.Summons.Add((int)Convert.ChangeType(reader2["summonid"], TypeCode.Int32));
                                }
                            }
                        }
                        data.Drops = new List<MobData.MobDropData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM drop_data WHERE dropperid=@dropperid ORDER BY id ASC";
                            command2.Parameters.AddWithValue("@dropperid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    MobData.MobDropData dropData = new MobData.MobDropData();
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") dropData.Flags = (MobData.MobDropData.EMobDropFlags)Enum.Parse(typeof(MobData.MobDropData.EMobDropFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    dropData.ItemIdentifier = (int)Convert.ChangeType(reader2["itemid"], TypeCode.Int32);
                                    dropData.Minimum = (int)Convert.ChangeType(reader2["minimum_quantity"], TypeCode.Int32);
                                    dropData.Maximum = (int)Convert.ChangeType(reader2["maximum_quantity"], TypeCode.Int32);
                                    dropData.QuestIdentifier = (ushort)Convert.ChangeType(reader2["questid"], TypeCode.UInt16);
                                    dropData.Chance = (int)Convert.ChangeType(reader2["chance"], TypeCode.Int32);

                                    data.Drops.Add(dropData);
                                }
                            }
                        }

                        datas.Add(data);
                        ++dataCount;
                        ++Program.AllDataCounter;
                        Program.IncrementCounter();
                    }
                }
            }

            pWriter.Write(datas.Count);
            datas.ForEach(d => d.Save(pWriter));

            timer.Pause();
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", "MobData", dataCount, timer.Duration);
        }
        public static void Export(BinaryWriter pWriter)
        {
            PerformanceTimer timer = new PerformanceTimer();
            long dataCount = 0;
            timer.Unpause();

            List<ReactorData> datas = new List<ReactorData>();
            using (MySqlConnection connection1 = new MySqlConnection(Program.Database))
            {
                connection1.Open();
                MySqlCommand command1 = connection1.CreateCommand();
                command1.CommandText = "SELECT COUNT(*) FROM reactor_data";
                Program.ResetCounter((int)(long)command1.ExecuteScalar());
                command1.CommandText = "SELECT * FROM reactor_data ORDER BY reactorid ASC";
                using (MySqlDataReader reader1 = command1.ExecuteReader())
                {
                    while (reader1.Read())
                    {
                        ReactorData data = new ReactorData();
                        data.Identifier = (int)Convert.ChangeType(reader1["reactorid"], TypeCode.Int32);
                        if ((string)Convert.ChangeType(reader1["flags"], TypeCode.String) != "") data.Flags = (ReactorData.EReactorFlags)Enum.Parse(typeof(ReactorData.EReactorFlags), (string)Convert.ChangeType(reader1["flags"], TypeCode.String), true);
                        data.LinkIdentifier = (int)Convert.ChangeType(reader1["link"], TypeCode.Int32);
                        data.States = new List<ReactorData.ReactorStateData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM reactor_events WHERE reactorid=@reactorid ORDER BY state ASC";
                            command2.Parameters.AddWithValue("@reactorid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    ReactorData.ReactorStateData stateData = new ReactorData.ReactorStateData();
                                    stateData.State = (byte)Convert.ChangeType(reader2["state"], TypeCode.Byte);
                                    stateData.Type = (ReactorData.ReactorStateData.EReactorStateType)Enum.Parse(typeof(ReactorData.ReactorStateData.EReactorStateType), (string)Convert.ChangeType(reader2["type"], TypeCode.String), true);
                                    stateData.Timeout = (int)Convert.ChangeType(reader2["timeout"], TypeCode.Int32);
                                    stateData.ItemIdentifier = (int)Convert.ChangeType(reader2["itemid"], TypeCode.Int32);
                                    stateData.Quantity = (byte)Convert.ChangeType(reader2["quantity"], TypeCode.Byte);
                                    stateData.LeftTopX = (short)Convert.ChangeType(reader2["ltx"], TypeCode.Int16);
                                    stateData.LeftTopY = (short)Convert.ChangeType(reader2["lty"], TypeCode.Int16);
                                    stateData.RightBottomX = (short)Convert.ChangeType(reader2["rbx"], TypeCode.Int16);
                                    stateData.RightBottomY = (short)Convert.ChangeType(reader2["rby"], TypeCode.Int16);

                                    data.States.Add(stateData);
                                }
                            }
                        }
                        data.Drops = new List<ReactorData.ReactorDropData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM drop_data WHERE dropperid=@dropperid ORDER BY id ASC";
                            command2.Parameters.AddWithValue("@dropperid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    ReactorData.ReactorDropData dropData = new ReactorData.ReactorDropData();
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") dropData.Flags = (ReactorData.ReactorDropData.EReactorDropFlags)Enum.Parse(typeof(ReactorData.ReactorDropData.EReactorDropFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    dropData.ItemIdentifier = (int)Convert.ChangeType(reader2["itemid"], TypeCode.Int32);
                                    dropData.Minimum = (int)Convert.ChangeType(reader2["minimum_quantity"], TypeCode.Int32);
                                    dropData.Maximum = (int)Convert.ChangeType(reader2["maximum_quantity"], TypeCode.Int32);
                                    dropData.QuestIdentifier = (ushort)Convert.ChangeType(reader2["questid"], TypeCode.UInt16);
                                    dropData.Chance = (int)Convert.ChangeType(reader2["chance"], TypeCode.Int32);

                                    data.Drops.Add(dropData);
                                }
                            }
                        }

                        datas.Add(data);
                        ++dataCount;
                        ++Program.AllDataCounter;
                        Program.IncrementCounter();
                    }
                }
            }

            pWriter.Write(datas.Count);
            datas.ForEach(d => d.Save(pWriter));

            timer.Pause();
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", "ReactorData", dataCount, timer.Duration);
        }
        public static void Export(BinaryWriter pWriter)
        {
            PerformanceTimer timer = new PerformanceTimer();
            long dataCount = 0;
            timer.Unpause();

            List<SkillData> datas = new List<SkillData>();
            using (MySqlConnection connection1 = new MySqlConnection(Program.Database))
            {
                connection1.Open();
                MySqlCommand command1 = connection1.CreateCommand();
                command1.CommandText = "SELECT COUNT(*) FROM skill_player_data";
                Program.ResetCounter((int)(long)command1.ExecuteScalar());
                command1.CommandText = "SELECT * FROM skill_player_data ORDER BY skillid ASC,level ASC";
                using (MySqlDataReader reader1 = command1.ExecuteReader())
                {
                    while (reader1.Read())
                    {
                        SkillData data = new SkillData();
                        data.Identifier = (int)Convert.ChangeType(reader1["skillid"], TypeCode.Int32);
                        data.Level = (byte)Convert.ChangeType(reader1["level"], TypeCode.Byte);
                        data.MobCount = (byte)Convert.ChangeType(reader1["mob_count"], TypeCode.Byte);
                        data.HitCount = (byte)Convert.ChangeType(reader1["hit_count"], TypeCode.Byte);
                        data.Range = (ushort)Convert.ChangeType(reader1["range"], TypeCode.UInt16);
                        data.Duration = (int)Convert.ChangeType(reader1["time"], TypeCode.Int32);
                        data.MPCost = (ushort)Convert.ChangeType(reader1["mp_cost"], TypeCode.UInt16);
                        data.HPCost = (byte)Convert.ChangeType(reader1["hp_cost"], TypeCode.Byte);
                        data.Damage = (ushort)Convert.ChangeType(reader1["damage"], TypeCode.UInt16);
                        data.FixedDamage = (byte)Convert.ChangeType(reader1["fixed_damage"], TypeCode.Byte);
                        data.CriticalDamage = (byte)Convert.ChangeType(reader1["critical_damage"], TypeCode.Byte);
                        data.Mastery = (byte)Convert.ChangeType(reader1["mastery"], TypeCode.Byte);
                        data.OptionalItemCost = (int)Convert.ChangeType(reader1["optional_item_cost"], TypeCode.Int32);
                        data.ItemCost = (int)Convert.ChangeType(reader1["item_cost"], TypeCode.Int32);
                        data.ItemCount = (byte)Convert.ChangeType(reader1["item_count"], TypeCode.Byte);
                        data.BulletCost = (byte)Convert.ChangeType(reader1["bullet_cost"], TypeCode.Byte);
                        data.MoneyCost = (ushort)Convert.ChangeType(reader1["money_cost"], TypeCode.UInt16);
                        data.Parameter1 = (int)Convert.ChangeType(reader1["x"], TypeCode.Int32);
                        data.Parameter2 = (int)Convert.ChangeType(reader1["y"], TypeCode.Int32);
                        data.Speed = (short)Convert.ChangeType(reader1["speed"], TypeCode.Int16);
                        data.Jump = (byte)Convert.ChangeType(reader1["jump"], TypeCode.Byte);
                        data.Strength = (byte)Convert.ChangeType(reader1["str"], TypeCode.Byte);
                        data.WeaponAttack = (short)Convert.ChangeType(reader1["weapon_atk"], TypeCode.Int16);
                        data.WeaponDefense = (short)Convert.ChangeType(reader1["weapon_def"], TypeCode.Int16);
                        data.MagicAttack = (short)Convert.ChangeType(reader1["magic_atk"], TypeCode.Int16);
                        data.MagicDefense = (short)Convert.ChangeType(reader1["magic_def"], TypeCode.Int16);
                        data.Accuracy = (byte)Convert.ChangeType(reader1["accuracy"], TypeCode.Byte);
                        data.Avoidance = (byte)Convert.ChangeType(reader1["avoid"], TypeCode.Byte);
                        data.HP = (ushort)Convert.ChangeType(reader1["hp"], TypeCode.UInt16);
                        data.MP = (byte)Convert.ChangeType(reader1["mp"], TypeCode.Byte);
                        data.Prop = (byte)Convert.ChangeType(reader1["prop"], TypeCode.Byte);
                        data.Morph = (ushort)Convert.ChangeType(reader1["morph"], TypeCode.UInt16);
                        data.LeftTopX = (short)Convert.ChangeType(reader1["ltx"], TypeCode.Int16);
                        data.LeftTopY = (short)Convert.ChangeType(reader1["lty"], TypeCode.Int16);
                        data.RightBottomX = (short)Convert.ChangeType(reader1["rbx"], TypeCode.Int16);
                        data.RightBottomY = (short)Convert.ChangeType(reader1["rby"], TypeCode.Int16);
                        data.Cooldown = (ushort)Convert.ChangeType(reader1["cooldown_time"], TypeCode.UInt16);

                        datas.Add(data);
                        ++dataCount;
                        ++Program.AllDataCounter;
                        Program.IncrementCounter();
                    }
                }
            }

            pWriter.Write(datas.Count);
            datas.ForEach(d => d.Save(pWriter));

            timer.Pause();
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", "SkillData", dataCount, timer.Duration);
        }
        public static void Export(BinaryWriter pWriter)
        {
            PerformanceTimer timer = new PerformanceTimer();
            long dataCount = 0;
            timer.Unpause();

            List<MapData> datas = new List<MapData>();
            using (MySqlConnection connection1 = new MySqlConnection(Program.Database))
            {
                connection1.Open();
                MySqlCommand command1 = connection1.CreateCommand();
                command1.CommandText = "SELECT COUNT(*) FROM map_data";
                Program.ResetCounter((int)(long)command1.ExecuteScalar());
                command1.CommandText = "SELECT * FROM map_data ORDER BY mapid ASC";
                using (MySqlDataReader reader1 = command1.ExecuteReader())
                {
                    while (reader1.Read())
                    {
                        MapData data = new MapData();
                        data.Identifier = (int)Convert.ChangeType(reader1["mapid"], TypeCode.Int32);
                        if ((string)Convert.ChangeType(reader1["flags"], TypeCode.String) != "") data.Flags = (MapData.EMapFlags)Enum.Parse(typeof(MapData.EMapFlags), (string)Convert.ChangeType(reader1["flags"], TypeCode.String), true);
                        data.ShuffleName = (string)Convert.ChangeType(reader1["shuffle_name"], TypeCode.String);
                        data.Music = (string)Convert.ChangeType(reader1["default_bgm"], TypeCode.String);
                        data.MinLevelLimit = (byte)Convert.ChangeType(reader1["min_level_limit"], TypeCode.Byte);
                        data.TimeLimit = (ushort)Convert.ChangeType(reader1["time_limit"], TypeCode.UInt16);
                        data.RegenRate = (byte)Convert.ChangeType(reader1["regen_rate"], TypeCode.Byte);
                        data.Traction = (float)Convert.ChangeType(reader1["default_traction"], TypeCode.Single);
                        data.LeftTopX = (short)Convert.ChangeType(reader1["map_ltx"], TypeCode.Int16);
                        data.LeftTopY = (short)Convert.ChangeType(reader1["map_lty"], TypeCode.Int16);
                        data.RightBottomX = (short)Convert.ChangeType(reader1["map_rbx"], TypeCode.Int16);
                        data.RightBottomY = (short)Convert.ChangeType(reader1["map_rby"], TypeCode.Int16);
                        data.ReturnMapIdentifier = (int)Convert.ChangeType(reader1["return_map"], TypeCode.Int32);
                        data.ForcedReturnMapIdentifier = (int)Convert.ChangeType(reader1["forced_return_map"], TypeCode.Int32);
                        if ((string)Convert.ChangeType(reader1["field_type"], TypeCode.String) != "") data.FieldTypes = (MapData.EMapFieldType)Enum.Parse(typeof(MapData.EMapFieldType), (string)Convert.ChangeType(reader1["field_type"], TypeCode.String), true);
                        if ((string)Convert.ChangeType(reader1["field_limitations"], TypeCode.String) != "") data.FieldLimits = (MapData.EMapFieldLimit)Enum.Parse(typeof(MapData.EMapFieldLimit), (string)Convert.ChangeType(reader1["field_limitations"], TypeCode.String), true);
                        data.DecreaseHP = (byte)Convert.ChangeType(reader1["decrease_hp"], TypeCode.Byte);
                        data.DamagePerSecond = (ushort)Convert.ChangeType(reader1["damage_per_second"], TypeCode.UInt16);
                        data.ProtectItemIdentifier = (int)Convert.ChangeType(reader1["protect_item"], TypeCode.Int32);
                        data.MobRate = (float)Convert.ChangeType(reader1["mob_rate"], TypeCode.Single);
                        data.LinkIdentifier = (int)Convert.ChangeType(reader1["link"], TypeCode.Int32);
                        data.Footholds = new List<MapData.MapFootholdData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM map_footholds WHERE mapid=@mapid ORDER BY id ASC";
                            command2.Parameters.AddWithValue("@mapid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    MapData.MapFootholdData footholdData = new MapData.MapFootholdData();
                                    footholdData.Identifier = (ushort)Convert.ChangeType(reader2["id"], TypeCode.UInt16);
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") footholdData.Flags = (MapData.MapFootholdData.EMapFootholdFlags)Enum.Parse(typeof(MapData.MapFootholdData.EMapFootholdFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    footholdData.PreviousIdentifier = (ushort)Convert.ChangeType(reader2["prev"], TypeCode.UInt16);
                                    footholdData.NextIdentifier = (ushort)Convert.ChangeType(reader2["next"], TypeCode.UInt16);
                                    footholdData.DragForce = (short)Convert.ChangeType(reader2["drag_force"], TypeCode.Int16);
                                    footholdData.X1 = (short)Convert.ChangeType(reader2["x1"], TypeCode.Int16);
                                    footholdData.Y1 = (short)Convert.ChangeType(reader2["y1"], TypeCode.Int16);
                                    footholdData.X2 = (short)Convert.ChangeType(reader2["x2"], TypeCode.Int16);
                                    footholdData.Y2 = (short)Convert.ChangeType(reader2["y2"], TypeCode.Int16);

                                    data.Footholds.Add(footholdData);
                                }
                            }
                        }
                        data.NPCs = new List<MapData.MapNPCData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM map_life WHERE mapid=@mapid AND life_type='npc' ORDER BY id ASC";
                            command2.Parameters.AddWithValue("@mapid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    MapData.MapNPCData npcData = new MapData.MapNPCData();
                                    npcData.NPCIdentifier = (int)Convert.ChangeType(reader2["lifeid"], TypeCode.Int32);
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") npcData.Flags = (MapData.MapNPCData.EMapNPCFlags)Enum.Parse(typeof(MapData.MapNPCData.EMapNPCFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    npcData.Foothold = (ushort)Convert.ChangeType(reader2["foothold"], TypeCode.UInt16);
                                    npcData.X = (short)Convert.ChangeType(reader2["x"], TypeCode.Int16);
                                    npcData.Y = (short)Convert.ChangeType(reader2["y"], TypeCode.Int16);
                                    npcData.MinClickX = (short)Convert.ChangeType(reader2["min_click_pos"], TypeCode.Int16);
                                    npcData.MaxClickX = (short)Convert.ChangeType(reader2["max_click_pos"], TypeCode.Int16);

                                    data.NPCs.Add(npcData);
                                }
                            }
                        }
                        data.Reactors = new List<MapData.MapReactorData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM map_life WHERE mapid=@mapid AND life_type='reactor' ORDER BY id ASC";
                            command2.Parameters.AddWithValue("@mapid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    MapData.MapReactorData reactorData = new MapData.MapReactorData();
                                    reactorData.ReactorIdentifier = (int)Convert.ChangeType(reader2["lifeid"], TypeCode.Int32);
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") reactorData.Flags = (MapData.MapReactorData.EMapReactorFlags)Enum.Parse(typeof(MapData.MapReactorData.EMapReactorFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    reactorData.Foothold = (ushort)Convert.ChangeType(reader2["foothold"], TypeCode.UInt16);
                                    reactorData.X = (short)Convert.ChangeType(reader2["x"], TypeCode.Int16);
                                    reactorData.Y = (short)Convert.ChangeType(reader2["y"], TypeCode.Int16);
                                    reactorData.MinClickX = (short)Convert.ChangeType(reader2["min_click_pos"], TypeCode.Int16);
                                    reactorData.MaxClickX = (short)Convert.ChangeType(reader2["max_click_pos"], TypeCode.Int16);
                                    reactorData.RespawnTime = (int)Convert.ChangeType(reader2["respawn_time"], TypeCode.Int32);
                                    reactorData.Name = (string)Convert.ChangeType(reader2["name"], TypeCode.String);

                                    data.Reactors.Add(reactorData);
                                }
                            }
                        }
                        data.Mobs = new List<MapData.MapMobData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM map_life WHERE mapid=@mapid AND life_type='mob' ORDER BY id ASC";
                            command2.Parameters.AddWithValue("@mapid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    MapData.MapMobData mobData = new MapData.MapMobData();
                                    mobData.MobIdentifier = (int)Convert.ChangeType(reader2["lifeid"], TypeCode.Int32);
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") mobData.Flags = (MapData.MapMobData.EMapMobFlags)Enum.Parse(typeof(MapData.MapMobData.EMapMobFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    mobData.Foothold = (ushort)Convert.ChangeType(reader2["foothold"], TypeCode.UInt16);
                                    mobData.X = (short)Convert.ChangeType(reader2["x"], TypeCode.Int16);
                                    mobData.Y = (short)Convert.ChangeType(reader2["y"], TypeCode.Int16);
                                    mobData.MinClickX = (short)Convert.ChangeType(reader2["min_click_pos"], TypeCode.Int16);
                                    mobData.MaxClickX = (short)Convert.ChangeType(reader2["max_click_pos"], TypeCode.Int16);
                                    mobData.RespawnTime = (int)Convert.ChangeType(reader2["respawn_time"], TypeCode.Int32);
                                    mobData.Announcement = "";
                                    using (MySqlConnection connection3 = new MySqlConnection(Program.Database))
                                    {
                                        connection3.Open();
                                        MySqlCommand command3 = connection3.CreateCommand();
                                        command3.CommandText = "SELECT * FROM map_time_mob WHERE mapid=@mapid AND mobid=@mobid";
                                        command3.Parameters.AddWithValue("@mapid", data.Identifier);
                                        command3.Parameters.AddWithValue("@mobid", mobData.MobIdentifier);
                                        using (MySqlDataReader reader3 = command3.ExecuteReader())
                                        {
                                            if (reader3.Read())
                                            {
                                                mobData.StartHour = (byte)Convert.ChangeType(reader3["starthour"], TypeCode.Byte);
                                                mobData.EndHour = (byte)Convert.ChangeType(reader3["endhour"], TypeCode.Byte);
                                                mobData.Announcement = (string)Convert.ChangeType(reader3["message"], TypeCode.String);
                                            }
                                        }
                                    }

                                    data.Mobs.Add(mobData);
                                }
                            }
                        }
                        data.Portals = new List<MapData.MapPortalData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM map_portals WHERE mapid=@mapid ORDER BY id ASC";
                            command2.Parameters.AddWithValue("@mapid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    MapData.MapPortalData portalData = new MapData.MapPortalData();
                                    if ((string)Convert.ChangeType(reader2["flags"], TypeCode.String) != "") portalData.Flags = (MapData.MapPortalData.EMapPortalFlags)Enum.Parse(typeof(MapData.MapPortalData.EMapPortalFlags), (string)Convert.ChangeType(reader2["flags"], TypeCode.String), true);
                                    portalData.X = (short)Convert.ChangeType(reader2["x"], TypeCode.Int16);
                                    portalData.Y = (short)Convert.ChangeType(reader2["y"], TypeCode.Int16);
                                    portalData.Name = (string)Convert.ChangeType(reader2["name"], TypeCode.String);
                                    portalData.ToMapIdentifier = (int)Convert.ChangeType(reader2["tomap"], TypeCode.Int32);
                                    portalData.ToName = (string)Convert.ChangeType(reader2["toname"], TypeCode.String);
                                    portalData.Script = (string)Convert.ChangeType(reader2["script"], TypeCode.String);

                                    data.Portals.Add(portalData);
                                }
                            }
                        }
                        data.Seats = new List<MapData.MapSeatData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM map_seats WHERE mapid=@mapid ORDER BY seatid ASC";
                            command2.Parameters.AddWithValue("@mapid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    MapData.MapSeatData seatData = new MapData.MapSeatData();
                                    seatData.X = (short)Convert.ChangeType(reader2["x"], TypeCode.Int16);
                                    seatData.Y = (short)Convert.ChangeType(reader2["y"], TypeCode.Int16);

                                    data.Seats.Add(seatData);
                                }
                            }
                        }

                        datas.Add(data);
                        ++dataCount;
                        ++Program.AllDataCounter;
                        Program.IncrementCounter();
                    }
                }
            }

            pWriter.Write(datas.Count);
            datas.ForEach(d => d.Save(pWriter));

            timer.Pause();
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", "MapData", dataCount, timer.Duration);
        }
        public static void Export(BinaryWriter pWriter)
        {
            PerformanceTimer timer = new PerformanceTimer();
            long dataCount = 0;
            timer.Unpause();

            List<AbilityData> datas = new List<AbilityData>();
            using (MySqlConnection connection1 = new MySqlConnection(Program.Database))
            {
                connection1.Open();
                MySqlCommand command1 = connection1.CreateCommand();
                command1.CommandText = "SELECT COUNT(*) FROM skill_mob_data";
                Program.ResetCounter((int)(long)command1.ExecuteScalar());
                command1.CommandText = "SELECT * FROM skill_mob_data ORDER BY skillid ASC,level ASC";
                using (MySqlDataReader reader1 = command1.ExecuteReader())
                {
                    while (reader1.Read())
                    {
                        AbilityData data = new AbilityData();
                        data.Identifier = (byte)Convert.ChangeType(reader1["skillid"], TypeCode.Byte);
                        data.Level = (byte)Convert.ChangeType(reader1["level"], TypeCode.Byte);
                        data.Duration = (ushort)Convert.ChangeType(reader1["time"], TypeCode.UInt16);
                        data.MPCost = (byte)Convert.ChangeType(reader1["mp_cost"], TypeCode.Byte);
                        data.Parameter1 = (int)Convert.ChangeType(reader1["x"], TypeCode.Int32);
                        data.Parameter2 = (int)Convert.ChangeType(reader1["y"], TypeCode.Int32);
                        data.Chance = (byte)Convert.ChangeType(reader1["chance"], TypeCode.Byte);
                        data.TargetCount = (byte)Convert.ChangeType(reader1["target_count"], TypeCode.Byte);
                        data.Cooldown = (ushort)Convert.ChangeType(reader1["cooldown"], TypeCode.UInt16);
                        data.LeftTopX = (short)Convert.ChangeType(reader1["ltx"], TypeCode.Int16);
                        data.LeftTopY = (short)Convert.ChangeType(reader1["lty"], TypeCode.Int16);
                        data.RightBottomX = (short)Convert.ChangeType(reader1["rbx"], TypeCode.Int16);
                        data.RightBottomY = (short)Convert.ChangeType(reader1["rby"], TypeCode.Int16);
                        data.HPLimitPercent = (byte)Convert.ChangeType(reader1["hp_limit_percentage"], TypeCode.Byte);
                        data.SummonLimit = (ushort)Convert.ChangeType(reader1["summon_limit"], TypeCode.UInt16);
                        data.SummonEffect = (byte)Convert.ChangeType(reader1["summon_effect"], TypeCode.Byte);
                        data.SummonIdentifiers = new List<int>();
                        if (data.Identifier == 200)
                        {
                            using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                            {
                                connection2.Open();
                                MySqlCommand command2 = connection2.CreateCommand();
                                command2.CommandText = "SELECT * FROM skill_mob_summons WHERE level=@level ORDER BY `index` ASC";
                                command2.Parameters.AddWithValue("@level", data.Level);
                                using (MySqlDataReader reader2 = command2.ExecuteReader())
                                {
                                    while (reader2.Read())
                                    {
                                        data.SummonIdentifiers.Add((int)Convert.ChangeType(reader2["mobid"], TypeCode.Int32));
                                    }
                                }
                            }
                        }

                        datas.Add(data);
                        ++dataCount;
                        ++Program.AllDataCounter;
                        Program.IncrementCounter();
                    }
                }
            }

            pWriter.Write(datas.Count);
            datas.ForEach(d => d.Save(pWriter));

            timer.Pause();
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", "AbilityData", dataCount, timer.Duration);
        }
        public static void Export(BinaryWriter pWriter)
        {
            PerformanceTimer timer = new PerformanceTimer();
            long dataCount = 0;
            timer.Unpause();

            List<NPCData> datas = new List<NPCData>();
            using (MySqlConnection connection1 = new MySqlConnection(Program.Database))
            {
                connection1.Open();
                MySqlCommand command1 = connection1.CreateCommand();
                command1.CommandText = "SELECT COUNT(*) FROM npc_data";
                Program.ResetCounter((int)(long)command1.ExecuteScalar());
                command1.CommandText = "SELECT * FROM npc_data ORDER BY npcid ASC";
                using (MySqlDataReader reader1 = command1.ExecuteReader())
                {
                    while (reader1.Read())
                    {
                        NPCData data = new NPCData();
                        data.Identifier = (int)Convert.ChangeType(reader1["npcid"], TypeCode.Int32);
                        if ((string)Convert.ChangeType(reader1["flags"], TypeCode.String) != "") data.Flags = (NPCData.ENPCFlags)Enum.Parse(typeof(NPCData.ENPCFlags), (string)Convert.ChangeType(reader1["flags"], TypeCode.String), true);
                        data.StorageCost = (ushort)Convert.ChangeType(reader1["storage_cost"], TypeCode.UInt16);
                        data.Shops = new List<NPCData.NPCShopData>();
                        using (MySqlConnection connection2 = new MySqlConnection(Program.Database))
                        {
                            connection2.Open();
                            MySqlCommand command2 = connection2.CreateCommand();
                            command2.CommandText = "SELECT * FROM shop_data WHERE npcid=@npcid ORDER BY rechargetier ASC";
                            command2.Parameters.AddWithValue("@npcid", data.Identifier);
                            using (MySqlDataReader reader2 = command2.ExecuteReader())
                            {
                                while (reader2.Read())
                                {
                                    NPCData.NPCShopData shopData = new NPCData.NPCShopData();
                                    shopData.ShopIdentifier = (int)Convert.ChangeType(reader2["shopid"], TypeCode.Int32);
                                    shopData.RechargeTier = (byte)Convert.ChangeType(reader2["rechargetier"], TypeCode.Byte);
                                    shopData.Items = new List<NPCData.NPCShopData.NPCShopItemData>();
                                    using (MySqlConnection connection3 = new MySqlConnection(Program.Database))
                                    {
                                        connection3.Open();
                                        MySqlCommand command3 = connection3.CreateCommand();
                                        command3.CommandText = "SELECT * FROM shop_items WHERE shopid=@shopid ORDER BY sort ASC";
                                        command3.Parameters.AddWithValue("@shopid", shopData.ShopIdentifier);
                                        using (MySqlDataReader reader3 = command3.ExecuteReader())
                                        {
                                            while (reader3.Read())
                                            {
                                                NPCData.NPCShopData.NPCShopItemData itemData = new NPCData.NPCShopData.NPCShopItemData();
                                                itemData.ItemIdentifier = (int)Convert.ChangeType(reader3["itemid"], TypeCode.Int32);
                                                itemData.Quantity = (ushort)Convert.ChangeType(reader3["quantity"], TypeCode.UInt16);
                                                itemData.Price = (int)Convert.ChangeType(reader3["price"], TypeCode.Int32);
                                                using (MySqlConnection connection4 = new MySqlConnection(Program.Database))
                                                {
                                                    connection4.Open();
                                                    MySqlCommand command4 = connection4.CreateCommand();
                                                    command4.CommandText = "SELECT * FROM shop_recharge_data WHERE tierid=@tierid AND itemid=@itemid";
                                                    command4.Parameters.AddWithValue("@tierid", shopData.RechargeTier);
                                                    command4.Parameters.AddWithValue("@itemid", itemData.ItemIdentifier);
                                                    using (MySqlDataReader reader4 = command4.ExecuteReader())
                                                    {
                                                        if (reader4.Read())
                                                        {
                                                            itemData.RechargePrice = (float)Convert.ChangeType(reader4["price"], TypeCode.Single);
                                                        }
                                                    }
                                                }

                                                shopData.Items.Add(itemData);
                                            }
                                        }
                                    }

                                    data.Shops.Add(shopData);
                                }
                            }
                        }

                        datas.Add(data);
                        ++dataCount;
                        ++Program.AllDataCounter;
                        Program.IncrementCounter();
                    }
                }
            }

            pWriter.Write(datas.Count);
            datas.ForEach(d => d.Save(pWriter));

            timer.Pause();
            Console.WriteLine("| {0,-24} | {1,-16} | {2,-24} |", "NPCData", dataCount, timer.Duration);
        }