Esempio n. 1
0
        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));
        }
Esempio n. 2
0
 public static void Check_SameName_Req(LittleEndianAccessor lea, GhostClient gc)
 {
     lea.readInt();
     lea.readInt();
     string name = lea.readAsciiString(20);
     gc.SendPacket(net.Packet.Chars.Check_SameName_Ack((Database.Exists("Characters", "name = '{0}'", name) ? 0 : 1)));
 }
Esempio n. 3
0
 public static void handlerPacket(ReceiveOperationCode.Game recvops, LittleEndianAccessor lea, GhostClient gc)
 {
     switch (recvops)
     {
         case ReceiveOperationCode.Game.CHARACTER_SELECT:
             break;
         default:
             Console.WriteLine("未知Field Receive Operation Code {0}", recvops.ToString());
             break;
     }
 }
Esempio n. 4
0
        /* state
         * 28 = 此為有年齡限制的頻道,請使用其他頻道
         * 04 = 此ID已連線,請稍後再試
         * else = 網路狀態錯誤
         */
        public static byte[] Game_Ack(GhostClient c, int state)
        {
            PacketLittleEndianWriter plew = new PacketLittleEndianWriter();

            plew.write((byte)SendOperationCode.Login.GAME_ACK);
            plew.write((byte)state);
            plew.writeGhostAsciiString("192.168.1.101");
            plew.writeInt(14101 + c.CharSID);
            plew.writeInt(14199);

            return plew.getPacket();
        }
Esempio n. 5
0
        public static void Login_Req(LittleEndianAccessor lea, GhostClient gc)
        {
            string username = lea.readGhostAsciiString();
            string password = lea.readGhostAsciiString();

            if (username.IsAlphaNumeric() == false)
            {
                gc.SendPacket(net.Packet.Login.Login_Ack(13, false));
                return;
            }

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

                if (password != gc.Account.Password)
                {
                    gc.SendPacket(net.Packet.Login.Login_Ack(14, false));
                }
                else if (gc.Account.Banned > 0)
                {
                    gc.SendPacket(net.Packet.Login.Login_Ack(12, false));
                }
                else
                {
                    if (gc.Account.Master > 0)
                    {
                        gc.SendPacket(net.Packet.Login.Login_Ack(0, true));
                    }
                    else
                    {
                        gc.SendPacket(net.Packet.Login.Login_Ack(0, false));
                    }
                    gc.Account.LoggedIn = 1;
                }

            }
            catch (Exception ee)
            {
                if (ee.Message.Equals("account does not")) {
                    gc.SendPacket(net.Packet.Login.Login_Ack(13, false));
                } else {
                    Log.Error(ee.ToString());
                }
            }
        }
Esempio n. 6
0
 public static void handlerPacket(ReceiveOperationCode.Login recvops, LittleEndianAccessor lea, GhostClient gc)
 {
     switch (recvops)
     {
         case ReceiveOperationCode.Login.LOGIN_REQ:
             net.handling.Login.Login_Req(lea, gc);
             break;
         case ReceiveOperationCode.Login.SERVERLIST_REQ:
             net.handling.Login.ServerList_Req(lea, gc);
             break;
         case ReceiveOperationCode.Login.GAME_REQ:
             net.handling.Login.Game_Req(lea, gc);
             break;
         default:
             Console.WriteLine("未知Login Receive Operation Code {0}", recvops.ToString());
             break;
     }
 }
Esempio n. 7
0
 public static void handlerPacket(ReceiveOperationCode.Chars recvops, LittleEndianAccessor lea, GhostClient gc)
 {
     switch (recvops)
     {
         case ReceiveOperationCode.Chars.MYCHAR_INFO_REQ:
             net.handling.Chars.MyChar_Info_Req(lea, gc);
             break;
         case ReceiveOperationCode.Chars.CREATE_MYCHAR_REQ:
             net.handling.Chars.Create_MyChar_Req(lea, gc);
             break;
         case ReceiveOperationCode.Chars.CHECK_SAMENAME_REQ:
             net.handling.Chars.Check_SameName_Req(lea, gc);
             break;
         case ReceiveOperationCode.Chars.DELETE_MYCHAR_REQ:
             net.handling.Chars.Delete_MyChar_Req(lea, gc);
             break;
         default:
             Console.WriteLine("未知Chars Receive Operation Code {0}", recvops.ToString());
             break;
     }
 }
Esempio n. 8
0
 public Account(GhostClient gc)
 {
     this.Client = gc;
 }
Esempio n. 9
0
        public static byte[] MyChar_Info_Ack(GhostClient gc, List<Character> chars)
        {
            PacketLittleEndianWriter plew = new PacketLittleEndianWriter();

            plew.writeShort((short)SendOperationCode.Chars.MYCHAR_INFO_ACK);
            plew.writeInt(0); // length + CRC
            plew.writeInt(0);
            plew.writeInt(chars.Count); // Characters.Count

            for (int i = 0; i < 4; i++)
            {
                getCharactersData(plew, (i < chars.Count) ? chars[i] : null);
            }

            return plew.getPacket();
        }
Esempio n. 10
0
        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());
                }
            }
        }
Esempio n. 11
0
        public static void Delete_MyChar_Req(LittleEndianAccessor lea, GhostClient gc)
        {
            lea.readInt();
            lea.readInt();
            int del_id = lea.readInt();

            gc.Account.Characters[del_id].Delete();

            gc.SendPacket(net.Packet.Chars.Delete_MyChar_Ack(del_id + 1));
        }
Esempio n. 12
0
 public static void ServerList_Req(LittleEndianAccessor lea, GhostClient gc)
 {
     gc.SendPacket(net.Packet.Login.ServerList_Ack(0, new int[] { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}));
 }
Esempio n. 13
0
 public static void Game_Req(LittleEndianAccessor lea, GhostClient gc)
 {
     gc.SendPacket(net.Packet.Login.Game_Ack(gc, 0));
 }