コード例 #1
0
ファイル: MySQLActorDB.cs プロジェクト: yasuhiro91/SagaECO
        private void SaveItem(ActorPC pc)
        {
            string[] names = Enum.GetNames(typeof(ContainerType));
            string sqlstr;
            sqlstr = "DELETE FROM `inventory` WHERE char_id='" + pc.CharID + "';";

            foreach (string i in names)
            {
                ContainerType container = (ContainerType)Enum.Parse(typeof(ContainerType), i);
                List<Item.Item> items = pc.Inventory.GetContainer(container);
                foreach (Item.Item j in items)
                {
                    sqlstr += string.Format("INSERT INTO `inventory`(`char_id`,`itemID`,`durability`,`identified`,`stack`,`container`) VALUES " +
                        "('{0}','{1}','{2}','{3}','{4}','{5}');", pc.CharID, j.ItemID, j.durability, j.identified, j.stack, (byte)container);
                }
            }
            try
            {
                SQLExecuteNonQuery(sqlstr);
            }
            catch (Exception ex)
            {
                Logger.ShowError(ex);
            }
        }
コード例 #2
0
ファイル: MySQLActorDB.cs プロジェクト: yasuhiro91/SagaECO
 public void CreateChar(ActorPC aChar, int account_id)
 {
     string sqlstr;
     uint charID = 0;
     if (aChar != null && this.isConnected() == true)
     {
         sqlstr = string.Format("INSERT INTO `char`(`account_id`,`name`,`race`,`gender`,`hairStyle`,`hairColor`,`wig`," +
             "`face`,`job`,`mapID`,`lv`,`jlv1`,`jlv2x`,`jlv2t`,`questRemaining`,`slot`,`x`,`y`,`dir`,`hp`,`max_hp`,`mp`," +
             "`max_mp`,`sp`,`max_sp`,`str`,`dex`,`intel`,`vit`,`agi`,`mag`,`gold`" +
             ") VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}'," +
             "'{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}'" +
             ",'{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}')",
             account_id, aChar.Name, (byte)aChar.Race, (byte)aChar.Gender, aChar.HairStyle, aChar.HairColor, aChar.Wig,
             aChar.Face, (byte)aChar.Job, aChar.MapID, aChar.Level, aChar.JobLevel1, aChar.JobLevel2X, aChar.JobLevel2T,
             aChar.QuestRemaining, aChar.Slot, Global.PosX16to8(aChar.X), Global.PosY16to8(aChar.Y), (byte)(aChar.Dir / 45), aChar.HP, aChar.MaxHP, aChar.MP,
             aChar.MaxMP, aChar.SP, aChar.MaxSP, aChar.Str, aChar.Dex, aChar.Int, aChar.Vit, aChar.Agi, aChar.Mag, aChar.Gold);
         try
         {
             SQLExecuteScalar(sqlstr, ref charID);
         }
         catch (Exception ex)
         {
             Logger.ShowError(ex);
         }
         aChar.CharID = charID;
         SaveItem(aChar);
     }
 }
コード例 #3
0
ファイル: MySQLActorDB.cs プロジェクト: yasuhiro91/SagaECO
 private void GetItem(ActorPC pc)
 {
     string sqlstr;
     DataRowCollection result = null;
     sqlstr = "SELECT * FROM `inventory` WHERE `char_id`='" + pc.CharID + "';";
     try
     {
         result = SQLExecuteQuery(sqlstr);
     }
     catch (Exception ex)
     {
         Logger.ShowError(ex);
         return;
     }
     foreach (DataRow i in result)
     {
         Item.Item newItem = ItemFactory.Instance.GetItem((uint)i["itemID"]);
         newItem.durability = (ushort)i["durability"];
         newItem.stack = (byte)i["stack"];
         newItem.identified = (byte)i["identified"];
         ContainerType container = (ContainerType)(byte)i["container"];
         pc.Inventory.AddItem(container, newItem);
     }
 }
