Exemple #1
0
        /// <summary>
        /// Checks if this character name is valid for a new character
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        internal static bool CheckCharacterName(string name)
        {
            bool valid = true;

            // Check for invalid characters
            if (name.IndexOfAny(Settings.ForbiddenCharacters) >= 0)
                return false;

            using (DBManager dbManager = new DBManager(Databases.User))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(1))
                {
                    dbManager.CreateInParameter(dbCmd, "name", System.Data.DbType.String, name);
                    dbManager.CreateInParameter(dbCmd, "now", System.Data.DbType.DateTime, DateTime.UtcNow);
                    try
                    {
                        dbCmd.Connection.Open();
                        using (DbDataReader reader = dbCmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                valid = false;
                            }
                        }
                    }
                    // When an error occurs, say that name exists to block creation
                    catch (Exception ex) { ConsoleUtils.ShowError(ex.Message); valid = false; }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            return valid;
        }
Exemple #2
0
        internal static void InsertItem(int charId, int itemCode, bool equip)
        {
            DB_Item item = Arcadia.ItemResource[itemCode];
            using (DBManager dbManager = new DBManager(Databases.User))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(21))
                {
                    dbManager.CreateInParameter(dbCmd, "owner_id", System.Data.DbType.Int64, charId);
                    dbManager.CreateInParameter(dbCmd, "idx", System.Data.DbType.Int32, 0);
                    dbManager.CreateInParameter(dbCmd, "code", System.Data.DbType.Int32, itemCode);
                    dbManager.CreateInParameter(dbCmd, "cnt", System.Data.DbType.Int64, 1);
                    dbManager.CreateInParameter(dbCmd, "level", System.Data.DbType.Int32, item.level);
                    dbManager.CreateInParameter(dbCmd, "enhance", System.Data.DbType.Int32, item.enhance);
                    dbManager.CreateInParameter(dbCmd, "durability", System.Data.DbType.Int32, item.ethereal_durability);
                    dbManager.CreateInParameter(dbCmd, "endurance", System.Data.DbType.Int32, item.endurance);
                    dbManager.CreateInParameter(dbCmd, "flag", System.Data.DbType.Int32, 0);
                    dbManager.CreateInParameter(dbCmd, "gcode", System.Data.DbType.Int32, 0);
                    dbManager.CreateInParameter(dbCmd, "wear_info", System.Data.DbType.Int32, (equip ? item.wear_type : -1));
                    dbManager.CreateInParameter(dbCmd, "socket_0", System.Data.DbType.Int32, 0);
                    dbManager.CreateInParameter(dbCmd, "socket_1", System.Data.DbType.Int32, 0);
                    dbManager.CreateInParameter(dbCmd, "socket_2", System.Data.DbType.Int32, 0);
                    dbManager.CreateInParameter(dbCmd, "socket_3", System.Data.DbType.Int32, 0);
                    dbManager.CreateInParameter(dbCmd, "remain_time", System.Data.DbType.Int32, item.available_period);
                    dbManager.CreateInParameter(dbCmd, "elemental_effect_type", System.Data.DbType.Int32, 0);
                    dbManager.CreateInParameter(dbCmd, "elemental_effect_expire_time", System.Data.DbType.DateTime, new DateTime(0));
                    dbManager.CreateInParameter(dbCmd, "elemental_effect_attack_point", System.Data.DbType.Int32, 0);
                    dbManager.CreateInParameter(dbCmd, "elemental_effect_magic_point", System.Data.DbType.Int32, 0);
                    dbManager.CreateInParameter(dbCmd, "create_time", System.Data.DbType.DateTime, DateTime.UtcNow);

                    try
                    {
                        dbCmd.Connection.Open();
                        dbCmd.ExecuteNonQuery();
                    }
                    catch (Exception ex) { ConsoleUtils.ShowError(ex.Message); }
                    finally { dbCmd.Connection.Close(); }
                }
            }
        }
