void ArcheAgeConnection_DisconnectedEvent(object sender, EventArgs e)
        {
            if (CurrentAccount != null)
            {
                if (GameServerController.AuthorizedAccounts.ContainsKey(CurrentAccount.AccountId))
                {
                    GameServerController.AuthorizedAccounts.Remove(CurrentAccount.AccountId);
                }
                //Removing Account From All GameServers
                foreach (GameServer server in GameServerController.CurrentGameServers.Values)
                {
                    if (server.CurrentAuthorized.Contains(CurrentAccount.AccountId))
                    {
                        server.CurrentAuthorized.Remove(CurrentAccount.AccountId);
                    }
                }
                if (CurrentAccount.Password != null) //If you been fully authroized.
                {
                    CurrentAccount.LastEnteredTime = Utility.CurrentTimeMilliseconds();
                    AccountHolder.InsertOrUpdate(CurrentAccount);
                }
            }
            string             arg = movedToGame ? "moved to Game" : "disconnected";
            ArcheAgeConnection archeAgeConnection = this;

            Logger.Trace("ArcheAge: {0} {1}", CurrentAccount == null ? archeAgeConnection.ToString() : CurrentAccount.Name, arg);
            Dispose();
        }
Beispiel #2
0
        /**
         * token 验证模式
         * uid+token
         *
         */
        private static void Handle_Token_Continue(ArcheAgeConnection net, PacketReader reader)
        {
            reader.Offset = 21;
            int     m_RUidLength   = reader.ReadLEInt16();
            string  m_uid          = reader.ReadString(m_RUidLength); //Reading Login
            int     m_RtokenLength = reader.ReadLEInt16();
            string  m_RToken       = reader.ReadHexString(m_RtokenLength);
            Account n_Current      = AccountHolder.AccountList.FirstOrDefault(n => n.AccountId == Convert.ToInt32(m_uid));

            if (n_Current != null)
            {
                Logger.Trace("账号: < " + n_Current.AccountId + ":" + n_Current.Name + ">正在登陆");
                //账号存在
                if (n_Current.Token.ToLower() == m_RToken.ToLower())
                {
                    net.CurrentAccount = n_Current;
                    //将账号信息写入在线账户列表
                    GameServerController.AuthorizedAccounts.Add(net.CurrentAccount.AccountId, net.CurrentAccount);
                    Logger.Trace("账号: < " + n_Current.AccountId + ":" + n_Current.Name + ">登陆成功");
                    net.SendAsync(new NP_AcceptLogin(clientVersion));
                    net.SendAsync(new NP_03key(clientVersion));
                    //返回服务器列表
                    //net.SendAsync(new NP_ServerList());
                    return;
                }
                Logger.Trace("账号: <" + n_Current.AccountId + ":" + n_Current.Name + ">TOKEN验证失败:" + m_RToken.ToLower());
            }
            else
            {
                Logger.Trace("客户端尝试登陆不存在的账户" + m_uid);
            }

            //如果前面没有终止,那么账号登陆失败
            net.SendAsync(new NP_FailLogin());
        }
        /**
         * token Verification mode
         * uid+token
         *
         */
        private static void Handle_Token_Continue(ArcheAgeConnection net, PacketReader reader)
        {
            reader.Offset = 21;
            int     m_RUidLength   = reader.ReadLEInt16();
            string  m_uid          = reader.ReadString(m_RUidLength); //Reading Login
            int     m_RtokenLength = reader.ReadLEInt16();
            string  m_RToken       = reader.ReadHexString(m_RtokenLength);
            Account n_Current      = AccountHolder.AccountList.FirstOrDefault(n => n.AccountId == Convert.ToInt64(m_uid));

            if (n_Current != null)
            {
                Logger.Trace("account number: < " + n_Current.AccountId + ":" + n_Current.Name + "> is landing");
                //accounts exist
                if (n_Current.Token.ToLower() == m_RToken.ToLower())
                {
                    net.CurrentAccount = n_Current;
                    //Write account information to online account list
                    GameServerController.AuthorizedAccounts.Add(net.CurrentAccount.AccountId, net.CurrentAccount);
                    Logger.Trace("Account: < " + n_Current.AccountId + ":" + n_Current.Name + "> landing success");
                    net.SendAsync(new NP_AcceptLogin(clientVersion));
                    net.SendAsync(new NP_03key(clientVersion));
                    //return server list
                    //net.SendAsync(new NP_ServerList());
                    return;
                }
                Logger.Trace("Account: < " + n_Current.AccountId + ":" + n_Current.Name + "> token verification failed: " + m_RToken.ToLower());
            }
            else
            {
                Logger.Trace("Client attempts to login to a nonexistent account" + m_uid);
            }

            //If there is no termination before, the account login fails
            net.SendAsync(new NP_FailLogin());
        }
Beispiel #4
0
        /**
         *
         * 客户端选择服务器发送
         * 服务器IP
         * 服务器端口号
         * sessionID
         *
         * */
        private static void Handle_ServerSelected(ArcheAgeConnection net, PacketReader reader)
        {
            //net.SendAsync(new NP_EditMessage2("systemTest"));
            //return;
            reader.Offset += 8; //00 00 00 00 00 00 00 00  Undefined Data
            byte serverId = reader.ReadByte();
            //serverId =1;
            GameServer server = GameServerController.CurrentGameServers.FirstOrDefault(n => n.Value.Id == serverId).Value;

            if (server != null && server.CurrentConnection != null)
            {
                if (GameServerController.AuthorizedAccounts.ContainsKey(net.CurrentAccount.AccountId))
                {
                    //create session
                    Random random = new Random();
                    int    num    = random.Next(255) + random.Next(255) + random.Next(255) + random.Next(255);
                    net.CurrentAccount.Session = num = 1323126619;//指定session

                    net.movedToGame = true;
                    GameServerController.AuthorizedAccounts.Remove(net.CurrentAccount.AccountId);
                    server.CurrentConnection.SendAsync(new NET_AccountInfo(net.CurrentAccount));
                    server.CurrentAuthorized.Add(net.CurrentAccount.AccountId);
                    net.SendAsync(new NP_SendGameAuthorization(server, num));
                }
            }
            else
            {
                Logger.Trace("请求了不存在的服务器ID:" + serverId);
                net.Dispose();
            }
        }
        private static void Handle_SignIn_Continue(ArcheAgeConnection net, PacketReader reader)
        {
            //HOW TO DECRYPT IT ????
            //string password = "";
            //If the account is not empty, login fails
            if (net.CurrentAccount == null)
            {
                //Return login failure information
                net.SendAsync(new NP_FailLogin());
                return;
            }

            /* TODO
             * if (net.CurrentAccount.Password == null)
             * {
             *  //Means - New Account.
             *  net.CurrentAccount.Password = password;
             * }
             * else
             * {
             *  //Checking Password
             *  if (net.CurrentAccount.Password != password)
             *  {
             *      net.SendAsync(new NP_FailLogin());
             *      return;
             *  }
             * }
             */
            net.SendAsync(new NP_AcceptLogin(clientVersion));
            net.CurrentAccount.Session = net.GetHashCode();
            net.SendAsync(new NP_PasswordCorrect(net.CurrentAccount.Session));
            Logger.Trace("Account login: " + net.CurrentAccount.Name);
            GameServerController.AuthorizedAccounts.Add(net.CurrentAccount.AccountId, net.CurrentAccount);
        }
