/// <summary> /// Creates a new instance of CitySelectionDialog. Only used once in the game, when creating a new sim. /// </summary> /// <param name="Client">A NetworkClient instance, used to communicate with the loginserver.</param> /// <param name="X">The x-coordinate of this dialog on the screen.</param> /// <param name="Y">The y-coordinate of this dialog on the screen.</param> /// <param name="DiagBackgrnd">The background-texture for the dialog. Loaded from dialogs.dat.</param> /// <param name="Screen">A UIScreen instance, which is the screen that this dialog will be displayed on.</param> /// <param name="StrID">The string ID of this UICitySelectionDialog instance.</param> public UICitySelectionDialog(NetworkClient Client, int X, int Y, Texture2D DiagBackgrnd, List<CityServerInformation> CityServerInfo, UIScreen Screen, string StrID) : base(Client, Screen, StrID, DrawLevel.DontGiveAFuck) { m_DiagImg = DiagBackgrnd; m_X = X; m_Y = Y; m_Caption = "What City Do You Want to Live In?"; //TODO: Should probably finetune all coordinates to work based on the dialog's coordinates... m_OnlineCities = new UIListBox(40, 78, 40, 3, Screen, "LstOnlineCities", DrawLevel.DontGiveAFuck); MemoryStream TexStream = new MemoryStream(ContentManager.GetResourceFromLongID(0x8a900000001)); Texture2D CityDescBackroundTex = Texture2D.FromFile(Screen.ScreenMgr.GraphicsDevice, TexStream); m_CityDescBackground = new UIImage(221, 280, "CityDescBackgroundImg", CityDescBackroundTex, Screen); m_CityDescription = new UITextEdit(231, 292, 265, 141, true, 1000, "TxtCityDescription", Screen); TexStream = new MemoryStream(ContentManager.GetResourceFromLongID(CityServerInfo[0].ImageID)); Texture2D CityImgTex = Texture2D.FromFile(Screen.ScreenMgr.GraphicsDevice, TexStream); m_CityImg = new UIImage(28, 283, "CityThumbnailImg", CityImgTex, Screen); TexStream = new MemoryStream(ContentManager.GetResourceFromLongID(0x1e700000001)); Texture2D BtnTex = Texture2D.FromFile(Screen.ScreenMgr.GraphicsDevice, TexStream); m_OKBtn = new UIButton(278, 230, BtnTex, false, "BtnOK", Screen); m_CancelBtn = new UIButton(388, 430, BtnTex, false, "BtnCancel", Screen); m_Client.OnNetworkError += new NetworkErrorDelegate(m_Client_OnNetworkError); m_Client.OnReceivedData += new ReceivedPacketDelegate(m_Client_OnReceivedData); }
public NetworkedUIElement(string IP, int Port, UIScreen Screen, string StrID, DrawLevel DLevel) { m_Screen = Screen; m_StringID = StrID; m_Client = new NetworkClient(IP, Port); }
/// <summary> /// Occurs when the client has been sucessfully authenticated by the loginserver. /// Called by UILoginDialog.cs. /// </summary> /// <param name="Client">The client that received the packet.</param> /// <param name="Packet">The packet that was received.</param> public static void OnInitLoginNotify(NetworkClient Client, PacketStream Packet) { byte Opcode = (byte)Packet.ReadByte(); //Account was authenticated, so add the client to the player's account. PlayerAccount.Client = Client; if (!Directory.Exists("CharacterCache")) { Directory.CreateDirectory("CharacterCache"); //The charactercache didn't exist, so send the current time, which is //newer than the server's stamp. This will cause the server to send the entire cache. UIPacketSenders.SendCharacterInfoRequest(DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss")); } else { if (!File.Exists("CharacterCache\\Sims.tempcache")) { //The charactercache didn't exist, so send the current time, which is //newer than the server's stamp. This will cause the server to send the entire cache. UIPacketSenders.SendCharacterInfoRequest(DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss")); } } }
public NetworkedUIElement(NetworkClient Client, UIScreen Screen, string StrID, DrawLevel DLevel) { m_Screen = Screen; m_StringID = StrID; m_Client = Client; }
public LotScreen(ScreenManager ScreenMgr, NetworkClient Client) : base(ScreenMgr) { m_VM = new VirtualMachine(); m_Client = Client; m_Client.OnReceivedData += new ReceivedPacketDelegate(m_Client_OnReceivedData); }
public UINetworkButton(float X, float Y, Texture2D Texture, NetworkClient Client, UIScreen Screen, string StrID) : base(Client, Screen, StrID, DrawLevel.AlwaysOnTop) { m_X = X; m_Y = Y; m_Texture = Texture; m_Width = Texture.Width / 4; m_Caption = ""; m_CurrentFrame = 0; OnButtonClick += new NetworkButtonClickDelegate(delegate(UINetworkButton btn) { Screen.RegisterClick(this); }); //All classes inheriting from NetworkedUIElement MUST subscribe to these events! m_Client.OnReceivedData += new ReceivedPacketDelegate(m_Client_OnReceivedData); m_Client.OnNetworkError += new NetworkErrorDelegate(m_Client_OnNetworkError); }
public static void OnSimulationState(NetworkClient Client, PacketStream Packet, LotScreen Lot) { List<SimulationObject> SimObjects = new List<SimulationObject>(); byte Opcode = (byte)Packet.ReadByte(); byte NumTicks = (byte)Packet.ReadByte(); int NumObjects = Packet.ReadInt32(); BinaryFormatter BinFormatter = new BinaryFormatter(); for (int i = 0; i < NumObjects; i++) { SimulationObject SimObject = (SimulationObject)BinFormatter.Deserialize(Packet); SimObjects.Add(SimObject); } Lot.UpdateSimulationState(NumTicks, SimObjects); }
/// <summary> /// LoginServer sent information about the player's characters. /// </summary> /// <param name="Packet">The packet that was received.</param> public static void OnCharacterInfoResponse(PacketStream Packet, NetworkClient Client) { byte Opcode = (byte)Packet.ReadByte(); byte Length = (byte)Packet.ReadByte(); byte DecryptedLength = (byte)Packet.ReadByte(); Packet.DecryptPacket(PlayerAccount.EncKey, new DESCryptoServiceProvider(), DecryptedLength); //If the decrypted length == 1, it means that there were 0 //characters that needed to be updated, or that the user //hasn't created any characters on his/her account yet. //Since the Packet.Length property is equal to the length //of the encrypted data, it cannot be used to get the length //of the decrypted data. if (DecryptedLength > 1) { byte NumCharacters = (byte)Packet.ReadByte(); List<Sim> FreshSims = new List<Sim>(); for (int i = 0; i < NumCharacters; i++) { int CharacterID = Packet.ReadInt32(); Sim FreshSim = new Sim(Packet.ReadString()); FreshSim.CharacterID = CharacterID; FreshSim.Timestamp = Packet.ReadString(); FreshSim.Name = Packet.ReadString(); FreshSim.Sex = Packet.ReadString(); FreshSims.Add(FreshSim); } NetworkFacade.Avatars = FreshSims; CacheSims(FreshSims); } PacketStream CityInfoRequest = new PacketStream(0x06, 0); CityInfoRequest.WriteByte(0x00); //Dummy Client.SendEncrypted(0x06, CityInfoRequest.ToArray()); }
public static void SendLoginRequest(NetworkClient Client, string Username, string Password) { //Variable length... PacketStream Packet = new PacketStream(0x00, 0); Packet.WriteByte(0x00); SaltedHash Hash = new SaltedHash(new SHA512Managed(), Username.Length); byte[] HashBuf = new byte[Encoding.ASCII.GetBytes(Password).Length + Encoding.ASCII.GetBytes(Username).Length]; MemoryStream MemStream = new MemoryStream(); PasswordDeriveBytes Pwd = new PasswordDeriveBytes(Encoding.ASCII.GetBytes(Password), Encoding.ASCII.GetBytes("SALT"), "SHA1", 10); byte[] EncKey = Pwd.GetBytes(8); PlayerAccount.EncKey = EncKey; MemStream.WriteByte((byte)Username.Length); MemStream.Write(Encoding.ASCII.GetBytes(Username), 0, Encoding.ASCII.GetBytes(Username).Length); HashBuf = Hash.ComputePasswordHash(Username, Password); PlayerAccount.Hash = HashBuf; MemStream.WriteByte((byte)HashBuf.Length); MemStream.Write(HashBuf, 0, HashBuf.Length); MemStream.WriteByte((byte)EncKey.Length); MemStream.Write(EncKey, 0, EncKey.Length); Packet.WriteByte((byte)(2 + MemStream.ToArray().Length + 4)); Packet.WriteBytes(MemStream.ToArray()); //TODO: Change this to write a global client version. Packet.WriteByte(0x00); //Version 1 Packet.WriteByte(0x00); //Version 2 Packet.WriteByte(0x00); //Version 3 Packet.WriteByte(0x01); //Version 4 Client.Send(Packet.ToArray()); }
/// <summary> /// Occurs when the client was not authenticated by the loginserver. /// Called by UILoginDialog.cs. /// </summary> /// <param name="Client">The client that received the packet.</param> /// <param name="Packet">The packet that was received.</param> /// <param name="Screen">A UIScreen instance on which to display a messagebox to inform the player of the /// failure state.</param> public static void OnLoginFailResponse(ref NetworkClient Client, PacketStream Packet, UIScreen Screen) { byte Opcode = (byte)Packet.ReadByte(); switch (Packet.ReadByte()) { case 0x01: Screen.CreateMsgBox(250, 200, "Invalid accountname!"); break; case 0x02: Screen.CreateMsgBox(250, 200, "Invalid password!"); break; } Client.Disconnect(); }
/// <summary> /// Occurs when the client was not authenticated by the loginserver. /// Called by UILoginDialog.cs. /// </summary> /// <param name="Client">The client that received the packet.</param> /// <param name="Packet">The packet that was received.</param> /// <param name="Screen">A UIScreen instance on which to display a messagebox to inform the player of the /// failure state.</param> public static void OnLoginFailResponse(ref NetworkClient Client, PacketStream Packet) { byte Opcode = (byte)Packet.ReadByte(); switch (Packet.ReadByte()) { case 0x01: UIAlertOptions Options = new UIAlertOptions(); Options.Title = "Network error"; Options.Message = "Invalid username!"; Options.Buttons = UIAlertButtons.OK; UIScreen.ShowAlert(Options, true); break; case 0x02: Options = new UIAlertOptions(); Options.Title = "Network error"; Options.Message = "Invalid password!"; Options.Buttons = UIAlertButtons.OK; UIScreen.ShowAlert(Options, true); break; } Client.Disconnect(); }
/// <summary> /// Reconnects to a CityServer. /// </summary> public void Reconnect(ref NetworkClient Client, CityInfo SelectedCity, LoginArgsContainer LoginArgs) { Client.Disconnect(); Client.Connect(LoginArgs); }
public void _OnCityTokenResponse(NetworkClient Client, ProcessedPacket packet) { CityTransferStatus Status = UIPacketHandlers.OnCityTokenResponse(Client, packet); OnCityTransferProgress(Status); }
public void _OnCityToken(NetworkClient Client, ProcessedPacket packet) { UIPacketHandlers.OnCityToken(Client, packet); OnCityToken(PlayerAccount.CurrentlyActiveSim.ResidingCity); }
public void _OnCharacterCreationStatus(NetworkClient Client, ProcessedPacket packet) { CharacterCreationStatus CCStatus = UIPacketHandlers.OnCharacterCreationStatus(Client, packet); OnCharacterCreationStatus(CCStatus); }