Exemple #3
0
        internal static void LoadItemEffect()
        {
            ItemEffectResource = new Dictionary<int, DB_ItemEffect[]>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(6))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            int id = -1;
                            List<DB_ItemEffect> effects = new List<DB_ItemEffect>();

                            while (dbReader.Read())
                            {
                                int off = 0;

                                if (id != (int)dbReader[off] && id != -1)
                                {
                                    if (!ItemEffectResource.ContainsKey(id))
                                        ItemEffectResource.Add(id, effects.ToArray());
                                    else
                                        ConsoleUtils.ShowError("Duplicated Item Effect with ID {0}. Skipping duplicated entry.", id);

                                    effects.Clear();
                                }
                                id = (int)dbReader[off++];

                                effects.Add(new DB_ItemEffect()
                                {
                                     ordinal_id = (int)dbReader[off++],
                                     tooltip_id = (int)dbReader[off++],
                                     effect_type = (byte)dbReader[off++],
                                     effect_id = (short)dbReader[off++],
                                     effect_level = (short)dbReader[off++],
                                     value_0 = (decimal)dbReader[off++],
                                     value_1 = (decimal)dbReader[off++],
                                     value_2 = (decimal)dbReader[off++],
                                     value_3 = (decimal)dbReader[off++],
                                     value_4 = (decimal)dbReader[off++],
                                     value_5 = (decimal)dbReader[off++],
                                     value_6 = (decimal)dbReader[off++],
                                     value_7 = (decimal)dbReader[off++],
                                     value_8 = (decimal)dbReader[off++],
                                     value_9 = (decimal)dbReader[off++],
                                     value_10 = (decimal)dbReader[off++],
                                     value_11 = (decimal)dbReader[off++],
                                     value_12 = (decimal)dbReader[off++],
                                     value_13 = (decimal)dbReader[off++],
                                     value_14 = (decimal)dbReader[off++],
                                     value_15 = (decimal)dbReader[off++],
                                     value_16 = (decimal)dbReader[off++],
                                     value_17 = (decimal)dbReader[off++],
                                     value_18 = (decimal)dbReader[off++],
                                     value_19 = (decimal)dbReader[off++],
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from ItemEffectResource", ItemEffectResource.Count);
        }
Exemple #4
0
        internal static void LoadState()
        {
            StateResource = new Dictionary<int, DB_State>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(27))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int off = 0;
                                int state_id = (int)dbReader[off++];

                                if (!StateResource.ContainsKey(state_id))
                                    StateResource.Add(
                                        state_id,
                                        new DB_State
                                        {
                                            text_id = (int)dbReader[off++],
                                            tooltip_id = (int)dbReader[off++],
                                            is_harmful = Convert.ToChar(dbReader[off++]),
                                            state_time_type = (int)dbReader[off++],
                                            state_group = (int)dbReader[off++],
                                            duplicate_group_1 = (int)dbReader[off++],
                                            duplicate_group_2 = (int)dbReader[off++],
                                            duplicate_group_3 = (int)dbReader[off++],
                                            uf_avatar = Convert.ToChar(dbReader[off++]),
                                            uf_summon = Convert.ToChar(dbReader[off++]),
                                            uf_monster = Convert.ToChar(dbReader[off++]),
                                            base_effect_id = (int)dbReader[off++],
                                            fire_interval = (int)dbReader[off++],
                                            elemental_type = (int)dbReader[off++],
                                            amplify_base = (decimal)dbReader[off++],
                                            amplify_per_skl = (decimal)dbReader[off++],
                                            add_damage_base = (int)dbReader[off++],
                                            add_damage_per_skl = (int)dbReader[off++],
                                            effect_type = (int)dbReader[off++],
                                            value_0 = (decimal)dbReader[off++],
                                            value_1 = (decimal)dbReader[off++],
                                            value_2 = (decimal)dbReader[off++],
                                            value_3 = (decimal)dbReader[off++],
                                            value_4 = (decimal)dbReader[off++],
                                            value_5 = (decimal)dbReader[off++],
                                            value_6 = (decimal)dbReader[off++],
                                            value_7 = (decimal)dbReader[off++],
                                            value_8 = (decimal)dbReader[off++],
                                            value_9 = (decimal)dbReader[off++],
                                            value_10 = (decimal)dbReader[off++],
                                            value_11 = (decimal)dbReader[off++],
                                            value_12 = (decimal)dbReader[off++],
                                            value_13 = (decimal)dbReader[off++],
                                            value_14 = (decimal)dbReader[off++],
                                            value_15 = (decimal)dbReader[off++],
                                            value_16 = (decimal)dbReader[off++],
                                            value_17 = (decimal)dbReader[off++],
                                            value_18 = (decimal)dbReader[off++],
                                            value_19 = (decimal)dbReader[off++],
                                            icon_id = (int)dbReader[off++],
                                            icon_file_name = (string)dbReader[off++],
                                            fx_id = (int)dbReader[off++],
                                            pos_id = (int)dbReader[off++],
                                            cast_skill_id = (int)dbReader[off++],
                                            cast_fx_id = (int)dbReader[off++],
                                            cast_fx_pos_id = (int)dbReader[off++],
                                            hit_fx_id = (int)dbReader[off++],
                                            hit_fx_pos_id = (int)dbReader[off++],
                                            special_output_timining_id = (int)dbReader[off++],
                                            special_output_fx_pos_id = (int)dbReader[off++],
                                            special_output_fx_delay = (int)dbReader[off++],
                                            state_fx_id = (int)dbReader[off++],
                                            state_fx_pos_id = (int)dbReader[off++]
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated State with ID {0}. Skipping duplicated entry.", state_id);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from StateResource", StateResource.Count);
        }
Exemple #5
0
        internal static void LoadMonsterDropTable()
        {
            MonsterDropTableResource = new Dictionary<int, DB_MonsterDropTable[]>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(12))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            bool started = false;
                            int id = 0;
                            List<DB_MonsterDropTable> dropTable = new List<DB_MonsterDropTable>();

                            while (dbReader.Read())
                            {
                                int off = 0;
                                if (id != (int)dbReader[off] && started)
                                {
                                    if (!MonsterDropTableResource.ContainsKey(id))
                                        MonsterDropTableResource.Add(id, dropTable.ToArray());
                                    else
                                        ConsoleUtils.ShowError("Duplicated Monster Drop Table with ID {0}. Skipping duplicated entry.", id);
                                }

                                started = true;
                                id = (int)dbReader[off++];

                                dropTable.Add(
                                    new DB_MonsterDropTable
                                    {
                                        sub_id = (int)dbReader[off++],
                                        drop_item_id_00 = (int)dbReader[off++],
                                        drop_percentage_00 = (decimal)dbReader[off++],
                                        drop_min_count_00 = (short)dbReader[off++],
                                        drop_max_count_00 = (short)dbReader[off++],
                                        drop_min_level_00 = (short)dbReader[off++],
                                        drop_max_level_00 = (short)dbReader[off++],
                                        drop_item_id_01 = (int)dbReader[off++],
                                        drop_percentage_01 = (decimal)dbReader[off++],
                                        drop_min_count_01 = (short)dbReader[off++],
                                        drop_max_count_01 = (short)dbReader[off++],
                                        drop_min_level_01 = (short)dbReader[off++],
                                        drop_max_level_01 = (short)dbReader[off++],
                                        drop_item_id_02 = (int)dbReader[off++],
                                        drop_percentage_02 = (decimal)dbReader[off++],
                                        drop_min_count_02 = (short)dbReader[off++],
                                        drop_max_count_02 = (short)dbReader[off++],
                                        drop_min_level_02 = (short)dbReader[off++],
                                        drop_max_level_02 = (short)dbReader[off++],
                                        drop_item_id_03 = (int)dbReader[off++],
                                        drop_percentage_03 = (decimal)dbReader[off++],
                                        drop_min_count_03 = (short)dbReader[off++],
                                        drop_max_count_03 = (short)dbReader[off++],
                                        drop_min_level_03 = (short)dbReader[off++],
                                        drop_max_level_03 = (short)dbReader[off++],
                                        drop_item_id_04 = (int)dbReader[off++],
                                        drop_percentage_04 = (decimal)dbReader[off++],
                                        drop_min_count_04 = (short)dbReader[off++],
                                        drop_max_count_04 = (short)dbReader[off++],
                                        drop_min_level_04 = (short)dbReader[off++],
                                        drop_max_level_04 = (short)dbReader[off++],
                                        drop_item_id_05 = (int)dbReader[off++],
                                        drop_percentage_05 = (decimal)dbReader[off++],
                                        drop_min_count_05 = (short)dbReader[off++],
                                        drop_max_count_05 = (short)dbReader[off++],
                                        drop_min_level_05 = (short)dbReader[off++],
                                        drop_max_level_05 = (short)dbReader[off++],
                                        drop_item_id_06 = (int)dbReader[off++],
                                        drop_percentage_06 = (decimal)dbReader[off++],
                                        drop_min_count_06 = (short)dbReader[off++],
                                        drop_max_count_06 = (short)dbReader[off++],
                                        drop_min_level_06 = (short)dbReader[off++],
                                        drop_max_level_06 = (short)dbReader[off++],
                                        drop_item_id_07 = (int)dbReader[off++],
                                        drop_percentage_07 = (decimal)dbReader[off++],
                                        drop_min_count_07 = (short)dbReader[off++],
                                        drop_max_count_07 = (short)dbReader[off++],
                                        drop_min_level_07 = (short)dbReader[off++],
                                        drop_max_level_07 = (short)dbReader[off++],
                                        drop_item_id_08 = (int)dbReader[off++],
                                        drop_percentage_08 = (decimal)dbReader[off++],
                                        drop_min_count_08 = (short)dbReader[off++],
                                        drop_max_count_08 = (short)dbReader[off++],
                                        drop_min_level_08 = (short)dbReader[off++],
                                        drop_max_level_08 = (short)dbReader[off++],
                                        drop_item_id_09 = (int)dbReader[off++],
                                        drop_percentage_09 = (decimal)dbReader[off++],
                                        drop_min_count_09 = (short)dbReader[off++],
                                        drop_max_count_09 = (short)dbReader[off++],
                                        drop_min_level_09 = (short)dbReader[off++],
                                        drop_max_level_09 = (short)dbReader[off++],
                                    });
                            }

                            if (!MonsterDropTableResource.ContainsKey(id))
                                MonsterDropTableResource.Add(id, dropTable.ToArray());
                            else
                                ConsoleUtils.ShowError("Duplicated Monster Drop Table with ID {0}. Skipping duplicated entry.", id);
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from MonsterDropTableResource", MonsterDropTableResource.Count);
        }
Exemple #6
0
        void FeedHistoryData(String strTicker)
        {
            DBManager dbManager = new DBManager();
            MySqlConnection con = null;
            MySqlTransaction trans = null;

            try
            {
                String ip = CommonConfig.DB_SERVER_IP;
                con = dbManager.CreateConnection(ip, CommonConfig.DATABASE_CORREL);
                con.Open();
                trans = con.BeginTransaction();

                DeleteHistoryData_Raw(con, strTicker);
                FeedHistoryData_Raw(con);

                trans.Commit();
                Write("Feed History Data is success...");
            }
            catch (System.Exception e)
            {
                trans.Rollback();
                Error(e.ToString());
            }
            finally
            {
                dbManager.Close(con);
            }
        }
Exemple #7
0
        void LoadProductInfoFromComdty()
        {
            DBManager dbManager = new DBManager();
            MySqlConnection con = null;

            try
            {
                String ip = CommonConfig.DB_SERVER_IP;
                con = dbManager.CreateConnection(ip, CommonConfig.DATABASE_COMDTY);
                con.Open();

                LoadProductInfoFromComdty_Raw(con);

                Write("상품정보를 읽어오기를 실행하였습니다.");
            }
            catch (System.Exception e)
            {
                Error(e.ToString());
            }
            finally
            {
                dbManager.Close(con);
            }
        }
Exemple #8
0
        /// <summary>
        /// Loads character data into player
        /// and sends to client
        /// </summary>
        /// <param name="player"></param>
        /// <param name="name"></param>
        /// <param name="race"></param>
        internal static void Login(Player player, string name, byte race)
        {
            using (DBManager dbManager = new DBManager(Databases.User))
            {
                #region Character Info load
                using (DbCommand dbCmd = dbManager.CreateCommand(5))
                {
                    dbManager.CreateInParameter(dbCmd, "accId", System.Data.DbType.String, player.AccountId);
                    dbManager.CreateInParameter(dbCmd, "now", System.Data.DbType.DateTime, DateTime.UtcNow);
                    dbManager.CreateInParameter(dbCmd, "name", System.Data.DbType.String, name);

                    int off = 0;

                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader reader = dbCmd.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                player.CharacterId = (int)reader[off++]; // 0
                                off++; // AccountId // 1
                                player.Name = (string)reader[off++]; // 3
                                player.PartyId = (int)reader[off++]; // 4
                                player.GuildId = (int)reader[off++]; // 5
                                off++; // PrevGuildId // 6
                                // 7~10
                                player.Position = new Position((int)reader[off++], (int)reader[off++], (int)reader[off++], (byte)reader[off++]);
                                player.Race = (byte)reader[off++]; // 11
                                player.Sex = (int)reader[off++]; // 12
                                player.Level = (int)reader[off++]; // 13
                                player.MaxReachedLevel = (int)reader[off++]; // 14
                                player.Exp = (long)reader[off++]; // 15
                                player.LastDecreasedExp = (long)reader[off++]; // 16
                                player.Hp = (int)reader[off++]; // 17
                                player.Mp = (short)(int)reader[off++]; // 18 // TODO :FIX
                                player.Stamina = (int)reader[off++]; // 19
                                player.Havoc = (int)reader[off++]; // 20
                                player.Job = (short)reader[off++]; // 21
                                player.JobDepth = (byte)reader[off++]; // 22
                                player.JobLevel = (int)reader[off++]; // 23
                                player.Jp = (int)reader[off++]; // 24
                                player.TotalJp = (int)reader[off++]; // 25
                                for (int i = 0; i < 3; i++)
                                { // Previous Jobs
                                    player.PrevJobs[i].Id = (int)reader[off++]; // 26, 28, 30
                                    player.PrevJobs[i].Level = (int)reader[off++]; // 27, 29, 31
                                }
                                player.ImmoralPoints = (decimal)reader[off++]; // 32
                                player.Cha = (int)reader[off++]; // 33
                                player.Pkc = (int)reader[off++]; // 34
                                player.Dkc = (int)reader[off++]; // 35
                                player.Huntaholic.Points = (int)reader[off++]; // 36
                                player.Huntaholic.EnterCount = (int)reader[off++]; // 37
                                player.Gold = (long)reader[off++]; // 38
                                player.Chaos = (int)reader[off++]; // 39
                                player.SkinColor = (uint)reader[off++]; // 40
                                player.HairId = (int)reader[off++]; // 41
                                player.FaceId = (int)reader[off++]; // 42
                                player.BodyId = (int)reader[off++]; // 43
                                player.HandsId = (int)reader[off++]; // 44
                                player.FeetId = (int)reader[off++]; // 45
                                player.TextureId = (int)reader[off++]; // 46
                                for (int i = 0; i < 6; i++)
                                    player.Belt[i].Id = (long)reader[off++]; // 47, 48, 49, 50, 51, 52
                                for (int i = 0; i < 6; i++)
                                    player.Summon[i].Id = (int)reader[off++]; // 53, 54, 55, 56, 57, 58
                                player.MainSummon = (int)reader[off++]; // 59
                                player.SubSummon = (int)reader[off++]; // 60
                                player.RemainSummonTime = (int)reader[off++]; // 61
                                player.Pet = (int)reader[off++]; // 62
                                off++; // Create Date // 63
                                off++; // Delete Date // 64
                                off++; // Login Time // 65
                                off++; // Login count // 66
                                off++; // Logout Time // 67
                                off++; // Play Time // 68
                                player.ChatBlockTime = (int)reader[off++]; // 69
                                player.AdvChatCount = (int)reader[off++]; // 70
                                off++; // NameChanged // 71
                                off++; // Auto User // 72
                                player.GuildBlockTime = (int)reader[off++]; // 73
                                player.PkMode = (byte)reader[off++]; // 74
                                off++; // Otp Value // 75
                                off++; // Otp Date // 76
                                player.ClientInfo = (string)reader[off++]; // 77
                            }
                        }
                    }
                    catch (Exception ex) { ConsoleUtils.ShowError(ex.Message + " (Offset: " + off + ")"); }
                    finally { dbCmd.Connection.Close(); }
                }

                #endregion

                #region Update login_time
                using (DbCommand dbCmd = dbManager.CreateCommand(7))
                {
                    dbManager.CreateInParameter(dbCmd, "cid", System.Data.DbType.Int32, player.CharacterId);
                    try
                    {
                        dbCmd.Connection.Open();
                        dbCmd.ExecuteNonQuery();
                    }
                    catch (Exception ex) { ConsoleUtils.ShowError("Failed to Update LoginTime. Error {0}", ex.Message); }
                    finally { dbCmd.Connection.Close(); }
                }
                #endregion

                player.Stats.Load(player);
                ClientPackets.Instance.StatInfo(player, player.Stats, player.Attributes, false);
                ClientPackets.Instance.StatInfo(player, player.BonusStats, player.BonusAttributes, true);

                //ClientPackets.send_Login_pre1(player);

                // Load Inventory
                Inventory.Load(player);

                //ClientPackets.send_Login_pre1(player);

                ClientPackets.send_Login_pre2(player);

                ClientPackets.Instance.LoginResult(player);

                ClientPackets.Instance.StatInfo(player, player.Stats, player.Attributes, false);
                ClientPackets.Instance.StatInfo(player, player.BonusStats, player.BonusAttributes, true);

                ClientPackets.Instance.InventoryList(player, player.InventoryHandles);
                ClientPackets.Instance.EquipSummon(player, player.Summon, false);

                ClientPackets.Instance.WearInfo(player, player.WearInfo);
                ClientPackets.Instance.GoldUpdate(player, player.Gold, player.Chaos);
                ClientPackets.Instance.Property(player, "chaos", player.Chaos, true);
                ClientPackets.Instance.LevelUpdate(player, player.Level, player.JobLevel);
                ClientPackets.Instance.ExpUpdate(player, player.Exp, player.Jp);

                ClientPackets.Instance.Property(player, "job", player.Job, true);
                ClientPackets.Instance.Property(player, "job_level", player.JobLevel, true);
                ClientPackets.Instance.Property(player, "job_0", player.PrevJobs[0].Id, true);
                ClientPackets.Instance.Property(player, "jlv_0", player.PrevJobs[0].Level, true);
                ClientPackets.Instance.Property(player, "job_1", player.PrevJobs[1].Id, true);
                ClientPackets.Instance.Property(player, "jlv_1", player.PrevJobs[1].Level, true);
                ClientPackets.Instance.Property(player, "job_2", player.PrevJobs[2].Id, true);
                ClientPackets.Instance.Property(player, "jlv_2", player.PrevJobs[2].Level, true);

                ClientPackets.Instance.BeltSlotInfo(player, player.Belt);

                ClientPackets.send_Login_pre3(player);

                ClientPackets.Instance.Property(player, "huntaholic_ent", player.Huntaholic.EnterCount, true);
                ClientPackets.Instance.Property(player, "dk_count", player.Dkc, true);
                ClientPackets.Instance.Property(player, "pk_count", player.Pkc, true);
                ClientPackets.Instance.Property(player, "immoral", player.ImmoralPoints, true);
                ClientPackets.Instance.Property(player, "stamina", player.Stamina, true);
                ClientPackets.Instance.Property(player, "max_stamina", player.MaxStamina, true);
                ClientPackets.Instance.Property(player, "channel", player.Cha, true);

                ClientPackets.Instance.StatusChange(player, player.Handle, 0);

                ClientPackets.Instance.QuestList(player); // TODO : Incomplete packet

                ClientPackets.Instance.Chat(player, "@FRIEND", 0x8C, "FLIST|");
                ClientPackets.Instance.Chat(player, "@FRIEND", 0x8C, "DLIST|");

                // TODO : what is this used for?
                ClientPackets.Instance.Property(player, "playtime", 0, true);
                ClientPackets.Instance.Property(player, "playtime_limit1", 0, true);
                ClientPackets.Instance.Property(player, "playtime_limit2", 0, true);

                // TODO : Get new location by position
                ClientPackets.Instance.ChangeLocation(player, 0, 100302);
                // TODO : Get proper weather info and region
                ClientPackets.Instance.WeatherInfo(player, 100302, 1);

                ClientPackets.send_Login_pre4(player);

                ClientPackets.Instance.Property(player, "client_info", player.ClientInfo, false);
                ClientPackets.Instance.Property(player, "stamina_regen", player.StaminaRegen, true);
            }

            // TODO : PlaceHolder Data, must be replaced with real one
            //ClientPackets.send_Login(player);
        }