Beispiel #6
0
        /**
         *
         * 客户端选择服务器发送
         * 服务器IP
         * 服务器端口号
         * sessionID
         *
         * */
        private static void Handle_ServerSelected(ArcheAgeConnection net, PacketReader reader)
        {
            //net.SendAsyncHex(new NP_Hex("6f000c005100006700e682a8e79a84e5b8b3e8999fe59ba0e98195e58f8de9818ae688b2e7aea1e79086e8a68fe7aba0e88887e6a29de4be8be69585e5819ce6ac8a34e697a52c20e5a682e69c89e79691e5958fe8ab8be6b4bde5aea2e69c8de4b8ade5bf83313a31e8a9a2e5958f2e01"));
            //return;
            reader.Offset += 8; //00 00 00 00 00 00 00 00  Undefined Data
            byte serverId = reader.ReadByte();
            //serverId =1;
            GameServer server = GameServerController.CurrentGameServers.FirstOrDefault(n => n.Value.Id == serverId).Value;

            if (server != null && server.CurrentConnection != null)
            {
                if (GameServerController.AuthorizedAccounts.ContainsKey(net.CurrentAccount.AccountId))
                {
                    //create session
                    Random random = new Random();
                    int    num    = random.Next(255) + random.Next(255) + random.Next(255) + random.Next(255);
                    net.CurrentAccount.Session = num = 1323126619;//指定session

                    net.movedToGame = true;
                    GameServerController.AuthorizedAccounts.Remove(net.CurrentAccount.AccountId);
                    server.CurrentConnection.SendAsync(new NET_AccountInfo(net.CurrentAccount));
                    server.CurrentAuthorized.Add(net.CurrentAccount.AccountId);
                    net.SendAsync(new NP_SendGameAuthorization(server, num));
                }
            }
            else
            {
                Logger.Trace("no server ID:" + serverId);
                net.Dispose();
            }
        }
Beispiel #7
0
        private static void Handle_SignIn(ArcheAgeConnection net, PacketReader reader)
        {
            reader.Offset += 10;                                           //Static Data - 0A 00 00 00 07 00 00 00 00 00

            string m_RLogin = reader.ReadStringSafe(reader.ReadLEInt16()); //Reading Login

            Account n_Current = AccountHolder.AccountList.FirstOrDefault(n => n.Name == m_RLogin);

            if (n_Current == null)
            {
                //Make New Temporary
                if (Settings.Default.Account_AutoCreation)
                {
                    Account m_New = new Account();
                    m_New.AccountId       = AccountHolder.AccountList.Count + 1;
                    m_New.LastEnteredTime = Utility.CurrentTimeMilliseconds();
                    m_New.AccessLevel     = 0;
                    m_New.LastIp          = net.ToString();
                    m_New.Membership      = 0;
                    m_New.Name            = m_RLogin;
                    net.CurrentAccount    = m_New;
                    AccountHolder.AccountList.Add(m_New);
                }
                else
                {
                    net.CurrentAccount = null;
                }
            }
            else
            {
                net.CurrentAccount = n_Current;
            }
            net.SendAsync(new NP_AcceptLogin());
            net.SendAsync(new NP_AESKey());
        }
        private static void Handle_Token_Continue2(ArcheAgeConnection net, PacketReader reader)
        {
            Account n_Current = AccountHolder.AccountList.FirstOrDefault(n => n.AccountId == 1);

            if (n_Current != null)
            {
                Logger.Trace("The account is trying to login: "******"Account login successful: " + net.CurrentAccount.Name);
                net.SendAsync(new NP_AcceptLogin(clientVersion));
                net.SendAsync(new NP_03key(clientVersion));
                //Return to server list
                //net.SendAsync(new NP_ServerList());
                return;
                //  }
                // Logger.Trace("account number: " + net.CurrentAccount.Name + "/Incorrect password:" + m_RToken.ToLower());
            }
            //If the previous did not stop, then account landing failed
            net.SendAsync(new NP_FailLogin());
        }
Beispiel #9
0
        private static void Handle_Token_Continue2(ArcheAgeConnection net, PacketReader reader)
        {
            Account n_Current = AccountHolder.AccountList.FirstOrDefault(n => n.AccountId == 1);

            if (n_Current != null)
            {
                Logger.Trace("账号试图登陆: " + n_Current.Name);
                //账号存在
                // if (n_Current.Password.ToLower() == m_RToken.ToLower())
                // {
                net.CurrentAccount = n_Current;
                //将账号信息写入在线账户列表
                GameServerController.AuthorizedAccounts.Add(net.CurrentAccount.AccountId, net.CurrentAccount);
                Logger.Trace("账号登陆成功: " + net.CurrentAccount.Name);
                net.SendAsync(new NP_AcceptLogin(clientVersion));
                net.SendAsync(new NP_03key(clientVersion));
                //返回服务器列表
                //net.SendAsync(new NP_ServerList());
                return;
                //  }
                // Logger.Trace("账号: " + net.CurrentAccount.Name + "/密码不正确:" + m_RToken.ToLower());
            }

            //如果前面没有终止,那么账号登陆失败
            net.SendAsync(new NP_FailLogin());
        }
Beispiel #10
0
        private static void Handle_AuthClient(ArcheAgeConnection net, PacketReader reader)
        {
            int AccountId = reader.ReadInt16();//userid

            reader.Offset += 4;
            int undefined = reader.ReadInt16();//undefined  session?

            net.SendAsync(new NP_AcceptAuth());
        }
        /// <summary>
        /// Обрабатываем приход пакета из Лобби "Выбор сервера"
        ///</summary>>
        private static void Handle_CARequestReconnect_0X0F(ArcheAgeConnection net, PacketReader reader)
        {
            /*
             * [1]             C>s             0ms.            14:01:18 .890      21.07.18
             * -------------------------------------------------------------------------------
             * TType: ArcheageServer: LS1     Parse: 6           EnCode: off
             * ------- 0  1  2  3  4  5  6  7 -  8  9  A  B  C  D  E  F    -------------------
             * 000000 21 00 0F 00 0A 00 00 00 | 08 00 00 00 01 00 00 00     !...............
             * 000010 00 00 00 00 01 09 1F 83 | 1D 08 00 00 00 00 00 00     .......ƒ........
             * 000020 00 00 00                                              ...
             * -------------------------------------------------------------------------------
             * Archeage: "CARequestReconnect"               size: 35     prot: 2  $002
             * Addr:  Size:    Type:         Description:     Value:
             * 0000     2   word          psize             33         | $0021
             * 0002     2   word          ID                15         | $000F
             * 0004     4   integer       p_from            10         | $0000000A
             * 0008     4   integer       p_to              8          | $00000008
             * 000C     8   int64         accountId         1          | $00000001
             * 0014     4   integer       cookie            -2095118079 | $831F0901
             * 0018  2079   WideStr[byte] MAC               00:00:00:00:00:00:00:00:00  ($)
             */

            int  p_from    = reader.ReadLEInt32();
            int  p_to      = reader.ReadLEInt32();
            long accountId = reader.ReadLEInt64();
            int  cookie    = reader.ReadLEInt32();

            Account n_Current = AccountHolder.AccountList.FirstOrDefault(n => n.AccountId == accountId);

            if (n_Current != null)
            {
                Logger.Trace("Account ID: " + n_Current.AccountId + " & Account Name: " + n_Current.Name + " is landing");
                net.CurrentAccount = n_Current;
                //Write account number information Write Online account list
                GameServerController.AuthorizedAccounts.Add(net.CurrentAccount.AccountId, net.CurrentAccount);
                Logger.Trace("Account ID: " + n_Current.AccountId + " & Account Name: " + n_Current.Name + " landing success");
                net.SendAsync(new AcJoinResponse_0X00(clientVersion));
                net.SendAsync(new AcAuthResponse_0X03(clientVersion, net));
                return;
            }
            else
            {
                Logger.Trace("Client try to login to a nonexistent account: " + accountId);
            }
        }
