Example #1
0
        private void Client_OnConnected(LoginArgsContainer LoginArgs)
        {
            TSOClient.Network.Events.ProgressEvent Progress =
                new TSOClient.Network.Events.ProgressEvent(TSOClient.Events.EventCodes.PROGRESS_UPDATE);
            Progress.Done  = 1;
            Progress.Total = 2;

            if (m_CharacterCreated)
            {
                UIPacketSenders.SendCharacterCreateCity(LoginArgs, PlayerAccount.CurrentlyActiveSim);
                OnTransitionProgress(Progress);
            }
            else
            {
                UIPacketSenders.SendCityToken(NetworkFacade.Client);
                OnTransitionProgress(Progress);
            }
        }
        /// <summary>
        /// Another stage in the CityServer transition progress was done.
        /// </summary>
        /// <param name="e"></param>
        private void OnTransitionProgress(ProgressEvent e)
        {
            var stage = e.Done;

            m_LoginProgress.ProgressCaption = GameFacade.Strings.GetString("251", (stage + 4).ToString());
            m_LoginProgress.Progress = 25 * stage;
        }
        /// <summary>
        /// Received a status update from the CityServer.
        /// Occurs after sending the token.
        /// </summary>
        /// <param name="e">Status of transfer.</param>
        private void Controller_OnCityTransfer(CityTransferStatus e)
        {
            switch (e)
            {
                case CityTransferStatus.Success:
                    if (m_Dead) return; //don't create multiple please
                    TSOClient.Network.Events.ProgressEvent Progress = new ProgressEvent(EventCodes.PROGRESS_UPDATE);
                    Progress.Done = 2;
                    Progress.Total = 2;

                    //Commenting out the below line makes the city show up when creating a new Sim... o_O
                    //OnTransitionProgress(Progress);
                    GameFacade.Controller.ShowCity();
                    m_Dead = true;
                    break;
                case CityTransferStatus.GeneralError:
                    Controller_OnNetworkError(new SocketException());
                    break;
            }
        }
        /// <summary>
        /// Received a status update from the CityServer.
        /// Occurs after sending CharacterCreation packet.
        /// </summary>
        /// <param name="e">Status of character creation.</param>
        private void Controller_OnCharacterCreationStatus(CharacterCreationStatus CCStatus)
        {
            switch (CCStatus)
            {
                case CharacterCreationStatus.Success:
                    if (m_Dead) return;
                    TSOClient.Network.Events.ProgressEvent Progress = new ProgressEvent(EventCodes.PROGRESS_UPDATE);
                    Progress.Done = 1;
                    Progress.Total = 1;

                    //Lord have mercy on the soul who figures out why commenting out the below line
                    //causes the city to show...
                    //OnTransitionProgress(Progress);
                    GameFacade.Controller.ShowCity();
                    m_Dead = true;
                    break;
                case CharacterCreationStatus.GeneralError:
                    Controller_OnNetworkError(new SocketException());
                    break;
            }
        }
        private void Client_OnConnected(LoginArgsContainer LoginArgs)
        {
            TSOClient.Network.Events.ProgressEvent Progress =
                new TSOClient.Network.Events.ProgressEvent(TSOClient.Events.EventCodes.PROGRESS_UPDATE);
            Progress.Done = 1;
            Progress.Total = 2;

            if (m_CharacterCreated)
            {
                UIPacketSenders.SendCharacterCreateCity(LoginArgs, PlayerAccount.CurrentlyActiveSim);
                OnTransitionProgress(Progress);
            }
            else
            {
                UIPacketSenders.SendCityToken(NetworkFacade.Client);
                OnTransitionProgress(Progress);
            }
        }
        private void Controller_OnLoginSuccessCity()
        {
            TSOClient.Network.Events.ProgressEvent Progress =
                new TSOClient.Network.Events.ProgressEvent(TSOClient.Events.EventCodes.PROGRESS_UPDATE);
            Progress.Done = 2;
            Progress.Total = 3;

            if (m_CharacterCreated)
            {
                UIPacketSenders.SendCharacterCreateCity(NetworkFacade.Client, PlayerAccount.CurrentlyActiveSim);
                OnTransitionProgress(Progress);
            }
            else
            {
                UIPacketSenders.SendCityToken(NetworkFacade.Client);
                OnTransitionProgress(Progress);
            }
        }
 private void Controller_OnLoginNotifyCity()
 {
     TSOClient.Network.Events.ProgressEvent Progress =
         new TSOClient.Network.Events.ProgressEvent(TSOClient.Events.EventCodes.PROGRESS_UPDATE);
     Progress.Done = 2;
     Progress.Total = 3;
     OnTransitionProgress(Progress);
 }
        /// <summary>
        /// Authentication failed, so retry.
        /// </summary>
        private void Controller_OnLoginFailureCity()
        {
            if (EventSink.EventQueue[0].ECode == EventCodes.AUTHENTICATION_FAILURE)
            {
                TSOClient.Network.Events.ProgressEvent Progress =
                    new TSOClient.Network.Events.ProgressEvent(TSOClient.Events.EventCodes.PROGRESS_UPDATE);
                Progress.Done = 1;
                Progress.Total = 3;

                LoginArgsContainer LoginArgs = new LoginArgsContainer();
                LoginArgs.Username = NetworkFacade.Client.ClientEncryptor.Username;
                LoginArgs.Password = Convert.ToBase64String(PlayerAccount.Hash);
                LoginArgs.Enc = NetworkFacade.Client.ClientEncryptor;

                NetworkFacade.Controller.Reconnect(ref NetworkFacade.Client, m_SelectedCity, LoginArgs);
                OnTransitionProgress(Progress);

                //Doing this instead of EventQueue.Clear() ensures we won't accidentally remove any
                //events that may have been added to the end.
                EventSink.EventQueue.Remove(EventSink.EventQueue[0]);
            }
        }
        private void Client_OnConnected(LoginArgsContainer LoginArgs)
        {
            TSOClient.Network.Events.ProgressEvent Progress =
                new TSOClient.Network.Events.ProgressEvent(TSOClient.Events.EventCodes.PROGRESS_UPDATE);
            Progress.Done = 1;
            Progress.Total = 3;

            UIPacketSenders.SendLoginRequestCity(LoginArgs);
            OnTransitionProgress(Progress);
        }