Exemple #9
0
        /// <summary>
        /// Creates a new Character to this account
        /// </summary>
        /// <param name="player"></param>
        /// <param name="charInfo"></param>
        /// <returns></returns>
        internal static bool Create(Player player, Network.Packets.LobbyCharacterInfo charInfo)
        {
            // Ensures the name is available
            if (!CheckCharacterName(charInfo.Name))
                return false;

            lock (CreateLock)
            {
                bool result = true;
                using (DBManager dbManager = new DBManager(Databases.User))
                {
                    using (DbCommand dbCmd = dbManager.CreateCommand(2))
                    {
                        int charId;
                        short job = 0;
                        int startWeapon = 0;
                        int startClothes = 0;
                        int startBag = 490001;
                        Position startPos = new Position();

                        switch (charInfo.ModelInfo.Race)
                        {
                            case 3: // Gaia
                                job = 100;
                                startPos.X = 164474;
                                startPos.Y = 52932;

                                startWeapon = 112100; //Trainee's Small Axe
                                if (charInfo.ModelInfo.WearInfo[2] == 601)
                                    startClothes = 220100;
                                else
                                    startClothes = 220109;
                                break;

                            case 4: // Deva
                                job = 200;
                                startPos.X = 164335;
                                startPos.Y = 49510;

                                startWeapon = 106100; // Beginner's Mace
                                if (charInfo.ModelInfo.WearInfo[2] == 601)
                                    startClothes = 240100;
                                else
                                    startClothes = 240109;
                                break;

                            case 5: // Asura
                                job = 300;
                                startPos.X = 168356;
                                startPos.Y = 55399;

                                startWeapon = 103100; // Beginner's Dirk
                                if (charInfo.ModelInfo.WearInfo[2] == 601)
                                    startClothes = 230100;
                                else
                                    startClothes = 230109;
                                break;
                        }

                        dbManager.CreateInParameter(dbCmd, "accId", System.Data.DbType.Int32, player.AccountId);
                        dbManager.CreateInParameter(dbCmd, "name", System.Data.DbType.String, charInfo.Name);
                        dbManager.CreateInParameter(dbCmd, "race", System.Data.DbType.Byte, (byte)charInfo.ModelInfo.Race);
                        dbManager.CreateInParameter(dbCmd, "sex", System.Data.DbType.Int32, charInfo.ModelInfo.Sex);
                        dbManager.CreateInParameter(dbCmd, "job", System.Data.DbType.Int16, job);
                        dbManager.CreateInParameter(dbCmd, "level", System.Data.DbType.Int32, 1);
                        dbManager.CreateInParameter(dbCmd, "x", System.Data.DbType.Single, startPos.X);
                        dbManager.CreateInParameter(dbCmd, "y", System.Data.DbType.Single, startPos.Y);
                        dbManager.CreateInParameter(dbCmd, "textureId", System.Data.DbType.Int32, charInfo.ModelInfo.TextureId);
                        dbManager.CreateInParameter(dbCmd, "hairId", System.Data.DbType.Int32, charInfo.ModelInfo.ModelId[0]);
                        dbManager.CreateInParameter(dbCmd, "faceId", System.Data.DbType.Int32, charInfo.ModelInfo.ModelId[1]);
                        dbManager.CreateInParameter(dbCmd, "bodyId", System.Data.DbType.Int32, charInfo.ModelInfo.ModelId[2]);
                        dbManager.CreateInParameter(dbCmd, "handsId", System.Data.DbType.Int32, charInfo.ModelInfo.ModelId[3]);
                        dbManager.CreateInParameter(dbCmd, "feetId", System.Data.DbType.Int32, charInfo.ModelInfo.ModelId[4]);
                        dbManager.CreateInParameter(dbCmd, "skinColor", System.Data.DbType.UInt32, charInfo.SkinColor);

                        try
                        {
                            dbCmd.Connection.Open();
                            charId = Convert.ToInt32(dbCmd.ExecuteScalar());

                            Inventory.InsertItem(charId, startWeapon, true);
                            Inventory.InsertItem(charId, startClothes, true);
                            Inventory.InsertItem(charId, startBag, true);
                        }
                        catch (Exception ex) { ConsoleUtils.ShowError(ex.Message); result = false; }
                        finally { dbCmd.Connection.Close(); }
                    }
                }
                return result;
            }
        }