Beispiel #12
0
 private static void Handle_ServerSelected(ArcheAgeConnection net, PacketReader reader)
 {
     reader.Offset += 8; //00 00 00 00 00 00 00 00  Undefined Data
     byte serverId = reader.ReadByte();
     GameServer server = GameServerController.CurrentGameServers.FirstOrDefault(n => n.Value.Id == serverId).Value;
     if (server.CurrentConnection != null)
     {
         if (GameServerController.AuthorizedAccounts.ContainsKey(net.CurrentAccount.AccountId))
         {
             net.movedToGame = true;
             GameServerController.AuthorizedAccounts.Remove(net.CurrentAccount.AccountId);
             server.CurrentConnection.SendAsync(new NET_AccountInfo(net.CurrentAccount));
             net.SendAsync(new NP_SendGameAuthorization(server, net.CurrentAccount.AccountId));
             server.CurrentAuthorized.Add(net.CurrentAccount.AccountId);
         }
     }
     else
         net.Dispose();
 }
Beispiel #13
0
        private static void Handle_ServerSelected(ArcheAgeConnection net, PacketReader reader)
        {
            reader.Offset += 8; //00 00 00 00 00 00 00 00  Undefined Data
            byte       serverId = reader.ReadByte();
            GameServer server   = GameServerController.CurrentGameServers.FirstOrDefault(n => n.Value.Id == serverId).Value;

            if (server.CurrentConnection != null)
            {
                if (GameServerController.AuthorizedAccounts.ContainsKey(net.CurrentAccount.AccountId))
                {
                    net.movedToGame = true;
                    GameServerController.AuthorizedAccounts.Remove(net.CurrentAccount.AccountId);
                    server.CurrentConnection.SendAsync(new NET_AccountInfo(net.CurrentAccount));
                    net.SendAsync(new NP_SendGameAuthorization(server, net.CurrentAccount.AccountId));
                    server.CurrentAuthorized.Add(net.CurrentAccount.AccountId);
                }
            }
            else
            {
                net.Dispose();
            }
        }
        /**
         *
         * Client selects server to send
         *          * Server IP
         *          * Server port number
         * sessionID
         * */
        private static void Handle_ServerSelected(ArcheAgeConnection net, PacketReader reader)
        {
            //net.SendAsync(new NP_EditMessage2("systemTest"));
            //return;
            reader.Offset += 8; //00 00 00 00 00 00 00 00  Undefined Data
            byte serverId = reader.ReadByte();
            //serverId =1;
            GameServer server = GameServerController.CurrentGameServers.FirstOrDefault(n => n.Value.Id == serverId).Value;

            if (server != null && server.CurrentConnection != null)
            {
                if (GameServerController.AuthorizedAccounts.ContainsKey(net.CurrentAccount.AccountId))
                {
                    //create session
                    //Random random = new Random();
                    //int num = random.Next(255) + random.Next(255) + random.Next(255) + random.Next(255);
                    //net.CurrentAccount.Session = num= 1323126619;//Specify session

                    // генерируем cookie
                    Random random = new Random();
                    int    cookie = random.Next(255);
                    cookie += random.Next(255) << 8;
                    cookie += random.Next(255) << 16;
                    cookie += random.Next(255) << 24;
                    net.CurrentAccount.Session = cookie; //Designated session

                    net.movedToGame = true;
                    GameServerController.AuthorizedAccounts.Remove(net.CurrentAccount.AccountId);
                    server.CurrentConnection.SendAsync(new NET_AccountInfo(net.CurrentAccount));
                    server.CurrentAuthorized.Add(net.CurrentAccount.AccountId);
                    net.SendAsync(new NP_SendGameAuthorization(server, cookie));
                }
            }
            else
            {
                Logger.Trace("Requested a non-existent server ID:" + serverId);
                net.Dispose();
            }
        }
        private static void Handle_CAEnterWorld_0x0B(ArcheAgeConnection net, PacketReader reader)
        {
            //net.SendAsyncHex(new NP_Hex("13000A008D0EC89A0E003132372E302E302E31D704"));
            //0B00 0D00 00000000 00000000 01
            int        p_from   = reader.ReadLEInt32();
            int        p_to     = reader.ReadLEInt32();
            byte       serverId = reader.ReadByte(); //serverId
            GameServer server   = GameServerController.CurrentGameServers.FirstOrDefault(n => n.Value.Id == serverId).Value;

            if (server != null && server.CurrentConnection != null)
            {
                if (GameServerController.AuthorizedAccounts.ContainsKey(net.CurrentAccount.AccountId))
                {
                    net.CurrentAccount.LastEnteredTime = Utility.CurrentTimeMilliseconds();
                    net.CurrentAccount.LastIp          = net.ToString(); // IP
                    // генерируем cookie
                    Random random = new Random();
                    int    cookie = random.Next(255);
                    cookie += random.Next(255) << 8;
                    cookie += random.Next(255) << 16;
                    cookie += random.Next(255) << 24;
                    net.CurrentAccount.Session = cookie; //Designated session
                    //Передаем управление Гейм серверу
                    net.MovedToGame = true;
                    GameServerController.AuthorizedAccounts.Remove(net.CurrentAccount.AccountId);
                    //отсылаем Гейм серверу информацию об аккаунте
                    server.CurrentConnection.SendAsync(new NET_AccountInfo(clientVersion, net.CurrentAccount));
                    server.CurrentAuthorized.Add(net.CurrentAccount.AccountId);
                    //отсылаем Клиенту информацию о куках
                    net.SendAsync(new AcWorldCookie_0X0A(clientVersion, server, cookie));
                }
            }
            else
            {
                Logger.Trace("No serverID requested:" + serverId);
                net.Dispose();
            }
        }
        private static void Handle_SignIn(ArcheAgeConnection net, PacketReader reader)
        {
            reader.Offset += 12; //Static Data - 0A 00 00 00 07 00 00 00 00 00
            int m_RLoginLength = reader.ReadLEInt16();

            reader.Offset += 2;
            string  m_RLogin  = reader.ReadString(m_RLoginLength); //Reading Login
            Account n_Current = AccountHolder.AccountList.FirstOrDefault(n => n.Name == m_RLogin);

            if (n_Current == null)
            {
                //Make New Temporary
                if (Settings.Default.Account_AutoCreation)
                {
                    Account m_New = new Account
                    {
                        AccountId       = AccountHolder.AccountList.Count + 1,
                        LastEnteredTime = Utility.CurrentTimeMilliseconds(),
                        AccessLevel     = 0,
                        LastIp          = net.ToString(),
                        Membership      = 0,
                        Name            = m_RLogin
                    };
                    net.CurrentAccount = m_New;
                    AccountHolder.AccountList.Add(m_New);
                }
                else
                {
                    net.CurrentAccount = null;
                }
            }
            else
            {
                net.CurrentAccount = n_Current;
            }
            // net.SendAsync(new NP_PasswordCorrect(1));
            net.SendAsync(new NP_ServerList(clientVersion));
        }
