CityInfo holds information about, and can be used to represent a city server.
Exemplo n.º 1
0
 public void ShowPersonCreation(CityInfo selectedCity)
 {
     var screen = new PersonSelectionEdit();
     screen.SelectedCity = selectedCity;
     GameFacade.Screens.RemoveCurrent();
     GameFacade.Screens.AddScreen(screen);
 }
Exemplo n.º 2
0
 /// <summary>
 /// New city server came online!
 /// </summary>
 public static void OnNewCityServer(NetworkClient Client, ProcessedPacket Packet)
 {
     lock (NetworkFacade.Cities)
     {
         CityInfo Info = new CityInfo(false);
         Info.Name = Packet.ReadString();
         Info.Description = Packet.ReadString();
         Info.IP = Packet.ReadString();
         Info.Port = Packet.ReadInt32();
         Info.Status = (CityInfoStatus)Packet.ReadByte();
         Info.Thumbnail = Packet.ReadUInt64();
         Info.UUID = Packet.ReadString();
         Info.Map = Packet.ReadUInt64();
         NetworkFacade.Cities.Add(Info);
     }
 }
Exemplo n.º 3
0
        public static void OnCityInfoResponse(ProcessedPacket Packet)
        {
            byte NumCities = (byte)Packet.ReadByte();

            if (Packet.DecryptedLength > 1)
            {
                lock (NetworkFacade.Cities)
                {
                    for (int i = 0; i < NumCities; i++)
                    {
                        string Name = Packet.ReadString();
                        string Description = Packet.ReadString();
                        string IP = Packet.ReadString();
                        int Port = Packet.ReadInt32();
                        byte StatusByte = (byte)Packet.ReadByte();
                        CityInfoStatus Status = (CityInfoStatus)StatusByte;
                        ulong Thumbnail = Packet.ReadUInt64();
                        string UUID = Packet.ReadString();
                        ulong Map = Packet.ReadUInt64();

                        CityInfo Info = new CityInfo(false);
                        Info.Name = Name;
                        Info.Description = Description;
                        Info.Thumbnail = Thumbnail;
                        Info.UUID = UUID;
                        Info.Map = Map;
                        Info.IP = IP;
                        Info.Port = Port;
                        Info.Online = true;
                        Info.Status = Status;
                        NetworkFacade.Cities.Add(Info);
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a new CityTransitionScreen.
        /// </summary>
        /// <param name="SelectedCity">The city being transitioned to.</param>
        /// <param name="CharacterCreated">If transitioning from CreateASim, this should be true.
        /// A CharacterCreateCity packet will be sent to the CityServer. Otherwise, this should be false.
        /// A CityToken packet will be sent to the CityServer.</param>
        public CityTransitionScreen(CityInfo SelectedCity, bool CharacterCreated)
        {
            m_SelectedCity = SelectedCity;
            m_CharacterCreated = CharacterCreated;

            /**
             * Scale the whole screen to 1024
             */
            m_BackgroundCtnr = new UIContainer();
            m_BackgroundCtnr.ScaleX = m_BackgroundCtnr.ScaleY = ScreenWidth / 800.0f;

            /** Background image **/
            m_Background = new UIImage(GetTexture((ulong)FileIDs.UIFileIDs.setup));
            m_Background.ID = "Background";
            m_BackgroundCtnr.Add(m_Background);

            var lbl = new UILabel();
            lbl.Caption = "Version " + GlobalSettings.Default.ClientVersion;
            lbl.X = 20;
            lbl.Y = 558;
            m_BackgroundCtnr.Add(lbl);
            this.Add(m_BackgroundCtnr);

            m_LoginProgress = new UILoginProgress();
            m_LoginProgress.X = (ScreenWidth - (m_LoginProgress.Width + 20));
            m_LoginProgress.Y = (ScreenHeight - (m_LoginProgress.Height + 20));
            m_LoginProgress.Opacity = 0.9f;
            this.Add(m_LoginProgress);

            /*lock(NetworkFacade.Controller)
                NetworkFacade.Controller.OnNetworkError += new NetworkErrorDelegate(Controller_OnNetworkError);*/

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

                    NetworkFacade.Client = new NetworkClient(SelectedCity.IP, SelectedCity.Port,
                        GonzoNet.Encryption.EncryptionMode.AESCrypto, true);
                    //This might not fix decryption of cityserver's packets, but it shouldn't make things worse...
                    NetworkFacade.Client.ClientEncryptor = LoginArgs.Enc;
                    //THIS IS IMPORTANT - THIS NEEDS TO BE COPIED AFTER IT HAS BEEN RECREATED FOR
                    //THE RECONNECTION TO WORK!
                    LoginArgs.Client = NetworkFacade.Client;
                    NetworkFacade.Client.OnConnected += new OnConnectedDelegate(Client_OnConnected);
                    NetworkFacade.Controller.Reconnect(ref NetworkFacade.Client, SelectedCity, LoginArgs);
                }
            }

            lock (NetworkFacade.Controller)
            {
                NetworkFacade.Controller.OnCharacterCreationStatus += new OnCharacterCreationStatusDelegate(Controller_OnCharacterCreationStatus);
                NetworkFacade.Controller.OnCityTransferProgress += new OnCityTransferProgressDelegate(Controller_OnCityTransfer);
                NetworkFacade.Controller.OnLoginNotifyCity += new OnLoginNotifyCityDelegate(Controller_OnLoginNotifyCity);
                NetworkFacade.Controller.OnLoginSuccessCity += new OnLoginSuccessCityDelegate(Controller_OnLoginSuccessCity);
                NetworkFacade.Controller.OnLoginFailureCity += new OnLoginFailureCityDelegate(Controller_OnLoginFailureCity);
                NetworkFacade.Controller.OnNetworkError += new NetworkErrorDelegate(Controller_OnNetworkError);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Received token from LoginServer - proceed to CityServer!
 /// </summary>
 private void Controller_OnCityToken(CityInfo SelectedCity)
 {
     GameFacade.Controller.ShowCityTransition(SelectedCity, false);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Reconnects to a CityServer.
        /// </summary>
        public void Reconnect(ref NetworkClient Client, CityInfo SelectedCity, LoginArgsContainer LoginArgs)
        {
            Client.Disconnect();

            if (LoginArgs.Enc == null)
            {
                System.Diagnostics.Debug.WriteLine("LoginArgs.Enc was null!");
                LoginArgs.Enc = new GonzoNet.Encryption.AESEncryptor(Convert.ToBase64String(PlayerAccount.Hash));
            }
            else if (LoginArgs.Username == null || LoginArgs.Password == null)
            {
                System.Diagnostics.Debug.WriteLine("LoginArgs.Username or LoginArgs.Password was null!");
                LoginArgs.Username = PlayerAccount.Username;
                LoginArgs.Password = Convert.ToBase64String(PlayerAccount.Hash);
            }

            Client.Connect(LoginArgs);
        }
Exemplo n.º 7
0
 public void ShowCityTransition(CityInfo selectedCity, bool CharacterCreated)
 {
     GameFacade.Screens.RemoveCurrent();
     GameFacade.Screens.AddScreen(new CityTransitionScreen(selectedCity, CharacterCreated));
 }