Exemple #10
0
        internal static void Load(Player player)
        {
            using (DBManager dbManager = new DBManager(Databases.User))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(20))
                {
                    dbManager.CreateInParameter(dbCmd, "charId", System.Data.DbType.Int64, player.CharacterId);

                    #region Character Inventory load

                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader reader = dbCmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                int off = 0;

                                Item item = new Item((long)reader[off++]);
                                off += 6;
                                item.Code = (int)reader[off++];
                                item.Count = (long)reader[off++];
                                item.Level = (int)reader[off++];
                                item.Enhance = (int)reader[off++];
                                item.Durability = (int)reader[off++];
                                item.Endurance = (uint)(int)reader[off++];
                                item.Flag = (int)reader[off++];
                                item.GCode = (int)reader[off++];
                                item.WearInfo = (Wear)reader[off++];
                                item.Socket[0] = (int)reader[off++];
                                item.Socket[1] = (int)reader[off++];
                                item.Socket[2] = (int)reader[off++];
                                item.Socket[3] = (int)reader[off++];
                                item.RemainTime = (int)reader[off++];
                                // TODO : Elemental data

                                if (item.WearInfo >= 0)
                                    Equip(player, item, false);

                                player.Inventory.Add(item.Handle, item);
                                player.InventoryHandles.Add(item.Handle);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        ConsoleUtils.ShowError("Failed to load inventory. Error: {0}", e.Message);
                    }

                    #endregion
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// Deletes a character from this account
        /// </summary>
        /// <param name="player"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        internal static bool Delete(Player player, string name)
        {
            bool result = true;

            using (DBManager dbManager = new DBManager(Databases.User))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand((Settings.KeepDeletedCharacters ? 3 : 4)))
                {
                    if (Settings.KeepDeletedCharacters)
                        dbManager.CreateInParameter(dbCmd, "now", System.Data.DbType.DateTime, DateTime.UtcNow);
                    dbManager.CreateInParameter(dbCmd, "accId", System.Data.DbType.Int32, player.AccountId);
                    dbManager.CreateInParameter(dbCmd, "name", System.Data.DbType.String, name);

                    try
                    {
                        dbCmd.Connection.Open();
                        dbCmd.ExecuteNonQuery();
                    }
                    catch (Exception ex) { ConsoleUtils.ShowError(ex.Message); result = false; }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            return result;
        }
Exemple #12
0
        internal static void LoadEventArea()
        {
            EventAreaResource = new Dictionary<int, DB_EventArea>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(4))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int off = 0;
                                int id = (int)dbReader[off++];

                                if (!EventAreaResource.ContainsKey(id))
                                    EventAreaResource.Add(
                                        id,
                                        new DB_EventArea
                                        {
                                             begin_time = (int)dbReader[off++],
                                             end_time = (int)dbReader[off++],
                                             min_level = (int)dbReader[off++],
                                             max_level = (int)dbReader[off++],
                                             race_job_limit = (long)dbReader[off++],
                                             activate_condition1 = (int)dbReader[off++],
                                             activate_value1_1 = (int)dbReader[off++],
                                             activate_value1_2 = (int)dbReader[off++],
                                             activate_condition2 = (int)dbReader[off++],
                                             activate_value2_1 = (int)dbReader[off++],
                                             activate_value2_2 = (int)dbReader[off++],
                                             activate_condition3 = (int)dbReader[off++],
                                             activate_value3_1 = (int)dbReader[off++],
                                             activate_value3_2 = (int)dbReader[off++],
                                             activate_condition4 = (int)dbReader[off++],
                                             activate_value4_1 = (int)dbReader[off++],
                                             activate_value4_2 = (int)dbReader[off++],
                                             activate_condition5 = (int)dbReader[off++],
                                             activate_value5_1 = (int)dbReader[off++],
                                             activate_value5_2 = (int)dbReader[off++],
                                             activate_condition6 = (int)dbReader[off++],
                                             activate_value6_1 = (int)dbReader[off++],
                                             activate_value6_2 = (int)dbReader[off++],
                                             count_limit = (int)dbReader[off++],
                                             script = (string)dbReader[off++]
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated Event Area with ID {0}. Skipping duplicated entry.", id);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from EventAreaResource", EventAreaResource.Count);
        }