Beispiel #17
0
        private static void Handle_SignIn_Continue(ArcheAgeConnection net, PacketReader reader)
        {
            //HOW TO DECRYPT IT ????
            string password = "";
            if (net.CurrentAccount == null)
            {
                net.SendAsync(new NP_FailLogin());
                return;
            }

            /* TODO
            if (net.CurrentAccount.Password == null)
            {
                //Means - New Account.
                net.CurrentAccount.Password = password;
            }
            else
            {
                //Checking Password
                if (net.CurrentAccount.Password != password)
                {
                    net.SendAsync(new NP_FailLogin());
                    return;
                }
            }
            */

            net.CurrentAccount.Session = net.GetHashCode();
            net.SendAsync(new NP_PasswordCorrect(net.CurrentAccount.Session));
            Logger.Trace("Account Logged In: " + net.CurrentAccount.Name);
            GameServerController.AuthorizedAccounts.Add(net.CurrentAccount.AccountId, net.CurrentAccount);
        }
 private static void Handle_RequestServerList(ArcheAgeConnection net, PacketReader reader)
 {
     byte[] unknown = reader.ReadByteArray(8); //unk?
     net.SendAsync(new NP_ServerList(clientVersion));
 }
 //Return server connection into packets
 private static void Handle_0d(ArcheAgeConnection net, PacketReader reader)
 {
     net.SendAsync0d(new NP_PasswordCorrect(1));
     //net.SendAsync(new NP_ServerList());
 }
 //Send server list (based on packet capture)
 private static void Handle_05(ArcheAgeConnection net, PacketReader reader)
 {
     net.SendAsyncHex(new NP_PasswordCorrect(1));
 }