コード例 #4
0
ファイル: MySQLActorDB.cs プロジェクト: yasuhiro91/SagaECO
 public void SaveChar(ActorPC aChar)
 {
     string sqlstr;
     if (aChar != null && this.isConnected() == true)
     {
         sqlstr = string.Format("UPDATE `char` SET `name`='{0}',`race`='{1}',`gender`='{2}',`hairStyle`='{3}',`hairColor`='{4}',`wig`='{5}'," +
              "`face`='{6}',`job`='{7}',`mapID`='{8}',`lv`='{9}',`jlv1`='{10}',`jlv2x`='{11}',`jlv2t`='{12}',`questRemaining`='{13}',`slot`='{14}'" +
              ",`x`='{16}',`y`='{17}',`dir`='{18}',`hp`='{19}',`max_hp`='{20}',`mp`='{21}'," +
             "`max_mp`='{22}',`sp`='{23}',`max_sp`='{24}',`str`='{25}',`dex`='{26}',`intel`='{27}',`vit`='{28}',`agi`='{29}',`mag`='{30}',`gold`='{31}'" +
             " WHERE char_id='{15}' LIMIT 1",
              aChar.Name, (byte)aChar.Race, (byte)aChar.Gender, aChar.HairStyle, aChar.HairColor, aChar.Wig,
             aChar.Face, (byte)aChar.Job, aChar.MapID, aChar.Level, aChar.JobLevel1, aChar.JobLevel2X, aChar.JobLevel2T,
             aChar.QuestRemaining, aChar.Slot, aChar.CharID, Global.PosX16to8(aChar.X), Global.PosY16to8(aChar.Y), (byte)(aChar.Dir / 45), aChar.HP, aChar.MaxHP, aChar.MP,
             aChar.MaxMP, aChar.SP, aChar.MaxSP, aChar.Str, aChar.Dex, aChar.Int, aChar.Vit, aChar.Agi, aChar.Mag, aChar.Gold);
         try
         {
             SQLExecuteNonQuery(sqlstr);
         }
         catch (Exception ex)
         {
             Logger.ShowError(ex);
         }
         SaveItem(aChar);
     }
 }
コード例 #5
0
ファイル: MySQLActorDB.cs プロジェクト: yasuhiro91/SagaECO
        public ActorPC GetChar(uint charID)
        {
            string sqlstr;
            DataRow result = null;
            ActorPC pc;
            sqlstr = "SELECT * FROM `char` WHERE `char_id`='" + charID + "' LIMIT 1";
            try
            {
                result = SQLExecuteQuery(sqlstr)[0];
            }
            catch (Exception ex)
            {
                Logger.ShowError(ex);
                return null;
            }
            pc = new ActorPC();
            pc.CharID = charID;
            pc.Account = null;
            pc.Name = (string)result["name"];
            pc.Race = (PC_RACE)(byte)result["race"];
            pc.Gender = (PC_GENDER)(byte)result["gender"];
            pc.HairStyle = (byte)result["hairStyle"];
            pc.HairColor = (byte)result["hairColor"];
            pc.Wig = (byte)result["wig"];
            pc.Face = (byte)result["face"];
            pc.Job = (PC_JOB)(byte)result["job"];
            pc.MapID = (uint)result["mapID"];
            pc.Level = (byte)result["lv"];
            pc.JobLevel1 = (byte)result["jlv1"];
            pc.JobLevel2X = (byte)result["jlv2x"];
            pc.JobLevel2T = (byte)result["jlv2t"];
            pc.QuestRemaining = (ushort)result["questRemaining"];
            pc.Slot = (byte)result["slot"];
            pc.X = Global.PosX8to16((byte)result["x"]);
            pc.Y = Global.PosY8to16((byte)result["y"]);
            pc.Dir = (ushort)((byte)result["dir"] * 45);
            pc.HP = (uint)result["hp"];
            pc.MP = (uint)result["mp"];
            pc.SP = (uint)result["sp"];
            pc.MaxHP = (uint)result["max_hp"];
            pc.MaxMP = (uint)result["max_mp"];
            pc.MaxSP = (uint)result["max_sp"];
            pc.Str = (ushort)result["str"];
            pc.Dex = (ushort)result["dex"];
            pc.Int = (ushort)result["intel"];
            pc.Vit = (ushort)result["vit"];
            pc.Agi = (ushort)result["agi"];
            pc.Mag = (ushort)result["mag"];
            pc.Gold = (uint)result["gold"];

            GetItem(pc);
            return pc;
        }
