Esempio n. 1
0
        private void ReceiveLoginRejection(IRecvPacket packet)
        {
            Disconnect();
            LoginRejectionPacket p = (LoginRejectionPacket)packet;

            switch (p.Reason)
            {
            case LoginRejectionReasons.InvalidAccountPassword:
                Status = LoginClientStatus.Error_InvalidUsernamePassword;
                break;

            case LoginRejectionReasons.AccountInUse:
                Status = LoginClientStatus.Error_InUse;
                break;

            case LoginRejectionReasons.AccountBlocked:
                Status = LoginClientStatus.Error_Blocked;
                break;

            case LoginRejectionReasons.BadPassword:
                Status = LoginClientStatus.Error_BadPassword;
                break;

            case LoginRejectionReasons.IdleExceeded:
                Status = LoginClientStatus.Error_Idle;
                break;

            case LoginRejectionReasons.BadCommuncation:
                Status = LoginClientStatus.Error_BadCommunication;
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Connect to a server!
        /// </summary>
        /// <param name="host">Address of the host. Can be a website or an ip address. IP addresses should be IPv4.</param>
        /// <param name="port">Port of the server on the host.</param>
        /// <returns></returns>
        public bool Connect(string host, int port)
        {
            Status = LoginClientStatus.LoginServer_Connecting;
            bool success = m_Network.Connect(host, port);

            if (success)
            {
                Status = LoginClientStatus.LoginServer_WaitingForLogin;

                byte[] clientVersion = Settings.UltimaOnline.ClientVersion;

                if (clientVersion.Length != 4)
                {
                    Tracer.Warn("Cannot send seed packet: Version array is incorrectly sized.");
                }
                else
                {
                    m_Network.Send(new SeedPacket(1, clientVersion));
                }
            }
            else
            {
                Status = LoginClientStatus.Error_CannotConnectToServer;
            }
            return(success);
        }
Esempio n. 3
0
        private void CheckIfOkayToLogin()
        {
            // Before the client logs in, we need to know the player entity's serial, and the
            // map the player will be loading on login. If we don't have either of these, we
            // delay loading until we do.
            if (Status != LoginClientStatus.WorldServer_InWorld)
            {
                if (m_QueuedLoginConfirmPacket != null && (m_Engine.QueuedModel as WorldModel).MapIndex >= 0)
                {
                    Status = LoginClientStatus.WorldServer_InWorld;

                    m_Engine.ActivateQueuedModel();
                    if (m_Engine.ActiveModel is WorldModel)
                    {
                        ((WorldModel)m_Engine.ActiveModel).LoginSequence();
                        LoginConfirmPacket packet = m_QueuedLoginConfirmPacket;
                        PlayerMobile       player = EntityManager.GetObject <PlayerMobile>(m_QueuedLoginConfirmPacket.Serial, true);
                        if (player == null)
                        {
                            Tracer.Critical("No player object ready in CheckIfOkayToLogin().");
                        }
                        player.Move_Instant(packet.X, packet.Y, packet.Z, packet.Direction);
                        // iPlayer.SetFacing(p.Direction);
                    }
                    else
                    {
                        Tracer.Critical("Not in world model at login.");
                    }
                }
            }
            else
            {
                // already logged in, nothing else to do!
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Sends a message to the server to request a connection to the specified shard.
 /// </summary>
 /// <param name="index">The index of the shard to connect to.</param>
 public void SelectShard(int index)
 {
     if (Status == LoginClientStatus.LoginServer_HasServerList)
     {
         Status = LoginClientStatus.GameServer_Connecting;
         m_Network.Send(new SelectServerPacket(index));
     }
 }
Esempio n. 5
0
        private void ReceiveCharacterList(IRecvPacket packet)
        {
            CharacterCityListPacket p = (CharacterCityListPacket)packet;

            Characters.SetCharacterList(p.Characters);
            Characters.SetStartingLocations(p.Locations);
            Status = LoginClientStatus.GameServer_CharList;
        }
Esempio n. 6
0
        /// <summary>
        /// Disconnects from the server.
        /// </summary>
        public void Disconnect()
        {
            if (m_Network.IsConnected)
            {
                m_Network.Disconnect();
            }

            Status = LoginClientStatus.Unconnected;
        }
Esempio n. 7
0
        /// <summary>
        /// Disconnects from the server.
        /// </summary>
        public void Disconnect()
        {
            if (m_Network.IsConnected)
            {
                StopKeepAlivePackets();
                m_Network.Disconnect();
            }

            Status = LoginClientStatus.Unconnected;
        }
Esempio n. 8
0
        private void ReceiveServerRelay(IRecvPacket packet)
        {
            ServerRelayPacket p = (ServerRelayPacket)packet;

            m_ServerRelayKey = p.AccountId;
            // On OSI, upon receiving this packet, the client would disconnect and
            // log in to the specified server. Since emulated servers use the same
            // server for both shard selection and world, we don't need to disconnect.
            m_Network.IsDecompressionEnabled = true;
            Status = LoginClientStatus.LoginServer_WaitingForRelay;
        }
Esempio n. 9
0
        public LoginClient()
        {
            m_Network       = ServiceRegistry.GetService <INetworkClient>();
            m_Engine        = ServiceRegistry.GetService <UltimaGame>();
            m_UserInterface = ServiceRegistry.GetService <UserInterfaceService>();

            Status = LoginClientStatus.Unconnected;

            m_RegisteredHandlers = new List <Tuple <int, TypedPacketReceiveHandler> >();

            Initialize();
        }
Esempio n. 10
0
        public LoginClient()
        {
            ClientVersion.ClearVersion(); // only unlocked after server sends 0xbd version request packet.

            m_Network       = ServiceRegistry.GetService <INetworkClient>();
            m_Engine        = ServiceRegistry.GetService <UltimaGame>();
            m_UserInterface = ServiceRegistry.GetService <UserInterfaceService>();

            Status = LoginClientStatus.Unconnected;

            m_RegisteredHandlers = new List <Tuple <int, TypedPacketReceiveHandler> >();

            Initialize();
        }
Esempio n. 11
0
 private void ReceiveServerList(IRecvPacket packet)
 {
     ServerList.List = ((ServerListPacket)packet).Servers;
     Status          = LoginClientStatus.LoginServer_HasServerList;
 }
Esempio n. 12
0
 /// <summary>
 /// Connect to the indicated relay server.
 /// </summary>
 /// <param name="account">The username of the account to be logged in.</param>
 /// <param name="password">The password of the account to be logged in. This is encrypted in transit.</param>
 public void Relay()
 {
     Status = LoginClientStatus.LoginServer_Relaying;
     m_Network.Send(new GameLoginPacket(m_ServerRelayKey, Settings.Login.UserName, Password.ConvertToUnsecureString()));
 }
Esempio n. 13
0
        /// <summary>
        /// Attempts to login to the connected host.
        /// </summary>
        /// <param name="account">The username of the account to be logged in.</param>
        /// <param name="password">The password of the account to be logged in. This is encrypted in transit.</param>
        public void Login()
        {
            Status = LoginClientStatus.LoginServer_LoggingIn;

            m_Network.Send(new LoginPacket(Settings.Login.UserName, Password.ConvertToUnsecureString()));
        }