Beispiel #21
0
        private static void Handle_SignIn(ArcheAgeConnection net, PacketReader reader)
        {
            reader.Offset += 10; //Static Data - 0A 00 00 00 07 00 00 00 00 00

            string m_RLogin = reader.ReadStringSafe(reader.ReadLEInt16()); //Reading Login

            Account n_Current = AccountHolder.AccountList.FirstOrDefault(n => n.Name == m_RLogin);
            if (n_Current == null)
            {
                //Make New Temporary
                if (Settings.Default.Account_AutoCreation)
                {
                    Account m_New = new Account();
                    m_New.AccountId = AccountHolder.AccountList.Count + 1;
                    m_New.LastEnteredTime = Utility.CurrentTimeMilliseconds();
                    m_New.AccessLevel = 0;
                    m_New.LastIp = net.ToString();
                    m_New.Membership = 0;
                    m_New.Name = m_RLogin;
                    net.CurrentAccount = m_New;
                    AccountHolder.AccountList.Add(m_New);
                }
                else
                    net.CurrentAccount = null;
            }
            else
            {
                net.CurrentAccount = n_Current;
            }
            net.SendAsync(new NP_AcceptLogin());
            net.SendAsync(new NP_AESKey());
        }
        /// <summary>
        /// для версии2014 года
        /// </summary>
        /// <param name="net"></param>
        /// <param name="reader"></param>
        private static void Handle_CARequestAuth_0X04(ArcheAgeConnection net, PacketReader reader)
        {
            //3F00 0400 0A000000 0700000000 08000000000000000000 0600 616174657374200031E34F2B72D93BB25D5F27BE8A94C47800000000000000000000000000000000
            //3F00 0400 0A000000 0700000000 08000000000000000000 0600 616174657374200031E34F2B72D93BB25D5F27BE8A94C47800000000000000000000000000000000

            reader.Offset += 19;                                           //скипаем 19 байт
            int    m_RUidLength = reader.ReadLEInt16();                    //длина строки
            string m_Uid        = reader.ReadString(m_RUidLength);         //считываем ID
            //long accId = Convert.ToInt64(m_Uid);
            int     m_RtokenLength = reader.ReadLEInt16();                 // длина строки
            string  m_RToken       = reader.ReadHexString(m_RtokenLength); //считываем токен
            Account n_Current      = AccountHolder.AccountList.FirstOrDefault(n => n.Name == m_Uid);

            if (n_Current != null)
            {
                Logger.Trace("Account ID: " + n_Current.AccountId + " & Account Name: " + n_Current.Name + " is landing");
                //account numberexist
                if (n_Current.Token.ToLower() == m_RToken.ToLower())
                {
                    net.CurrentAccount = n_Current;
                    if (GameServerController.AuthorizedAccounts.ContainsKey(net.CurrentAccount.AccountId))
                    {
                        //Удалим результаты предыдущего коннекта для нормального реконнекта
                        GameServerController.AuthorizedAccounts.Remove(net.CurrentAccount.AccountId);
                    }
                    //Write account number information Write Online account list
                    GameServerController.AuthorizedAccounts.Add(net.CurrentAccount.AccountId, net.CurrentAccount);
                    Logger.Trace("Account ID: " + n_Current.AccountId + " & Account Name: " + n_Current.Name + " landing success");
                    //net.SendAsyncHex(new NP_Hex("0C00000000000300000000000000"));
                    net.SendAsync(new AcJoinResponse_0X00(clientVersion));
                    //net.SendAsyncHex(new NP_Hex("280003005833000020003236393631326537613630393431313862623735303764626334326261353934"));
                    net.SendAsync(new AcAuthResponse_0X03(clientVersion, net));
                    //net.SendAsyncHex(new NP_Hex("0C00000000000300000000000000"));
                    //net.SendAsyncHex(new NP_Hex("0C00000000000600000000000000"));
                    //    000000000600000000000000
                    //0C00000000000300000000000000
                    //03005833000020003236393631326537613630393431313862623735303764626334326261353934
                    return;
                }
                Logger.Trace("Account ID: " + n_Current.AccountId + " & Account Name: " + n_Current.Name +
                             " token verification failed:" + m_RToken.ToLower());
            }
            else
            {
                Logger.Trace("Client try to login to a nonexistent account: " + m_Uid);
                //Make New Temporary
                if (Settings.Default.Account_AutoCreation)
                {
                    Logger.Trace("Create new account: " + m_Uid);
                    Account m_New = new Account
                    {
                        AccountId       = AccountHolder.AccountList.Count + 1,
                        LastEnteredTime = Utility.CurrentTimeMilliseconds(),
                        AccessLevel     = 1,
                        LastIp          = net.ToString(),
                        Membership      = 1,
                        Name            = m_Uid,
                        Password        = "******",
                        Token           = m_RToken,
                        Characters      = 0
                    };
                    net.CurrentAccount = m_New;
                    AccountHolder.InsertOrUpdate(m_New);
                    //Write account number information Write Online account list
                    GameServerController.AuthorizedAccounts.Add(net.CurrentAccount.AccountId, net.CurrentAccount);
                    Logger.Trace("Account ID: " + net.CurrentAccount.AccountId + " & Account Name: " + net.CurrentAccount.Name + " landing success");
                    net.SendAsyncHex(new NP_Hex("0C00000000000300000000000000"));
                    //net.SendAsync(new AcJoinResponse_0X00(clientVersion));
                    net.SendAsyncHex(new NP_Hex("280003005833000020003236393631326537613630393431313862623735303764626334326261353934"));
                    //net.SendAsync(new AcAuthResponse_0X03(clientVersion, net));
                    return;
                }

                net.CurrentAccount = null;
                Logger.Trace("Сan not create account: " + m_Uid);
            }
            //If the front did not terminate, then the account number failed to log in
            net.SendAsync(new NP_ACLoginDenied_0x0C());
        }
 private static void Handle_CAListWorld_0x0A(ArcheAgeConnection net, PacketReader reader)
 {
     net.SendAsync(new AcWorldList_0X08(clientVersion, net));
     //net.SendAsyncHex(new NP_Hex("A802080018010A00D09BD183D186D0B8D0B90101000200000202020000020E00D09AD0B8D0BFD180D0BED0B7D0B00101000200000202020000031000D09CD0B5D0BBD0B8D181D0B0D180D0B00101000200000202020000040800D0A2D0B0D18FD0BD0101000200000202020000051200D090D180D0B0D0BDD0B7D0B5D0B1D0B8D18F0101000200000202020000060800D09ED0BBD0BBD0BE0101000200000202020000070800D090D0BDD0BDD0B00101000200000202020000080E00D090D180D0B0D0BDD0B7D0B5D0B10101000200000202020000090800D098D0BDD0BED18501010002000002020200000A0800D094D0B6D0B8D0BD01020000000000000000000B0E00D09ED180D185D0B8D0B4D0BDD0B001010000000000000000000C0A00D09DD0B0D0B8D0BCD0B001010000000000000000000D1000D090D0BDD182D0B0D0BBD0BBD0BED0BD01010002000002020200000E0E00D0A8D0B0D182D0B8D0B3D0BED0BD01010002000002020200000F0800D090D0B9D18DD1800101000200000202020000101000D0A1D0B0D0BBD18CD184D0B8D180D0B00102000000000000000000110A00D094D0B0D183D182D0B00101000000000000000000120E00D09AD0B0D0BBD0B5D0B8D0BBD18C0101000000000000000000130C00D09AD0B8D180D0B8D0BED1810101000000000000000000140E00D090D0BAD180D0B8D182D0B5D1810101000000000000000000150C00D0ADD0BDD188D0B0D0BAD0B00101000000000000000000160E00D090D188D0B0D0B1D0B5D0BBD18C0101000000000000000000170E00D09AD0B0D0BFD0B0D0B3D0B0D0BD0101000000000000000000180A00D09DD0B5D0B2D0B5D1800102000000000000000000018FA90D000BFF091A000B004A757374746F636865636B010210000E4FC3755AE17949B1F626620F354A930000000000000000"));
 }
 private static void Handle_CACancelEnterWorld_0X0C(ArcheAgeConnection net, PacketReader reader)
 {
     //var unknown = reader.ReadByteArray(8); //unk?
     net.SendAsync(new AcWorldList_0X08(clientVersion, net));
     //net.SendAsync(new AcAccountWarned_0X0D(clientVersion)); //не обязателен
 }
        /// <summary>
        /// Client choose server to send serverIP, server port number, sessionID
        ///</summary>>
        private static void Handle_CARequestReconnect_0X0D(ArcheAgeConnection net, PacketReader reader)
        {
            /*
             * [7]             C>s             0ms.            23:56:45 .957      10.03.18
             * -------------------------------------------------------------------------------
             * TType: ArcheageServer: undef   Parse: 6           EnCode: off
             * ------- 0  1  2  3  4  5  6  7 -  8  9  A  B  C  D  E  F    -------------------
             * 000000 0B 00 0D 00 00 00 00 00 | 00 00 00 00 01              .............
             * -------------------------------------------------------------------------------
             * Archeage: "CARequestReconnect"               size: 13     prot: 2  $002
             * Addr:  Size:    Type:         Description:     Value:
             * 0000     2   word          psize             11         | $000B
             * 0002     2   word          ID                13         | $000D
             * 0004     4   integer       p_from            0          | $00000000
             * 0008     4   integer       p_to              0          | $00000000
             * 000C     1   byte          serverId          1          | $01
             *          4   integer       cookie
             *          ?   WideStr[byte] MAC
             */
            //0B00 0D00 00000000 00000000 01
            //reader.Offset += 8; //Undefined Data
            int        p_from   = reader.ReadLEInt32();
            int        p_to     = reader.ReadLEInt32();
            byte       serverId = reader.ReadByte(); //serverId
            GameServer server   = GameServerController.CurrentGameServers.FirstOrDefault(n => n.Value.Id == serverId).Value;

            if (server != null && server.CurrentConnection != null)
            {
                if (GameServerController.AuthorizedAccounts.ContainsKey(net.CurrentAccount.AccountId))
                {
                    net.CurrentAccount.LastEnteredTime = Utility.CurrentTimeMilliseconds();
                    net.CurrentAccount.LastIp          = net.ToString(); // IP
                    //net.CurrentAccount.AccountId = net.CurrentAccount.AccountId; //
                    //create session (cookie)
                    ///var cookie = 128665876; //$07AB4914 - для теста
                    ///net.CurrentAccount.Session = cookie;
                    //AccountHolder.AccountList.FirstOrDefault(n => n.AccId == Convert.ToInt32(cookie));

                    // генерируем cookie
                    Random random = new Random();
                    int    cookie = random.Next(255);
                    cookie += random.Next(255) << 8;
                    cookie += random.Next(255) << 16;
                    cookie += random.Next(255) << 24;
                    net.CurrentAccount.Session = cookie; //Designated session

                    //Передаем управление Гейм серверу
                    net.movedToGame = true;
                    GameServerController.AuthorizedAccounts.Remove(net.CurrentAccount.AccountId);
                    //отсылаем Гейм серверу информацию об аккаунте
                    server.CurrentConnection.SendAsync(new NET_AccountInfo(net.CurrentAccount));
                    server.CurrentAuthorized.Add(net.CurrentAccount.AccountId);
                    //отсылаем Клиенту информацию о куках
                    net.SendAsync(new AcWorldCookie_0X0A(server, cookie));
                }
            }
            else
            {
                Logger.Trace("No serverID requested:" + serverId);
                net.Dispose();
            }
        }
        /// <summary>
        /// 0x06_CAChallengeResponse2Packet - token Verification mode
        /// uid+token
        /// </summary>
        private static void Handle_CAChallengeResponse2_0X06(ArcheAgeConnection net, PacketReader reader)
        {
            reader.Offset += 19;                                           //скипаем 19 байт
            int     m_RUidLength   = reader.ReadLEInt16();                 //длина строки
            string  m_Uid          = reader.ReadString(m_RUidLength);      //считываем имя "aatest"
            int     m_RtokenLength = reader.ReadLEInt16();                 // длина строки
            string  m_RToken       = reader.ReadHexString(m_RtokenLength); //считываем токен
            Account n_Current      = AccountHolder.AccountList.FirstOrDefault(n => n.Name == m_Uid);

            if (n_Current != null)
            {
                Logger.Trace("Account ID: " + n_Current.AccountId + " & Account Name: " + n_Current.Name + " is landing");
                //account numberexist
                if (n_Current.Token.ToLower() == m_RToken.ToLower())
                {
                    net.CurrentAccount = n_Current;
                    if (GameServerController.AuthorizedAccounts.ContainsKey(net.CurrentAccount.AccountId))
                    {
                        //Удалим результаты предыдущего коннекта для нормального реконнекта
                        GameServerController.AuthorizedAccounts.Remove(net.CurrentAccount.AccountId);
                    }
                    //Write account number information Write Online account list
                    GameServerController.AuthorizedAccounts.Add(net.CurrentAccount.AccountId, net.CurrentAccount);
                    Logger.Trace("Account ID: " + n_Current.AccountId + " & Account Name: " + n_Current.Name + " landing success");
                    net.SendAsync(new AcJoinResponse_0X00(clientVersion));
                    net.SendAsync(new AcAuthResponse_0X03(clientVersion, net));
                    return;
                }
                Logger.Trace("Account ID: " + n_Current.AccountId + " & Account Name: " + n_Current.Name +
                             " token verification failed:" + m_RToken.ToLower());
            }
            else
            {
                Logger.Trace("Client try to login to a nonexistent account: " + m_Uid);
                //Make New Temporary
                if (Settings.Default.Account_AutoCreation)
                {
                    Logger.Trace("Create new account: " + m_Uid);
                    Account m_New = new Account
                    {
                        AccountId       = AccountHolder.AccountList.Count + 1,
                        LastEnteredTime = Utility.CurrentTimeMilliseconds(),
                        AccessLevel     = 1,
                        LastIp          = net.ToString(),
                        Membership      = 1,
                        Name            = m_Uid,
                        Password        = "******",
                        Token           = m_RToken,
                        Characters      = 0
                    };
                    net.CurrentAccount = m_New;
                    AccountHolder.InsertOrUpdate(m_New);
                    //Write account number information Write Online account list
                    GameServerController.AuthorizedAccounts.Add(net.CurrentAccount.AccountId, net.CurrentAccount);
                    Logger.Trace("Account ID: " + net.CurrentAccount.AccountId + " & Account Name: " + net.CurrentAccount.Name + " landing success");
                    net.SendAsync(new AcJoinResponse_0X00(clientVersion));
                    net.SendAsync(new AcAuthResponse_0X03(clientVersion, net));
                    return;
                }
                else
                {
                    net.CurrentAccount = null;
                    Logger.Trace("Сan not create account: " + m_Uid);
                }
            }
            //If the front did not terminate, then the account number failed to log in
            net.SendAsync(new NP_ACLoginDenied_0x0C());
        }
        public AcAuthResponse_0X03(string clientVersion, ArcheAgeConnection net) : base(0x03, true)
        {
            switch (clientVersion)
            {
            case "1":
                //2800 0300 58330000 2000 3236393631326537613630393431313862623735303764626334326261353934
                ns.Write((int)net.CurrentAccount.AccountId);     // записываем AccountID
                //wsk - wide string key, в каждой сесии один и тот-же, даже при перелогине (выборе сервера)
                string wsk = "A18D7A05E22E459BD1A819222B821030"; //для теста
                ns.WriteASCIIFixed(wsk, wsk.Length);
                break;

            /*
             * [3]             S>c             0ms.            2:25:10 .845      23.06.18
             * -------------------------------------------------------------------------------
             * TType: ArcheageServer: undef   Parse: 6           EnCode: off
             * ------- 0  1  2  3  4  5  6  7 -  8  9  A  B  C  D  E  F    -------------------
             * 000000 2D 00 03 00 1A C7 00 00 | 00 00 00 00 20 00 41 31     -....Ç...... .A1
             * 000010 38 44 37 41 30 35 45 32 | 32 45 34 35 39 42 44 31     8D7A05E22E459BD1
             * 000020 41 38 31 39 32 32 32 42 | 38 32 31 30 33 30 00        A819222B821030.
             * -------------------------------------------------------------------------------
             * Archeage: "ACAuthResponse"                   size: 47     prot: 2  $002
             *          Addr:  Size:    Type:         Description:     Value:
             *          0000     2   word          psize             45         | $002D
             * 0002     2   word          ID                3          | $0003
             * 0004     8   int64         accountId         50970      | $0000C71A
             * 000C    34   WideStr[byte] wsk               A18D7A05E22E459BD1A819222B821030  ($)
             * 002E     1   byte          slotCount         0          | $00
             *
             * 2D00 0300 1AC7000000000000 2000 3346393243304532324430383344313843333233353433363932413442373630 00
             */
            //v.3.0.3.0
            case "3":
                ns.Write((long)net.CurrentAccount.AccountId); // записываем AccountID
                                                              //wsk - wide string key, в каждой сесии один и тот-же, даже при перелогине (выборе сервера)
                wsk = "A18D7A05E22E459BD1A819222B821030";     //для теста
                ns.WriteUTF8Fixed(wsk, wsk.Length);
                //slotCount
                ns.Write((byte)0x00);
                break;

            default:
                /*
                 * [3]             S>c             0ms.            14:42:03 .045      23.07.18
                 * -------------------------------------------------------------------------------
                 * TType: ArcheageServer: LS1     Parse: 6           EnCode: off
                 * ------- 0  1  2  3  4  5  6  7 -  8  9  A  B  C  D  E  F    -------------------
                 * 000000 2F 00 03 00 5A 43 05 00 | 00 00 00 00 20 00 63 34     /...ZC...... .c4
                 * 000010 30 39 39 32 30 36 63 38 | 66 32 34 38 63 35 39 65     099206c8f248c59e
                 * 000020 66 64 63 33 66 36 61 63 | 66 66 64 66 66 37 00 00     fdc3f6acffdff7..
                 * 000030 00                                                    .
                 * -------------------------------------------------------------------------------
                 * Archeage: "ACAuthResponse"                   size: 49     prot: 2  $002
                 * Addr:  Size:    Type:         Description:     Value:
                 * 0000     2   word          psize             47         | $002F
                 * 0002     2   word          ID                3          | $0003
                 * 0004     8   int64         accountId         344922     | $0005435A
                 * 000C    34   WideStr[byte] wsk               c4099206c8f248c59efdc3f6acffdff7  ($)
                 * 002E     1   byte          slotCount         0          | $00
                 * 2F00 0300 5A43050000000000 2000 6334303939323036633866323438633539656664633366366163666664666637 0000 00
                 */
                ns.Write((long)net.CurrentAccount.AccountId); // записываем AccountID
                //wsk - wide string key, в каждой сесии один и тот-же, даже при перелогине (выборе сервера)
                wsk = "c4099206c8f248c59efdc3f6acffdff7";     //для теста
                ns.WriteUTF8Fixed(wsk, wsk.Length);
                ns.Write((short)0x00);
                //slotCount
                ns.Write((byte)0x00);
                break;
            }
        }
        /// <summary>
        /// Send server list
        /// </summary>
        public AcWorldList_0X08(string clientVersion, ArcheAgeConnection net) : base(0x08, true)
        {
            switch (clientVersion)
            {
            case "1":
                ns.Write((byte)1);     // Count
                ns.Write((byte)1);
                string projectName = "AAPlay.ru";
                ns.WriteASCIIFixed(projectName, projectName.Length);
                ns.Write((byte)1);
                ns.Write((short)0);
                ns.Write((short)0);
                ns.Write((int)0);
                ns.Write((short)0);
                ns.Write((byte)1);     // Count
                ns.Write((int)1);
                ns.Write((byte)1);
                ns.Write((int)1);
                projectName = "AAPlay.ru";
                ns.WriteASCIIFixed(projectName, projectName.Length);
                ns.Write((byte)1);
                ns.Write((byte)1);
                projectName = "";
                ns.WriteASCIIFixed(projectName, projectName.Length);
                ns.Write((int)0);
                ns.Write((int)0);
                break;

            case "3":
                /*
                 * [5]             S>c             0ms.            23:03:31 .885      23.06.18
                 * -------------------------------------------------------------------------------
                 * TType: ArcheageServer: LS1     Parse: 6           EnCode: off
                 * ------- 0  1  2  3  4  5  6  7 -  8  9  A  B  C  D  E  F    -------------------
                 * 000000 7F 00 08 00 01 01 01 00 | 09 00 41 72 63 68 65 52     .........ArcheR
                 * 000010 61 67 65 01 00 00 00 00 | 00 00 00 00 00 00 02 1A     age.............
                 * 000020 C7 00 00 00 00 00 00 01 | D7 94 01 00 06 00 52 65     З.......Ч”....Re
                 * 000030 6D 6F 74 61 03 02 10 00 | DC 0D 0C FC D3 E0 18 47     mota....Ь..ьУа.G
                 * 000040 AD 2A 5D 55 EA 47 1C DF | 00 00 00 00 00 00 00 00     ­*]UкG.Я........
                 * 000050 1A C7 00 00 00 00 00 00 | 01 96 E7 01 00 06 00 44     .З.......–з....D
                 * 000060 65 76 65 6C 6F 01 02 10 | 00 CE CB 85 98 F5 41 B0     evelo....ОЛ…˜хA°
                 * 000070 4B A6 74 C7 83 4D DC 5D | 14 00 00 00 00 00 00 00     K¦tЗѓMЬ]........
                 * 000080 00                                                    .
                 * -------------------------------------------------------------------------------
                 * Archeage: "ACWorldList"                      size: 129    prot: 2  $002
                 * Addr:  Size:    Type:         Description:     Value:
                 * 0000     2   word          psize             127        | $007F
                 * 0002     2   word          ID                8          | $0008
                 * 0004     1   byte          count             1          | $01
                 * 0005     1   byte          id                1          | $01
                 * 0006     1   byte          type              1          | $01
                 * 0007     1   byte          color             0          | $00
                 * 0008    11   WideStr[byte] ServerName        ArcheRage  ($)
                 * 0013     1   byte          online            1          | $01
                 * 0014     1   byte          status            0          | $00
                 * 0015     1   byte          __                0          | $00
                 * 0016     1   byte          nuiane            0          | $00
                 * 0017     1   byte          __                0          | $00
                 * 0018     1   byte          dwarf             0          | $00
                 * 0019     1   byte          elf               0          | $00
                 * 001A     1   byte          harniec           0          | $00
                 * 001B     1   byte          ferre             0          | $00
                 * 001C     1   byte          warmozu           0          | $00
                 * 001D     1   byte          a                 0          | $00
                 * 001E     1   byte          chCount           2          | $02
                 * 001F     8   int64         accountId         50970      | $0000C71A
                 * 0027     1   byte          worldId           1          | $01
                 * 0028     4   integer       type              103639     | $000194D7
                 * 002C     8   WideStr[byte] CharName          Remota  ($)
                 * 0034     1   byte          CharRace          гномы  ($03)
                 * 0035     1   byte          CharGender        Ж  ($02)
                 * 0036    18   WideStr[byte] GUID              DC0D0CFCD3E01847AD2A5D55EA471CDF  ($)
                 * 0048     8   int64         v                 0          | $00000000
                 * 0050     8   int64         accountId         50970      | $0000C71A
                 * 0058     1   byte          worldId           1          | $01
                 * 0059     4   integer       type              124822     | $0001E796
                 * 005D     8   WideStr[byte] CharName          Develo  ($)
                 * 0065     1   byte          CharRace          нуиане  ($01)
                 * 0066     1   byte          CharGender        Ж  ($02)
                 * 0067    18   WideStr[byte] GUID              CECB8598F541B04BA674C7834DDC5D14  ($)
                 * 0079     8   int64         v                 0          | $00000000
                 */
                //4E000800  //пробная запись с одним чаром Remota - гномка
                //ns.WriteHex("0101010009004172636865526167650100000000000000000000011AC70000000000000152770100060052656D6F7461030210001F3F1EE73B4D974BA9F5659BA68279570000000000000000");
                //1D000800  //пробная запись - сервер ArcheRage, нет чаров, начало создания
                ////ns.WriteHex("010101000900417263686552616765010000000000000000000000");
                //v.3.0.3.0
                //Посылаем список серверов, количество чаров на аккаунтах
                var m_Current = GameServerController.CurrentGameServers.Values.ToList();
                //Write The number of servers
                ns.Write((byte)m_Current.Count);
                //Информация по серверу
                foreach (var server in m_Current)
                {
                    ns.Write((byte)server.Id);
                    ns.Write((byte)0x01);     //надпись в списке серверов 00-нет надписи, 01- НОВЫЙ, 02-ОБЪЕДИНЕННЫЙ, 03-ОБЪЕДИНЕННЫЙ, 04-нет надписи
                    ns.Write((byte)0x02);     //цвут надписи в списке серверов 00-синий, 01- зеленая, 02-фиолет, 03, 04, 08-красный, 0x10-
                    ns.WriteUTF8Fixed(server.Name, Encoding.UTF8.GetByteCount(server.Name));
                    //ns.WriteASCIIFixed(server.Name, server.Name.Length);
                    var online = server.IsOnline() ? (byte)0x01 : (byte)0x02; //1 Online 2 Offline
                    ns.Write((byte)online);                                   //Server Status - 0x00
                    var status = server.CurrentAuthorized.Count >= server.MaxPlayers ? 0x01 : 0x00;
                    ns.Write((byte)status);                                   //Server Status - 0x00 - normal / 0x01 - load / 0x02 - queue
                    ns.Write((byte)0x00);                                     //unknown
                                                                              //The following sections are the racial restrictions on server creation for this server selection interface 0 Normal 2 Prohibited
                    ns.Write((byte)0x00);                                     //Noah
                    ns.Write((byte)0x00);
                    ns.Write((byte)0x00);                                     //Dwarf family
                    ns.Write((byte)0x00);                                     //Elf
                    ns.Write((byte)0x00);                                     //Haliland
                    ns.Write((byte)0x00);                                     //Animal clan
                    ns.Write((byte)0x00);
                    ns.Write((byte)0x00);                                     //War Mozu
                }

                CharacterHolder.LoadCharacterData();            //считываем героев
                byte CharCount = net.CurrentAccount.Characters; //смотрим сколько героев на аккаунте
                                                                //Write The current user account number
                ns.Write((byte)CharCount);                      //CharCount
                if (CharCount != 0)
                {
                    long m_AccountId = net.CurrentAccount.AccountId;     //считываем только наших героев
                    foreach (Character n_Current in CharacterHolder.CharactersList)
                    {
                        if (n_Current.AccountId == m_AccountId)
                        {
                            ns.Write((long)n_Current.AccountId); //AccountID
                            ns.Write((byte)n_Current.WorldId);   //WorldID
                            ns.Write((int)n_Current.Type);       //type
                            string charname = n_Current.CharName;
                            ns.WriteASCIIFixed(charname, charname.Length);
                            ns.Write((byte)n_Current.CharRace);   //Char Race - 01=нуиане, 03 = гномы
                            ns.Write((byte)n_Current.CharGender); //CharGender - 01-М, 02=Ж
                            string uid = n_Current.GUID;          //UID - Параметры чара
                            ns.WriteHex(uid, uid.Length);
                            ns.Write((long)n_Current.V);          //v
                        }
                    }
                }

                break;

            default:

                break;
            }
        }