Exemple #13
0
        internal static void LoadItem()
        {
            ItemResource = new Dictionary<int, DB_Item>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(5))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int off = 0;
                                int id = (int)dbReader[off++];

                                if (!ItemResource.ContainsKey(id))
                                    ItemResource.Add(
                                        id,
                                        new DB_Item
                                        {
                                            name_id = (int)dbReader[off++],
                                            tooltip_id = (int)dbReader[off++],
                                            type = (int)dbReader[off++],
                                            Group = (int)dbReader[off++],
                                            Class = (int)dbReader[off++],
                                            wear_type = (int)dbReader[off++],
                                            Set_id = (int)dbReader[off++],
                                            Set_part_flag = (int)dbReader[off++],
                                            grade = (byte)dbReader[off++],
                                            rank = (int)dbReader[off++],
                                            level = (int)dbReader[off++],
                                            enhance = (int)dbReader[off++],
                                            socket = (int)dbReader[off++],
                                            status_flag = (int)dbReader[off++],
                                            limit_deva = Convert.ToChar(dbReader[off++]),
                                            limit_asura = Convert.ToChar(dbReader[off++]),
                                            limit_gaia = Convert.ToChar(dbReader[off++]),
                                            limit_fighter = Convert.ToChar(dbReader[off++]),
                                            limit_hunter = Convert.ToChar(dbReader[off++]),
                                            limit_magician = Convert.ToChar(dbReader[off++]),
                                            limit_summoner = Convert.ToChar(dbReader[off++]),
                                            use_min_level = (int)dbReader[off++],
                                            use_max_level = (int)dbReader[off++],
                                            target_min_level = (int)dbReader[off++],
                                            target_max_level = (int)dbReader[off++],
                                            range = (decimal)dbReader[off++],
                                            weight = (decimal)dbReader[off++],
                                            price = (int)dbReader[off++],
                                            huntaholic_point = (int)dbReader[off++],
                                            ethereal_durability = (int)dbReader[off++],
                                            endurance = (int)dbReader[off++],
                                            material = (int)dbReader[off++],
                                            summon_id = (int)dbReader[off++],
                                            item_use_flag = (int)dbReader[off++],
                                            available_period = (int)dbReader[off++],
                                            decrease_type = (byte)dbReader[off++],
                                            throw_range = (decimal)dbReader[off++],
                                            base_type_0 = (short)dbReader[off++],
                                            base_var1_0 = (decimal)dbReader[off++],
                                            base_var2_0 = (decimal)dbReader[off++],
                                            base_type_1 = (short)dbReader[off++],
                                            base_var1_1 = (decimal)dbReader[off++],
                                            base_var2_1 = (decimal)dbReader[off++],
                                            base_type_2 = (short)dbReader[off++],
                                            base_var1_2 = (decimal)dbReader[off++],
                                            base_var2_2 = (decimal)dbReader[off++],
                                            base_type_3 = (short)dbReader[off++],
                                            base_var1_3 = (decimal)dbReader[off++],
                                            base_var2_3 = (decimal)dbReader[off++],
                                            opt_type_0 = (short)dbReader[off++],
                                            opt_var1_0 = (decimal)dbReader[off++],
                                            opt_var2_0 = (decimal)dbReader[off++],
                                            opt_type_1 = (short)dbReader[off++],
                                            opt_var1_1 = (decimal)dbReader[off++],
                                            opt_var2_1 = (decimal)dbReader[off++],
                                            opt_type_2 = (short)dbReader[off++],
                                            opt_var1_2 = (decimal)dbReader[off++],
                                            opt_var2_2 = (decimal)dbReader[off++],
                                            opt_type_3 = (short)dbReader[off++],
                                            opt_var1_3 = (decimal)dbReader[off++],
                                            opt_var2_3 = (decimal)dbReader[off++],
                                            effect_id = (int)dbReader[off++],
                                            enhance_0_id = (short)dbReader[off++],
                                            enhance_0_01 = (decimal)dbReader[off++],
                                            enhance_0_02 = (decimal)dbReader[off++],
                                            enhance_0_03 = (decimal)dbReader[off++],
                                            enhance_0_04 = (decimal)dbReader[off++],
                                            enhance_1_id = (short)dbReader[off++],
                                            enhance_1_01 = (decimal)dbReader[off++],
                                            enhance_1_02 = (decimal)dbReader[off++],
                                            enhance_1_03 = (decimal)dbReader[off++],
                                            enhance_1_04 = (decimal)dbReader[off++],
                                            skill_id = (int)dbReader[off++],
                                            state_id = (int)dbReader[off++],
                                            state_level = (int)dbReader[off++],
                                            state_time = (int)dbReader[off++],
                                            state_type = (int)dbReader[off++],
                                            cool_time = (int)dbReader[off++],
                                            cool_time_group = (short)dbReader[off++],
                                            model_type_dem = (int)dbReader[off++],
                                            model_type_def = (int)dbReader[off++],
                                            model_type_asm = (int)dbReader[off++],
                                            model_type_asf = (int)dbReader[off++],
                                            model_type_gam = (int)dbReader[off++],
                                            model_type_gaf = (int)dbReader[off++],
                                            deco_model_change = (byte)dbReader[off++],
                                            model_00 = (string)dbReader[off++],
                                            model_01 = (string)dbReader[off++],
                                            model_02 = (string)dbReader[off++],
                                            model_03 = (string)dbReader[off++],
                                            model_04 = (string)dbReader[off++],
                                            model_05 = (string)dbReader[off++],
                                            model_06 = (string)dbReader[off++],
                                            model_07 = (string)dbReader[off++],
                                            model_08 = (string)dbReader[off++],
                                            model_09 = (string)dbReader[off++],
                                            model_10 = (string)dbReader[off++],
                                            model_11 = (string)dbReader[off++],
                                            model_12 = (string)dbReader[off++],
                                            model_13 = (string)dbReader[off++],
                                            model_14 = (string)dbReader[off++],
                                            model_15 = (string)dbReader[off++],
                                            model_16 = (string)dbReader[off++],
                                            model_17 = (string)dbReader[off++],
                                            texture_filename = (string)dbReader[off++],
                                            drop_type = (string)dbReader[off++],
                                            icon_id = (int)dbReader[off++],
                                            icon_file_name = (string)dbReader[off++],
                                            script_text = (string)dbReader[off++]
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated Item with ID {0}. Skipping duplicated entry.", id);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.ToString());
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from ItemResource", ItemResource.Count);
        }
Exemple #14
0
        internal static void LoadDropGroup()
        {
            DropGroupResource = new Dictionary<int, DB_DropGroup>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(3))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int off = 0;
                                int id = (int)dbReader[off++];

                                if (!DropGroupResource.ContainsKey(id))
                                    DropGroupResource.Add(id,
                                        new DB_DropGroup
                                        {
                                            drop_item_id_00 = (int)dbReader[off++],
                                            drop_min_count_00 = (long)dbReader[off++],
                                            drop_max_count_00 = (long)dbReader[off++],
                                            drop_percentage_00 = (decimal)dbReader[off++],
                                            drop_item_id_01 = (int)dbReader[off++],
                                            drop_min_count_01 = (long)dbReader[off++],
                                            drop_max_count_01 = (long)dbReader[off++],
                                            drop_percentage_01 = (decimal)dbReader[off++],
                                            drop_item_id_02 = (int)dbReader[off++],
                                            drop_min_count_02 = (long)dbReader[off++],
                                            drop_max_count_02 = (long)dbReader[off++],
                                            drop_percentage_02 = (decimal)dbReader[off++],
                                            drop_item_id_03 = (int)dbReader[off++],
                                            drop_min_count_03 = (long)dbReader[off++],
                                            drop_max_count_03 = (long)dbReader[off++],
                                            drop_percentage_03 = (decimal)dbReader[off++],
                                            drop_item_id_04 = (int)dbReader[off++],
                                            drop_min_count_04 = (long)dbReader[off++],
                                            drop_max_count_04 = (long)dbReader[off++],
                                            drop_percentage_04 = (decimal)dbReader[off++],
                                            drop_item_id_05 = (int)dbReader[off++],
                                            drop_min_count_05 = (long)dbReader[off++],
                                            drop_max_count_05 = (long)dbReader[off++],
                                            drop_percentage_05 = (decimal)dbReader[off++],
                                            drop_item_id_06 = (int)dbReader[off++],
                                            drop_min_count_06 = (long)dbReader[off++],
                                            drop_max_count_06 = (long)dbReader[off++],
                                            drop_percentage_06 = (decimal)dbReader[off++],
                                            drop_item_id_07 = (int)dbReader[off++],
                                            drop_min_count_07 = (long)dbReader[off++],
                                            drop_max_count_07 = (long)dbReader[off++],
                                            drop_percentage_07 = (decimal)dbReader[off++],
                                            drop_item_id_08 = (int)dbReader[off++],
                                            drop_min_count_08 = (long)dbReader[off++],
                                            drop_max_count_08 = (long)dbReader[off++],
                                            drop_percentage_08 = (decimal)dbReader[off++],
                                            drop_item_id_09 = (int)dbReader[off++],
                                            drop_min_count_09 = (long)dbReader[off++],
                                            drop_max_count_09 = (long)dbReader[off++],
                                            drop_percentage_09 = (decimal)dbReader[off++],
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated Drop Group with ID {0}. Skipping duplicated entry.", id);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from DropGroupResource", DropGroupResource.Count);
        }
Exemple #15
0
        internal static void LoadSummonUniqueName()
        {
            SummonUniqueNameResource = new Dictionary<int, DB_SummonName>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(24))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int id = (int)dbReader[0];

                                if (!SummonUniqueNameResource.ContainsKey(id))
                                    SummonUniqueNameResource.Add(
                                        id,
                                        new DB_SummonName
                                        {
                                            kind = (int)dbReader[1],
                                            text_id = (int)dbReader[2]
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated Summon Unique Name with ID {0}. Skipping duplicated entry.", id);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from SummonUniqueNameResource", SummonUniqueNameResource.Count);
        }
Exemple #16
0
        internal static void LoadCreatureBonus()
        {
            CreatureLevelBonus = new Dictionary<int, DB_CreatureLevelBonus>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(2))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int id = id = (int)dbReader[0];
                                if (!CreatureLevelBonus.ContainsKey(id))
                                    CreatureLevelBonus.Add(id,
                                    new DB_CreatureLevelBonus()
                                    {
                                        STR = (decimal)dbReader[1],
                                        VIT = (decimal)dbReader[2],
                                        DEX = (decimal)dbReader[3],
                                        AGI = (decimal)dbReader[4],
                                        INT = (decimal)dbReader[5],
                                        MEN = (decimal)dbReader[6],
                                        LUK = (decimal)dbReader[7]
                                    });
                                else
                                    ConsoleUtils.ShowError("Duplicated Creature Level Bonus with ID {0}. Skipping duplicated entry.", id);
                            }

                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from CreatureLevelBonus", CreatureLevelBonus.Count);
        }
