DarkEmu_GameServer.Systems.PlayerDataLoad C# (CSharp) Метод

PlayerDataLoad() публичный Метод

public PlayerDataLoad ( ) : void
Результат void
        public void PlayerDataLoad()
        {
            //Wrap our function inside a catcher
            try
            {
                //////////////////////////////////////////////////////////////////////////////////////
                // Load Character Data
                //////////////////////////////////////////////////////////////////////////////////////
                #region Character Data
                //If Character is null we return
                if (Character == null) return;
                //Set new sql query for character information
                MsSQL ms = new MsSQL("SELECT * FROM character WHERE name='" + Character.Information.Name + "'");
                //Open new sql data reader
                using (SqlDataReader reader = ms.Read())
                {
                    //While our reader is reading the information
                    while (reader.Read())
                    {
                        // Character id information
                        Character.Information.CharacterID = reader.GetInt32(0);
                        Character.Ids = new Global.ID(Character.Information.CharacterID, Global.ID.IDS.Player);
                        Character.Information.UniqueID = Character.Ids.GetUniqueID;
                        Character.Account.ID = Player.ID;
                        // Character model information
                        Character.Information.Model = reader.GetInt32(3);
                        Character.Information.Race = Data.ObjectBase[Character.Information.Model].Race;
                        Character.Information.Volume = reader.GetByte(4);
                        // Character base stats
                        Character.Information.Level = reader.GetByte(5);
                        Character.Stat.Strength = reader.GetInt16(6);
                        Character.Stat.Intelligence = reader.GetInt16(7);
                        Character.Information.Attributes = reader.GetInt16(8);
                        Character.Stat.Hp = reader.GetInt32(9);
                        Character.Stat.Mp = reader.GetInt32(10);
                        // Character gold information
                        Character.Information.Gold = reader.GetInt64(11);
                        // Character Points
                        Character.Information.XP = reader.GetInt64(12);
                        Character.Information.SpBar = reader.GetInt32(13);
                        Character.Information.SkillPoint = reader.GetInt32(14);
                        // Character GM information
                        Character.Information.GM = reader.GetByte(15);
                        // Character Location
                        Character.Position.xSec = reader.GetByte(16);
                        Character.Position.ySec = reader.GetByte(17);
                        Character.Position.x = reader.GetInt32(19);
                        Character.Position.y = reader.GetInt32(20);
                        Character.Position.z = reader.GetInt32(21);
                        Character.Information.Place = reader.GetByte(40);
                        // Character Main Stats
                        Character.Stat.SecondHp = reader.GetInt32(22);
                        Character.Stat.SecondMP = reader.GetInt32(23);
                        Character.Stat.MinPhyAttack = reader.GetInt32(24);
                        Character.Stat.MaxPhyAttack = reader.GetInt32(25);
                        Character.Stat.MinMagAttack = reader.GetInt32(26);
                        Character.Stat.MaxMagAttack = reader.GetInt32(27);
                        Character.Stat.PhyDef = reader.GetInt16(28);
                        Character.Stat.MagDef = reader.GetInt16(29);
                        Character.Stat.Hit = reader.GetInt16(30);
                        Character.Stat.Parry = reader.GetInt16(31);
                        Character.Speed.WalkSpeed = reader.GetInt32(33);
                        Character.Speed.RunSpeed = reader.GetInt32(34);
                        Character.Speed.BerserkSpeed = reader.GetInt32(35);
                        Character.Information.BerserkBar = reader.GetByte(36);
                        Character.Speed.DefaultSpeed = Character.Speed.RunSpeed;
                        Character.Stat.mag_Absorb = reader.GetInt16(38);
                        Character.Stat.phy_Absorb = reader.GetInt16(39);
                        // Character Other information
                        Character.Information.Pvpstate = reader.GetByte(45);
                        Character.Account.StorageGold = Player.pGold;
                        Character.Account.StorageSlots = Player.wSlots;
                        Character.Information.ExpandedStorage = reader.GetByte(53);
                        Character.LogNum = 53;
                        Character.Information.Slots = reader.GetInt32(44);
                        Character.Information.Title = reader.GetByte(41);
                        Character.Information.Online = reader.GetInt32(47);
                        Character.Information.StallModel = reader.GetInt32(52);
                        // Character Guide Info
                        Character.Guideinfo.G1 = new int[8];//Main Int Array Fro Guide Packet
                        Character.Guideinfo.Gchk = new int[8];//Main Guide Check Packet Array
                        //Read guide information
                        string Guideread = reader.GetString(51);
                        int t = 0;
                        for (int g = 0; g < 8; ++g)
                        {
                            Character.Guideinfo.G1[g] = int.Parse(Guideread.Substring(t, 2), System.Globalization.NumberStyles.HexNumber, null);
                            t = t + 2;
                        }
                        for (int gc = 0; gc < 8; ++gc)
                        {
                            Character.Guideinfo.Gchk[gc] = 0;
                        }
                        //Get guild joinable bool information
                        Character.Information.JoinGuildWait = Convert.ToBoolean(reader.GetByte(54));
                        //Get date time information and timespan information
                        DateTime WaitTime = reader.GetDateTime(55);
                        //Set timespan information
                        TimeSpan Timespan = WaitTime - DateTime.Now;
                        //If total minutes wait time is lower then 0
                        if (Timespan.TotalMinutes <= 0)
                        {
                            //Update database
                            MsSQL.UpdateData("UPDATE character SET GuildJoining='0' WHERE name='"+ Character.Information.Name +"'");
                            //Set bool to false so player can join a guild again
                            Character.Information.JoinGuildWait = false;
                        }
                    }
                }
                //Close our sql data reader
                ms.Close();
                #endregion
                //////////////////////////////////////////////////////////////////////////////////////
                // Set Skill And Mastery Information Max
                //////////////////////////////////////////////////////////////////////////////////////
                #region Set Skill / Mastery
                Character.Stat.Skill.Mastery = new int[9];
                Character.Stat.Skill.Mastery_Level = new byte[9];
                Character.Stat.Skill.Skill = new int[50000];
                #endregion
                //////////////////////////////////////////////////////////////////////////////////////
                // Load Mastery Data
                //////////////////////////////////////////////////////////////////////////////////////
                #region Load Mastery Data
                //New sql query to get mastery information
                ms = new MsSQL("SELECT * FROM mastery WHERE owner='" + Character.Information.CharacterID + "'");
                //Open new sql data reader
                using (SqlDataReader reader = ms.Read())
                {
                    //Set byte to 1 default
                    byte c = 1;
                    //While sql data reader is reading
                    while (reader.Read())
                    {
                        //We add the mastery information and level
                        Character.Stat.Skill.Mastery[c] = reader.GetInt32(1);
                        Character.Stat.Skill.Mastery_Level[c] = reader.GetByte(2);
                        c++;
                    }
                }
                //Close our sql data reader
                ms.Close();
                #endregion
                //////////////////////////////////////////////////////////////////////////////////////
                // Load Skill Data
                //////////////////////////////////////////////////////////////////////////////////////
                #region Load Skill Data
                //Create new query to get skill data
                ms = new MsSQL("SELECT * FROM saved_skills WHERE owner='" + Character.Information.CharacterID + "'");
                //Get skill count from reader
                using (SqlDataReader reader = ms.Read())
                    Character.Stat.Skill.AmountSkill = ms.Count();
                //Set default i to 1
                int i = 1;
                //Open new sql data reder
                using (SqlDataReader reader = ms.Read())
                {
                    //While the reader is reading
                    while (reader.Read())
                    {
                        //Add the skill id
                        Character.Stat.Skill.Skill[i] = reader.GetInt32(2);
                        i++;
                    }
                }
                //Close the sql data reader
                ms.Close();
                #endregion
                //////////////////////////////////////////////////////////////////////////////////////
                // Load Remaining information
                //////////////////////////////////////////////////////////////////////////////////////
                #region Load Remaining Data
                //Update x / y
                UpdateXY();
                //If character's current hp is lower then 1
                if (Character.Stat.SecondHp < 1)
                {
                    //Reset player location to return point, and fill the hp half of the max.
                    Character.Stat.SecondHp = (Character.Stat.Hp / 2);
                    Teleport_UpdateXYZ(Character.Information.Place);
                }
                //Set balande for player
                SetBalance();
                //Check our file information
                CheckFile();
                //Set stats for player
                SetStat();
                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine("Player Data Load Error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Systems