Exemple #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));
        }
Exemple #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)));
 }
 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;
     }
 }
Exemple #4
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());
                }
            }
        }
 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;
     }
 }
 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;
     }
 }
 protected override void messageReceived(Socket socket, byte[] message)
 {
     LittleEndianAccessor lea = new LittleEndianAccessor(new ByteArrayByteStream(message));
     int hander;
     switch (this.serverType)
     {
         case ServerType.LoginServer:
             hander = lea.readByte();
             net.handling.ServerHandler.handlerPacket((ReceiveOperationCode.Login)hander, lea, this);
             break;
         case ServerType.CharServer:
             hander = lea.readShort();
             net.handling.ServerHandler.handlerPacket((ReceiveOperationCode.Chars)hander, lea, this);
             break;
         case ServerType.GameServer:
             hander = lea.readShort();
             net.handling.ServerHandler.handlerPacket((ReceiveOperationCode.Game)hander, lea, this);
             break;
         default:
             hander = lea.readShort();
             net.handling.ServerHandler.handlerPacket((ReceiveOperationCode.Game)hander, lea, this);
             break;
     }
 }
Exemple #8
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());
                }
            }
        }
Exemple #9
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));
        }
Exemple #10
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}));
 }
Exemple #11
0
 public static void Game_Req(LittleEndianAccessor lea, GhostClient gc)
 {
     gc.SendPacket(net.Packet.Login.Game_Ack(gc, 0));
 }