Ejemplo n.º 1
0
        void ArcheAgeConnection_DisconnectedEvent(object sender, EventArgs e)
        {
            if (m_CurrentAccount != null)
            {
                if (GameServerController.AuthorizedAccounts.ContainsKey(m_CurrentAccount.AccountId))
                {
                    GameServerController.AuthorizedAccounts.Remove(m_CurrentAccount.AccountId);
                }
                //Removing Account From All GameServers
                foreach (GameServer server in GameServerController.CurrentGameServers.Values)
                {
                    if (server.CurrentAuthorized.Contains(m_CurrentAccount.AccountId))
                    {
                        server.CurrentAuthorized.Remove(m_CurrentAccount.AccountId);
                    }
                }
                if (m_CurrentAccount.Password != null) //If you been fully authroized.
                {
                    m_CurrentAccount.LastEnteredTime = Utility.CurrentTimeMilliseconds();
                    AccountHolder.InsertOrUpdate(m_CurrentAccount);
                }
            }
            string arg = movedToGame ? "进入游戏" : "断开连接";

            Logger.Trace("客户端 {0} : {1}", m_CurrentAccount == null ? this.ToString() : m_CurrentAccount.Name, arg);
            Dispose();
        }
        void ArcheAgeConnection_DisconnectedEvent(object sender, EventArgs e)
        {
            if (CurrentAccount != null)
            {
                if (GameServerController.AuthorizedAccounts.ContainsKey(CurrentAccount.Session)) //AccountID
                {
                    GameServerController.AuthorizedAccounts.Remove(CurrentAccount.Session);      //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();
        }
        /// <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());
        }
        /// <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;
            }
        }
Ejemplo n.º 5
0
        /// <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());
        }