コード例 #1
0
ファイル: Chars.cs プロジェクト: york8817612/GhostServer
        public static void Create_MyChar_Req(LittleEndianAccessor lea, GhostClient gc)
        {
            lea.readInt();
            lea.readInt();
            string name = lea.readAsciiString(20);
            int gender = lea.readByte();
            int unk1 = lea.readByte();
            int unk2 = lea.readByte();
            int unk3 = lea.readByte();
            int eyes = lea.readInt();
            int hair = lea.readInt();
            int weapon = lea.readInt();
            int armor = lea.readInt();

            Character chr = new Character();

            chr.AccountID = gc.Account.ID;
            chr.WorldID = gc.World.ID;
            chr.Name = name;
            chr.Title = "江湖人";
            chr.Level = 1;
            chr.Class = 0;
            chr.ClassLV = 0xFF;
            chr.Gender = (byte)gender;
            chr.Eyes = eyes;
            chr.Hair = hair;
            chr.Str = 3;
            chr.Dex = 3;
            chr.Vit = 3;
            chr.Int = 3;
            chr.Hp = 31;
            chr.MaxHp = 31;
            chr.Sp = 15;
            chr.MaxSp = 15;

            chr.Items.Add(new Item(weapon, (byte) ItemTypeConstants.EquipType.Weapon));
            chr.Items.Add(new Item(armor, (byte)ItemTypeConstants.EquipType.Dress));

            chr.Save();

            int pos;
            if ((gc.Account.Characters.Count + 1) <= 4)
            {
                gc.Account.Characters.Add(chr);
                pos = (gc.Account.Characters.Count << 8) + 1;
            }
            else if (Database.Exists("Characters", "name = '{0}'", name))
            {
                pos = -1;
            }
            else if ((gc.Account.Characters.Count + 1) > 4)
            {
                pos = -2;
            }
            else
            {
                pos = 0;
            }
            gc.SendPacket(net.Packet.Chars.Create_MyChar_Ack(pos));
        }
コード例 #2
0
ファイル: Chars.cs プロジェクト: york8817612/GhostServer
        public static void getCharactersData(PacketLittleEndianWriter plew, Character c)
        {
            plew.writeAsciiString(c != null ? c.Name : "", 20);
            plew.writeAsciiString(c != null ? c.Title : "", 20); // Title
            plew.write(c != null ? c.Gender : (byte)0);
            plew.write(c != null ? c.Level : (byte)0);
            plew.write(c != null ? c.Class : (byte)0);
            plew.write(c != null ? c.ClassLV : (byte)0);
            plew.write(0);
            plew.write(0);
            plew.write(0);
            plew.write(0);
            plew.writeShort((short)(c != null ? 1 : 0));
            plew.writeShort((short)(c != null ? 1 : 0));

            Dictionary<ItemTypeConstants.EquipType, int> eq = new Dictionary<ItemTypeConstants.EquipType, int>();
            if (c != null)
            {
                foreach (Item it in c.Items)
                {
                    switch (it.Slot)
                    {
                        case (byte)ItemTypeConstants.EquipType.Weapon:
                            eq.Add(ItemTypeConstants.EquipType.Weapon, it.ItemID);
                            break;
                        case (byte)ItemTypeConstants.EquipType.Dress:
                            eq.Add(ItemTypeConstants.EquipType.Dress, it.ItemID);
                            break;
                        case (byte)ItemTypeConstants.EquipType.Hat:
                            eq.Add(ItemTypeConstants.EquipType.Hat, it.ItemID);
                            break;
                        case (byte)ItemTypeConstants.EquipType.Face:
                            eq.Add(ItemTypeConstants.EquipType.Face, it.ItemID);
                            break;
                        case (byte)ItemTypeConstants.EquipType.Face2:
                            eq.Add(ItemTypeConstants.EquipType.Face2, it.ItemID);
                            break;
                        case (byte)ItemTypeConstants.EquipType.Mantle:
                            eq.Add(ItemTypeConstants.EquipType.Mantle, it.ItemID);
                            break;
                        case (byte)ItemTypeConstants.EquipType.Outfit:
                            eq.Add(ItemTypeConstants.EquipType.Outfit, it.ItemID);
                            break;
                    }
                }
            }

            plew.writeInt(c != null ? c.Eyes : 0); // 眼睛[eye]9110011
            plew.writeInt(c != null ? c.Hair : 0); // 頭髮[hair]9010011
            plew.writeInt(eq.ContainsKey(ItemTypeConstants.EquipType.Weapon) ? eq[ItemTypeConstants.EquipType.Weapon] : 0); // 武器[weapon]8010101
            plew.writeInt(eq.ContainsKey(ItemTypeConstants.EquipType.Dress) ? eq[ItemTypeConstants.EquipType.Dress] : 0); // 披風[mantle]8493122
            plew.writeInt(eq.ContainsKey(ItemTypeConstants.EquipType.Hat) ? eq[ItemTypeConstants.EquipType.Hat] : 0); // 帽子[hat]8610011
            plew.writeInt(eq.ContainsKey(ItemTypeConstants.EquipType.Face) ? eq[ItemTypeConstants.EquipType.Face] : 0); // 臉下[face2]9410021
            plew.writeInt(eq.ContainsKey(ItemTypeConstants.EquipType.Face2) ? eq[ItemTypeConstants.EquipType.Face2] : 0); // 臉上[face]8710013
            plew.writeInt(eq.ContainsKey(ItemTypeConstants.EquipType.Mantle) ? eq[ItemTypeConstants.EquipType.Mantle] : 0); // 服裝[outfit]9510081
            plew.writeInt(eq.ContainsKey(ItemTypeConstants.EquipType.Outfit) ? eq[ItemTypeConstants.EquipType.Outfit] : 0); // 衣服[dress]8160351
        }
コード例 #3
0
ファイル: Chars.cs プロジェクト: york8817612/GhostServer
        public static void MyChar_Info_Req(LittleEndianAccessor lea, GhostClient gc)
        {
            lea.readInt();
            lea.readInt();
            string[] data = lea.readAsciiString(0x100).Split(new string[] { " 0 " }, StringSplitOptions.None);
            string username = data[1];
            string password = data[2];

            gc.Account = new Account(gc);
            try
            {
                gc.Account.Load(username);

                if (password != gc.Account.Password)
                {
                    // -10
                }
                else if (gc.Account.LoggedIn > 0)
                {
                    // -2
                }
                else
                {
                    gc.Account.Characters = new List<Character>();
                    foreach (dynamic datum in new Datums("Characters").PopulateWith("id", "accountId = '{0}' && worldId = '{1}'", gc.Account.ID, gc.World.ID))
                    {
                        Character character = new Character(datum.id, gc);
                        character.Load(false);
                        gc.Account.Characters.Add(character);
                    }
                    gc.SendPacket(net.Packet.Chars.MyChar_Info_Ack(gc, gc.Account.Characters));
                }
            }
            catch (Exception ee)
            {
                if (ee.Message.Equals("account does not"))
                {
                    // -1
                }
                else
                {
                    Log.Error(ee.ToString());
                }
            }
        }