Exemple #17
0
        internal static void LoadSummon()
        {
            SummonResource = new Dictionary<int, DB_Summon>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(26))
                {
                    try
                    {
                        dbManager.CreateInParameter(dbCmd, "localflag", System.Data.DbType.Int32, Settings.LocalFlag);
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int off = 0;
                                int id = (int)dbReader[off++];

                                if (!SummonResource.ContainsKey(id))
                                    SummonResource.Add(
                                        id,
                                        new DB_Summon
                                        {
                                            model_id = (int)dbReader[off++],
                                            name_id = (int)dbReader[off++],
                                            type = (int)dbReader[off++],
                                            magic_type = (int)dbReader[off++],
                                            rate = (byte)dbReader[off++],
                                            stat_id = (int)dbReader[off++],
                                            size = (decimal)dbReader[off++],
                                            scale = (decimal)dbReader[off++],
                                            target_fx_size = (decimal)dbReader[off++],
                                            standard_walk_speed = (int)dbReader[off++],
                                            standard_run_speed = (int)dbReader[off++],
                                            riding_speed = (int)dbReader[off++],
                                            run_speed = (int)dbReader[off++],
                                            is_riding_only = (byte)dbReader[off++],
                                            riding_motion_type = (int)dbReader[off++],
                                            attack_range = (decimal)dbReader[off++],
                                            walk_type = (int)dbReader[off++],
                                            slant_type = (int)dbReader[off++],
                                            material = (int)dbReader[off++],
                                            weapon_type = (int)dbReader[off++],
                                            attack_motion_speed = (int)dbReader[off++],
                                            form = (int)dbReader[off++],
                                            evolve_target = (int)dbReader[off++],
                                            camera_x = (int)dbReader[off++],
                                            camera_y = (int)dbReader[off++],
                                            camera_z = (int)dbReader[off++],
                                            target_x = (decimal)dbReader[off++],
                                            target_y = (decimal)dbReader[off++],
                                            target_z = (decimal)dbReader[off++],
                                            model = (string)dbReader[off++],
                                            motion_file_id = (int)dbReader[off++],
                                            face_id = (int)dbReader[off++],
                                            face_file_name = (string)dbReader[off++],
                                            card_id = (int)dbReader[off++],
                                            script_text = (string)dbReader[off++],
                                            illust_file_name = (string)dbReader[off++],
                                            text_feature_id = (int)dbReader[off++],
                                            text_name_id = (int)dbReader[off++],
                                            skill1_id = (int)dbReader[off++],
                                            skill1_text_id = (int)dbReader[off++],
                                            skill2_id = (int)dbReader[off++],
                                            skill2_text_id = (int)dbReader[off++],
                                            skill3_id = (int)dbReader[off++],
                                            skill3_text_id = (int)dbReader[off++],
                                            skill4_id = (int)dbReader[off++],
                                            skill4_text_id = (int)dbReader[off++],
                                            skill5_id = (int)dbReader[off++],
                                            skill5_text_id = (int)dbReader[off++],
                                            texture_group = (int)dbReader[off++],
                                            local_flag = (int)dbReader[off++]
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated Summon with ID {0}. Skipping duplicated entry.", id);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from SummonResource", SummonResource.Count);
        }
Exemple #18
0
        internal static void LoadString()
        {
            StringResource = new Dictionary<int, DB_String>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(25))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int code = (int)dbReader[2];

                                if (!StringResource.ContainsKey(code))
                                    StringResource.Add(
                                        code,
                                        new DB_String
                                        {
                                            name = (string)dbReader[0],
                                            group_id = (int)dbReader[1],
                                            value = (string)dbReader[3]
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated String Id {0}. Skipping duplicated entry.", code);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from StringResource", StringResource.Count);
        }
Exemple #19
0
        /// <summary>
        /// Server content loading and start up
        /// </summary>
        public override void Start()
        {
            #region Internal StartUp
            DBManager.SetConnectionData(
                Settings.SqlEngine,
                "Server=" + Settings.SqlIp + ";Database=" + Settings.SqlDatabase + ";UID=" + Settings.SqlUsername + ";PWD=" + Settings.SqlPassword + ";Connection Timeout=5;",
                "",
                ""
            );

            using (DBManager dbManager = new DBManager(Databases.Auth))
            {
                if (dbManager.TestConnection())
                    ConsoleUtils.ShowInfo("Auth database connection test passed");
                else
                    return;
            }

            Database.Statements.Init();
            this.GameServers = new Dictionary<ushort, GameServer>();
            #endregion

            #region Listener StartUp
            GameManager.Instance.Start();
            ClientManager.Instance.Start();
            #endregion
        }
Exemple #20
0
        internal static void LoadJob()
        {
            JobResource = new Dictionary<int, DB_Job>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(8))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int off = 0;
                                int id = (int)dbReader[off++];

                                if (!JobResource.ContainsKey(id))
                                    JobResource.Add(
                                        id,
                                        new DB_Job
                                        {
                                            text_id = (int)dbReader[off++],
                                            stat_id = (int)dbReader[off++],
                                            job_class = (int)dbReader[off++],
                                            job_depth = Convert.ToChar(dbReader[off++]),
                                            up_lv = (short)dbReader[off++],
                                            up_jlv = (short)dbReader[off++],
                                            available_job_0 = (short)dbReader[off++],
                                            available_job_1 = (short)dbReader[off++],
                                            available_job_2 = (short)dbReader[off++],
                                            available_job_3 = (short)dbReader[off++],
                                            icon_id = (int)dbReader[off++],
                                            icon_file_name = (string)dbReader[off++]
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated Job with ID {0}. Skipping duplicated entry.", id);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from JobResource", JobResource.Count);
        }
Exemple #21
0
        /// <summary>
        /// Retrieves the character list
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        internal static void GetCharacterList(Player player)
        {
            List<Network.Packets.LobbyCharacterInfo> charList = new List<Network.Packets.LobbyCharacterInfo>();

            ushort lastLoginIndex = 0;

            using (DBManager dbManager = new DBManager(Databases.User))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(0))
                {
                    dbManager.CreateInParameter(dbCmd, "accId", System.Data.DbType.String, player.AccountId);
                    dbManager.CreateInParameter(dbCmd, "now", System.Data.DbType.DateTime, DateTime.UtcNow);
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader reader = dbCmd.ExecuteReader())
                        {
                            ushort count = 0;
                            DateTime lastLoginTime = new DateTime(0);

                            while (reader.Read())
                            {
                                // Reads the character data
                                Network.Packets.LobbyCharacterInfo chara = new Network.Packets.LobbyCharacterInfo();
                                int charId = (int)reader[0];
                                chara.Name = (string)reader[2];
                                chara.ModelInfo.Race = (byte)reader[10];
                                chara.ModelInfo.Sex = (int)reader[11];
                                chara.ModelInfo.TextureId = (int)reader[45];
                                for (int i = 0; i < 5; i++)
                                    chara.ModelInfo.ModelId[i] = (int)reader[40 + i];

                                using (DBManager dbManager2 = new DBManager(Databases.User))
                                {
                                    using (DbCommand dbCmd2 = dbManager2.CreateCommand(6))
                                    {
                                        dbManager2.CreateInParameter(dbCmd2, "charId", System.Data.DbType.Int32, charId);

                                        try
                                        {
                                            dbCmd2.Connection.Open();

                                            using (DbDataReader reader2 = dbCmd2.ExecuteReader())
                                            {
                                                while (reader2.Read())
                                                {
                                                    chara.ModelInfo.WearInfo[(short)reader2[0]] = (int)reader2[1];
                                                    chara.WearItemEnhanceInfo[(short)reader2[0]] = (int)reader2[2];
                                                    chara.WearItemLevelInfo[(short)reader2[0]] = (int)reader2[3];
                                                    chara.WearItemElementalType[(short)reader2[0]] = (byte)(sbyte)reader2[4];
                                                }
                                            }
                                        }
                                        catch (Exception e)
                                        {
                                            ConsoleUtils.ShowError("Failed to load character inventory. (Error: {0})", e.Message);
                                        }
                                        finally
                                        {
                                            dbCmd2.Connection.Close();
                                        }
                                    }
                                }
                                chara.Level = (int)reader[12];
                                chara.Job = (short)reader[20];
                                chara.JobLevel = (int)reader[22];
                                // TODO : chara.ExpPercentage = (int)
                                chara.Hp = (int)reader[16];
                                chara.Mp = (int)reader[17];
                                chara.Permission = player.Permission;
                                chara.IsBanned = false;
                                chara.SkinColor = (uint)reader[39];
                                chara.CreateTime = ((DateTime)reader[62]).ToString("yyyy/MM/dd");
                                chara.DeleteTime = "9999/12/31";
                                DateTime loginTime = (DateTime)reader[64];
                                if (loginTime > lastLoginTime)
                                {
                                    lastLoginTime = loginTime;
                                    lastLoginIndex = count;
                                }

                                // Adds data to char List
                                charList.Add(chara);

                                count++;
                            }
                        }
                    }
                    catch (Exception ex) { ConsoleUtils.ShowError(ex.Message); }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ClientPackets.Instance.CharacterList(player, charList.ToArray(), lastLoginIndex);
        }