Beispiel #29
0
 private static void Handle_RequestServerList(ArcheAgeConnection net, PacketReader reader)
 {
     byte[] unknown = reader.ReadByteArray(8); //unk?
     net.SendAsync(new NP_ServerList());
 }
        /// <summary>
        /// Send server list
        /// </summary>
        public AcWorldList_0X08(string clientVersion, ArcheAgeConnection net) : base(0x08, true)
        {
            switch (clientVersion)
            {
            case "1":
                var m_Current = GameServerController.CurrentGameServers.Values.ToList();
                ns.Write((byte)m_Current.Count);     // Count
                foreach (var server in m_Current)
                {
                    ns.Write((byte)server.Id);
                    ns.WriteUTF8Fixed(server.Name, Encoding.UTF8.GetByteCount(server.Name));
                    var online = server.IsOnline() ? (byte)0x01 : (byte)0x02; //1 Online 2 Offline
                    ns.Write((byte)online);                                   //Server Status - 0x01
                    switch (online)
                    {
                    case 0:
                        break;

                    default:
                        var status = server.CurrentAuthorized.Count >= server.MaxPlayers ? 0x01 : 0x00;
                        ns.Write((byte)status);         //Server Status - 0x00 - normal / 0x01 - load / 0x02 - queue
                        //The following sections are the racial restrictions on server creation for this server selection interface 0 Normal 2 Prohibited
                        for (int i = 0; i < 9; i++)
                        {
                            ns.Write((byte)0x00);         //rcon
                        }
                        break;
                    }
                }
                int CharCount = CharacterHolder.LoadCharacterData(net.CurrentAccount.AccountId); //считываем данные персонажей и их количество
                ns.Write((byte)CharCount);                                                       //CharCount

                net.CurrentAccount.Characters = (byte)CharCount;

                if (CharCount != 0)
                {
                    long m_AccountId = net.CurrentAccount.AccountId;     //считываем данные только наших персонажей
                    foreach (Character n_Current in CharacterHolder.CharactersList)
                    {
                        if (n_Current.AccountId == m_AccountId)
                        {
                            ns.Write((int)n_Current.AccountId); //AccountID
                            ns.Write((byte)n_Current.WorldId);  //WorldID
                            ns.Write((int)n_Current.Type);      //charID
                            string charname = n_Current.CharName;
                            ns.WriteASCIIFixed(charname, charname.Length);
                            ns.Write((byte)n_Current.CharRace);   //CharRace
                            ns.Write((byte)n_Current.CharGender); //CharGender
                            string uid = n_Current.GUID;          // = ""; //UID - Параметры чара, возможно пустая строка!
                            ns.WriteHex(uid, uid.Length);
                            ns.Write((long)n_Current.V);          //v
                        }
                    }
                }

                AccountHolder.InsertOrUpdate(net.CurrentAccount);

                break;

            case "3":
                //4E000800  //пробная запись с одним чаром Remota - гномка
                //ns.WriteHex("0101010009004172636865526167650100000000000000000000011AC70000000000000152770100060052656D6F7461030210001F3F1EE73B4D974BA9F5659BA68279570000000000000000");
                //1D000800  //пробная запись - сервер ArcheRage, нет чаров, начало создания
                ////ns.WriteHex("010101000900417263686552616765010000000000000000000000");
                //v.3.0.3.0
                //Посылаем список серверов, количество чаров на аккаунтах
                m_Current = GameServerController.CurrentGameServers.Values.ToList();
                //Write The number of servers
                ns.Write((byte)m_Current.Count);
                //Информация по серверу
                foreach (var server in m_Current)
                {
                    ns.Write((byte)server.Id);
                    ns.Write((byte)0x01);     //надпись в списке серверов 00-нет надписи, 01- НОВЫЙ, 02-ОБЪЕДИНЕННЫЙ, 03-ОБЪЕДИНЕННЫЙ, 04-нет надписи
                    ns.Write((byte)0x02);     //цвут надписи в списке серверов 00-синий, 01- зеленая, 02-фиолет, 03, 04, 08-красный, 0x10-
                    ns.WriteUTF8Fixed(server.Name, Encoding.UTF8.GetByteCount(server.Name));
                    //ns.WriteASCIIFixed(server.Name, server.Name.Length);
                    var online = server.IsOnline() ? (byte)0x01 : (byte)0x02;                //1 Online 2 Offline
                    ns.Write((byte)online);                                                  //Server Status - 0x00
                    var status = server.CurrentAuthorized.Count >= server.MaxPlayers ? 0x01 : 0x00;
                    ns.Write((byte)status);                                                  //Server Status - 0x00 - normal / 0x01 - load / 0x02 - queue
                    //The following sections are the racial restrictions on server creation for this server selection interface 0 Normal 2 Prohibited
                    ns.Write((byte)0x00);                                                    //unknown
                    ns.Write((byte)0x00);                                                    //Noah
                    ns.Write((byte)0x00);
                    ns.Write((byte)0x00);                                                    //Dwarf family
                    ns.Write((byte)0x00);                                                    //Elf
                    ns.Write((byte)0x00);                                                    //Haliland
                    ns.Write((byte)0x00);                                                    //Animal clan
                    ns.Write((byte)0x00);
                    ns.Write((byte)0x00);                                                    //War Mozu
                }
                CharCount = CharacterHolder.LoadCharacterData(net.CurrentAccount.AccountId); //считываем данные персонажей и их количество
                //Write The current user account number
                ns.Write((byte)CharCount);                                                   //CharCount
                if (CharCount != 0)
                {
                    long m_AccountId = net.CurrentAccount.AccountId;     //считываем данные только наших персонажей
                    foreach (Character n_Current in CharacterHolder.CharactersList)
                    {
                        if (n_Current.AccountId == m_AccountId)
                        {
                            ns.Write((long)n_Current.AccountId); //AccountID
                            ns.Write((byte)n_Current.WorldId);   //WorldID
                            ns.Write((int)n_Current.Type);       //type
                            string charname = n_Current.CharName;
                            ns.WriteASCIIFixed(charname, charname.Length);
                            ns.Write((byte)n_Current.CharRace);   //Char Race - 01=нуиане, 03 = гномы
                            ns.Write((byte)n_Current.CharGender); //CharGender - 01-М, 02=Ж
                            string uid = n_Current.GUID;          //UID - Параметры чара
                            ns.WriteHex(uid, uid.Length);
                            ns.Write((long)n_Current.V);          //v
                        }
                    }
                }
                break;

            default:
                break;
            }
        }