コード例 #6
0
ファイル: MySQLActorDB.cs プロジェクト: yasuhiro91/SagaECO
        public void DeleteChar(ActorPC aChar)
        {
            string sqlstr;
            sqlstr = "DELETE FROM `char` WHERE char_id='" + aChar.CharID + "';";
            sqlstr += "DELETE FROM `inventory` WHERE char_id='" + aChar.CharID + "';";

            try
            {
                SQLExecuteNonQuery(sqlstr);
            }
            catch (Exception ex)
            {
                Logger.ShowError(ex);
            }
        }
コード例 #7
0
ファイル: LoginClient.cs プロジェクト: yasuhiro91/SagaECO
        public void OnCharCreate(Packets.Client.CSMG_CHAR_CREATE p)
        {
            Packets.Server.SSMG_CHAR_CREATE_ACK p1 = new SagaLogin.Packets.Server.SSMG_CHAR_CREATE_ACK();
            if (LoginServer.charDB.CharExists(p.Name))
            {
                p1.CreateResult = SagaLogin.Packets.Server.SSMG_CHAR_CREATE_ACK.Result.GAME_SMSG_CHRCREATE_E_NAME_CONFLICT;
            }
            else
            {
                var slot =
                    from a in account.Characters
                    where a.Slot == p.Slot
                    select a;
                if (slot.Count() != 0)
                {
                    p1.CreateResult = SagaLogin.Packets.Server.SSMG_CHAR_CREATE_ACK.Result.GAME_SMSG_CHRCREATE_E_ALREADY_SLOT;
                }
                else
                {
                    ActorPC pc = new ActorPC();
                    pc.Name = p.Name;
                    pc.Face = p.Face;
                    pc.Gender = p.Gender;
                    pc.HairColor = p.HairColor;
                    pc.HairStyle = p.HairStyle;
                    pc.Race = p.Race;
                    pc.Slot = p.Slot;
                    pc.Wig = 0xFF;
                    pc.Level = 1;
                    pc.JobLevel1 = 1;
                    pc.JobLevel2T = 1;
                    pc.JobLevel2X = 1;
                    pc.QuestRemaining = 3;
                    pc.MapID = 10024000;
                    pc.X = Global.PosX8to16(207);
                    pc.Y = Global.PosY8to16(114);
                    pc.Dir = 2;
                    pc.HP = 100;
                    pc.MaxHP = 120;
                    pc.MP = 200;
                    pc.MaxMP = 220;
                    pc.SP = 50;
                    pc.MaxSP = 60;
                    pc.Str = 2;
                    pc.Dex = 3;
                    pc.Int = 4;
                    pc.Vit = 5;
                    pc.Agi = 6;
                    pc.Mag = 7;
                    pc.Gold = 123456;

                    pc.Inventory.AddItem(ContainerType.UPPER_BODY, ItemFactory.Instance.GetItem(50001381));
                    pc.Inventory.AddItem(ContainerType.LOWER_BODY, ItemFactory.Instance.GetItem(50012360));
                    pc.Inventory.AddItem(ContainerType.SHOES, ItemFactory.Instance.GetItem(50060100));
                    pc.Inventory.AddItem(ContainerType.BODY, ItemFactory.Instance.GetItem(10020114));
                    pc.Inventory.AddItem(ContainerType.BODY, ItemFactory.Instance.GetItem(60010082));

                    LoginServer.charDB.CreateChar(pc, account.AccountID);
                    account.Characters.Add(pc);
                    p1.CreateResult = SagaLogin.Packets.Server.SSMG_CHAR_CREATE_ACK.Result.OK;
                }
            }
            this.netIO.SendPacket(p1);
            this.SendCharData();
        }