Exemple #22
0
        internal static void LoadJobLevel()
        {
            JobLevelBonus = new Dictionary<int, DB_JobLevel>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(7))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int off = 0;
                                int job_id = (int)dbReader[off++];

                                if (!JobLevelBonus.ContainsKey(job_id))
                                    JobLevelBonus.Add(
                                        job_id,
                                        new DB_JobLevel
                                        {
                                            str_1 = (decimal)dbReader[off++],
                                            vit_1 = (decimal)dbReader[off++],
                                            dex_1 = (decimal)dbReader[off++],
                                            agi_1 = (decimal)dbReader[off++],
                                            int_1 = (decimal)dbReader[off++],
                                            men_1 = (decimal)dbReader[off++],
                                            luk_1 = (decimal)dbReader[off++],
                                            str_2 = (decimal)dbReader[off++],
                                            vit_2 = (decimal)dbReader[off++],
                                            dex_2 = (decimal)dbReader[off++],
                                            agi_2 = (decimal)dbReader[off++],
                                            int_2 = (decimal)dbReader[off++],
                                            men_2 = (decimal)dbReader[off++],
                                            luk_2 = (decimal)dbReader[off++],
                                            str_3 = (decimal)dbReader[off++],
                                            vit_3 = (decimal)dbReader[off++],
                                            dex_3 = (decimal)dbReader[off++],
                                            agi_3 = (decimal)dbReader[off++],
                                            int_3 = (decimal)dbReader[off++],
                                            men_3 = (decimal)dbReader[off++],
                                            luk_3 = (decimal)dbReader[off++],
                                            default_str = (decimal)dbReader[off++],
                                            default_vit = (decimal)dbReader[off++],
                                            default_dex = (decimal)dbReader[off++],
                                            default_agi = (decimal)dbReader[off++],
                                            default_int = (decimal)dbReader[off++],
                                            default_men = (decimal)dbReader[off++],
                                            default_luk = (decimal)dbReader[off++]
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated Job Level Bonus with ID {0}. Skipping duplicated entry.", job_id);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from JobLevelBonus", JobLevelBonus.Count);
        }
Exemple #23
0
        internal static void LoadLevel()
        {
            LevelResource = new Dictionary<int, DB_Level>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(9))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int level = (int)dbReader[0];

                                if (!LevelResource.ContainsKey(level))
                                    LevelResource.Add(
                                        level,
                                        new DB_Level
                                        {
                                            normal_exp = (long)dbReader[1],
                                            jl1 = (int)dbReader[2],
                                            jl2 = (int)dbReader[3],
                                            jl3 = (int)dbReader[4],
                                            jl4 = (int)dbReader[0]
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated Level ID {0}. Skipping duplicated entry.", level);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from LevelResource", LevelResource.Count);
        }
Exemple #24
0
        internal static void LoadMarket()
        {
            MarketResource = new Dictionary<String, DB_Market[]>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(10))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            string name = "";
                            List<DB_Market> market = new List<DB_Market>();

                            while (dbReader.Read())
                            {
                                if (name != (string)dbReader[1] && name != "")
                                {
                                    if (!MarketResource.ContainsKey(name))
                                        MarketResource.Add(name, market.ToArray());
                                    else
                                        ConsoleUtils.ShowError("Duplicated Market Name {0}. Skipping duplicated entry.", name);
                                    market.Clear();
                                }
                                name = (string)dbReader[1];

                                market.Add(
                                        new DB_Market
                                        {
                                            code = (int)dbReader[2],
                                            price_ratio = (decimal)dbReader[3],
                                            huntaholic_ratio = (decimal)dbReader[4]
                                        });
                            }

                            if (!MarketResource.ContainsKey(name))
                                MarketResource.Add(name, market.ToArray());
                            else
                                ConsoleUtils.ShowError("Duplicated Market Name {0}. Skipping duplicated entry.", name);

                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from MarketResource", MarketResource.Count);
        }
Exemple #25
0
        void UpdateComdty_Book()
        {
            DBManager dbManager = new DBManager();
            MySqlConnection con = null;
            MySqlTransaction trans = null;

            try
            {
                String ip = CommonConfig.DB_SERVER_IP;
                con = dbManager.CreateConnection(ip, CommonConfig.DATABASE_COMDTY);
                con.Open();
                trans = con.BeginTransaction();

                DeleteComdty_BookCodeTable_Raw(con);
                FeedComdty_BookCodeTable_Raw(con);

                trans.Commit();
                Write("Feed Product Data is success...");
            }
            catch (System.Exception e)
            {
                trans.Rollback();
                Error(e.ToString());
            }
            finally
            {
                dbManager.Close(con);
            }
        }
Exemple #26
0
        internal static void LoadMonster()
        {
            MonsterResource = new Dictionary<int, DB_Monster>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(11))
                {
                    try
                    {
                        dbManager.CreateInParameter(dbCmd, "localflag", System.Data.DbType.Int32, Settings.LocalFlag);
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int off = 0;
                                int id = (int)dbReader[off++];
                                DB_Monster monster = new DB_Monster
                                {
                                    monster_group = (int)dbReader[off++],
                                    name_id = (int)dbReader[off++],
                                    location_id = (int)dbReader[off++],
                                    model = (string)dbReader[off++],
                                    motion_file_id = (int)dbReader[off++],
                                    transform_level = (int)dbReader[off++],
                                    walk_type = (byte)dbReader[off++],
                                    slant_type = (byte)dbReader[off++],
                                    size = (decimal)dbReader[off++],
                                    scale = (decimal)dbReader[off++],
                                    target_fx_size = (decimal)dbReader[off++],
                                    camera_x = (int)dbReader[off++],
                                    camera_y = (int)dbReader[off++],
                                    camera_z = (int)dbReader[off++],
                                    target_x = (decimal)dbReader[off++],
                                    target_y = (decimal)dbReader[off++],
                                    target_z = (decimal)dbReader[off++],
                                    level = (int)dbReader[off++],
                                    grp = (int)dbReader[off++],
                                    magic_type = (int)dbReader[off++],
                                    race = (int)dbReader[off++],
                                    visible_range = (int)dbReader[off++],
                                    chase_range = (int)dbReader[off++],
                                    f_first_attack = (byte)dbReader[off++],
                                    f_group_first_attack = (byte)dbReader[off++],
                                    f_response_casting = (byte)dbReader[off++],
                                    f_response_race = (byte)dbReader[off++],
                                    f_response_battle = (byte)dbReader[off++],
                                    monster_type = (byte)dbReader[off++],
                                    stat_id = (int)dbReader[off++],
                                    fight_type = (int)dbReader[off++],
                                    monster_skill_link_id = (int)dbReader[off++],
                                    material = (int)dbReader[off++],
                                    weapon_type = (int)dbReader[off++],
                                    attack_motion_speed = (int)dbReader[off++],
                                    ability = (int)dbReader[off++],
                                    standard_walk_speed = (int)dbReader[off++],
                                    standard_run_speed = (int)dbReader[off++],
                                    walk_speed = (int)dbReader[off++],
                                    run_speed = (int)dbReader[off++],
                                    attack_range = (decimal)dbReader[off++],
                                    hidesense_range = (decimal)dbReader[off++],
                                    hp = (int)dbReader[off++],
                                    mp = (int)dbReader[off++],
                                    attack_point = (int)dbReader[off++],
                                    magic_point = (int)dbReader[off++],
                                    defence = (int)dbReader[off++],
                                    magic_defence = (int)dbReader[off++],
                                    attack_speed = (int)dbReader[off++],
                                    magic_speed = (int)dbReader[off++],
                                    accuracy = (int)dbReader[off++],
                                    avoid = (int)dbReader[off++],
                                    magic_accuracy = (int)dbReader[off++],
                                    magic_avoid = (int)dbReader[off++],
                                    taming_id = (int)dbReader[off++],
                                    taming_percentage = (decimal)dbReader[off++],
                                    taming_exp_mod = (decimal)dbReader[off++],
                                    exp = (int)dbReader[off++],
                                    jp = (int)dbReader[off++],
                                    gold_drop_percentage = (int)dbReader[off++],
                                    gold_min = (int)dbReader[off++],
                                    gold_max = (int)dbReader[off++],
                                    chaos_drop_percentage = (int)dbReader[off++],
                                    chaos_min = (int)dbReader[off++],
                                    chaos_max = (int)dbReader[off++],
                                    exp_2 = (int)dbReader[off++],
                                    jp_2 = (int)dbReader[off++],
                                    gold_min_2 = (int)dbReader[off++],
                                    gold_max_2 = (int)dbReader[off++],
                                    chaos_min_2 = (int)dbReader[off++],
                                    chaos_max_2 = (int)dbReader[off++],
                                    drop_table_link_id = (int)dbReader[off++],
                                    texture_group = (int)dbReader[off++],
                                    local_flag = (int)dbReader[off++],
                                    script_on_dead = (string)dbReader[off++]
                                };

                                if (MonsterResource.ContainsKey(id))
                                    ConsoleUtils.ShowError("Duplicated Monster with ID {0}; Current Local Flag: {1}, Ignored Local Flag: {2}", id, MonsterResource[id].local_flag, monster.local_flag);
                                else
                                    MonsterResource.Add(id, monster);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from MonsterResource", MonsterResource.Count);
        }
Exemple #27
0
        Boolean FeedProductInfo(String strTicker, String strDescription, String strBaseCurncy, double dOnePointAmount)
        {
            // 상품 정보를 입력한다.
            DBManager dbManager = new DBManager();
            MySqlConnection con = null;

            try
            {
                String ip = CommonConfig.DB_SERVER_IP;
                con = dbManager.CreateConnection(ip, CommonConfig.DATABASE_CORREL);
                con.Open();

                return FeedProductInfo_Raw(con, strTicker, strDescription, strBaseCurncy, dOnePointAmount);
            }
            catch (System.Exception e)
            {
                Error(e.ToString());
            }
            finally
            {
                dbManager.Close(con);
            }
            return false;
        }
Exemple #28
0
        internal static void LoadAuctionCategory()
        {
            AuctionCategoryResource = new Dictionary<int, DB_AuctionCategory[]>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(0))
                {
                    try
                    {
                        dbManager.CreateInParameter(dbCmd, "localflag", System.Data.DbType.Int32, Settings.LocalFlag);
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            int category_id = -1;
                            List<DB_AuctionCategory> subItems = new List<DB_AuctionCategory>();

                            while (dbReader.Read())
                            {
                                if ((int)dbReader[0] != category_id && category_id != -1)
                                {
                                    if (!AuctionCategoryResource.ContainsKey(category_id))
                                        AuctionCategoryResource.Add(category_id, subItems.ToArray());
                                    else
                                        ConsoleUtils.ShowError("Duplicated Auction Category Resource with ID {0}. Skipping duplicated entry.", category_id);

                                    subItems.Clear();
                                }
                                category_id = (int)dbReader[0];
                                DB_AuctionCategory subCat = new DB_AuctionCategory
                                {
                                    sub_category_id = (int)dbReader[1],
                                    name_id = (int)dbReader[2],
                                    local_flag = (int)dbReader[3],
                                    item_group = (int)dbReader[4],
                                    item_class = (int)dbReader[5]
                                };
                                subItems.Add(subCat);
                            }

                            if (category_id != -1)
                            {
                                AuctionCategoryResource.Add(category_id, subItems.ToArray());
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from AuctionCategoryResource", AuctionCategoryResource.Count);
        }
Exemple #29
0
        void LoadProductInfoFromCorrel(String strTicker)
        {
            DBManager dbManager = new DBManager();
            MySqlConnection con = null;

            try
            {
                String ip = CommonConfig.DB_SERVER_IP;
                con = dbManager.CreateConnection(ip, CommonConfig.DATABASE_CORREL);
                con.Open();

                LoadProductInfoFromCorrel_Raw(con, strTicker);
                LoadCombFutureMappingFromCorre_Raw(con, strTicker);

                Write("상품정보를 읽어오기를 실행하였습니다.");
            }
            catch (System.Exception e)
            {
                Error(e.ToString());
            }
            finally
            {
                dbManager.Close(con);
            }
        }
Exemple #30
0
        internal static void LoadStat()
        {
            StatResource = new Dictionary<int, DB_Stat>();

            using (DBManager dbManager = new DBManager(Databases.Game))
            {
                using (DbCommand dbCmd = dbManager.CreateCommand(21))
                {
                    try
                    {
                        dbCmd.Connection.Open();

                        using (DbDataReader dbReader = dbCmd.ExecuteReader())
                        {
                            while (dbReader.Read())
                            {
                                int off = 0;
                                int id = (int)dbReader[off++];
                                if (!StatResource.ContainsKey(id))
                                    StatResource.Add(
                                        id,
                                        new DB_Stat
                                        {
                                            STR = (int)dbReader[off++],
                                            VIT = (int)dbReader[off++],
                                            DEX = (int)dbReader[off++],
                                            AGI = (int)dbReader[off++],
                                            INT = (int)dbReader[off++],
                                            MEN = (int)dbReader[off++],
                                            LUK = (int)dbReader[off++]
                                        });
                                else
                                    ConsoleUtils.ShowError("Duplicated Stat with ID {0}. Skipping duplicated entry.", id);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ConsoleUtils.ShowSQL(ex.Message);
                        return;
                    }
                    finally { dbCmd.Connection.Close(); }
                }
            }

            ConsoleUtils.ShowNotice("{0} entries loaded from StatResource", StatResource.Count);
        }