/// <summary> /// Requests a token from the LoginServer, that can be used to log into a CityServer. /// </summary> /// <param name="Client">A NetworkClient instance.</param> public static void RequestCityToken(NetworkClient Client, Sim SelectedCharacter) { PacketStream Packet = new PacketStream((byte)PacketType.REQUEST_CITY_TOKEN, 0); Packet.WritePascalString(Client.ClientEncryptor.Username); Packet.WritePascalString(SelectedCharacter.ResidingCity.UUID); Packet.WritePascalString(SelectedCharacter.GUID.ToString()); Client.SendEncrypted((byte)PacketType.REQUEST_CITY_TOKEN, Packet.ToArray()); }
/// <summary> /// Sends a CharacterCreate packet to the LoginServer. /// </summary> /// <param name="Character">The character to create.</param> /// <param name="TimeStamp">The timestamp of when this character was created.</param> public static void SendCharacterCreate(TSOClient.VM.Sim Character, string TimeStamp) { PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_CREATE, 0); Packet.WritePascalString(PlayerAccount.Client.ClientEncryptor.Username); Packet.WritePascalString(TimeStamp); Packet.WritePascalString(Character.Name); Packet.WritePascalString(Character.Sex); Packet.WritePascalString(Character.Description); Packet.WriteUInt64(Character.HeadOutfitID); Packet.WriteUInt64(Character.BodyOutfitID); Packet.WriteByte((byte)Character.AppearanceType); Packet.WritePascalString(Character.ResidingCity.Name); Packet.WriteUInt64(Character.ResidingCity.Thumbnail); Packet.WritePascalString(Character.ResidingCity.UUID); Packet.WriteUInt64(Character.ResidingCity.Map); Packet.WritePascalString(Character.ResidingCity.IP); Packet.WriteInt32(Character.ResidingCity.Port); byte[] PacketData = Packet.ToArray(); PlayerAccount.Client.SendEncrypted((byte)PacketType.CHARACTER_CREATE, PacketData); }
public static void HandleCharacterCreate(NetworkClient Client, ProcessedPacket P) { Logger.LogInfo("Received CharacterCreate!"); string AccountName = SanitizeAccount(P.ReadPascalString()); using (var db = DataAccess.Get()) { Account Acc = db.Accounts.GetByUsername(AccountName); //TODO: Send GUID to client... SimBase Char = new SimBase(Guid.NewGuid()); Char.Timestamp = P.ReadPascalString(); Char.Name = P.ReadPascalString(); Char.Sex = P.ReadPascalString(); Char.Description = P.ReadPascalString(); Char.HeadOutfitID = P.ReadUInt64(); Char.BodyOutfitID = P.ReadUInt64(); Char.Appearance = (AppearanceType)P.ReadByte(); Char.ResidingCity = new CityInfo(P.ReadPascalString(), "", P.ReadUInt64(), P.ReadPascalString(), P.ReadUInt64(), P.ReadPascalString(), P.ReadInt32()); Char.CreatedThisSession = true; var characterModel = new Character(); characterModel.Name = Char.Name; characterModel.Sex = Char.Sex; characterModel.Description = Char.Description; characterModel.LastCached = Char.Timestamp; characterModel.GUID = Char.GUID; characterModel.HeadOutfitID = (long)Char.HeadOutfitID; characterModel.BodyOutfitID = (long)Char.BodyOutfitID; characterModel.AccountID = Acc.AccountID; characterModel.AppearanceType = (int)Char.Appearance; characterModel.City = Char.ResidingCity.UUID; characterModel.CityName = Char.ResidingCity.Name; characterModel.CityThumb = (long)Char.ResidingCity.Thumbnail; characterModel.CityMap = (long)Char.ResidingCity.Map; characterModel.CityIp = Char.ResidingCity.IP; characterModel.CityPort = Char.ResidingCity.Port; var status = db.Characters.CreateCharacter(characterModel); //Need to be variable length, because the success packet contains a token. PacketStream CCStatusPacket = new PacketStream((byte)PacketType.CHARACTER_CREATION_STATUS, 0); switch (status) { case LoginDataModel.Entities.CharacterCreationStatus.NameAlreadyExisted: CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.NameAlreadyExisted); Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray()); break; case LoginDataModel.Entities.CharacterCreationStatus.ExceededCharacterLimit: CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.ExceededCharacterLimit); Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray()); break; case LoginDataModel.Entities.CharacterCreationStatus.Success: CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.Success); CCStatusPacket.WritePascalString(Char.GUID.ToString()); Guid Token = Guid.NewGuid(); CCStatusPacket.WritePascalString(Token.ToString()); Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray()); foreach (CityServerClient CServer in NetworkFacade.CServerListener.CityServers) { if (CServer.ServerInfo.UUID == Char.ResidingCity.UUID) { PacketStream CServerPacket = new PacketStream(0x01, 0); CServerPacket.WriteHeader(); ushort PacketLength = (ushort)(PacketHeaders.UNENCRYPTED + 4 + (Client.RemoteIP.Length + 1) + (Char.GUID.ToString().Length + 1) + (Token.ToString().Length + 1)); CServerPacket.WriteUInt16(PacketLength); CServerPacket.WriteInt32(Acc.AccountID); CServerPacket.WritePascalString(Client.RemoteIP); CServerPacket.WritePascalString(Char.GUID.ToString()); CServerPacket.WritePascalString(Token.ToString()); CServer.Send(CServerPacket.ToArray()); break; } } break; } } //Client was modified, so update it. NetworkFacade.ClientListener.UpdateClient(Client); }
public static void SendCharacterInfoRequest(string TimeStamp) { PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_LIST, 0); //If this timestamp is newer than the server's timestamp, it means //the client doesn't have a charactercache. If it's older, it means //the cache needs to be updated. If it matches, the server sends an //empty responsepacket. //Packet.WriteString(TimeStamp); Packet.WritePascalString(TimeStamp); byte[] PacketData = Packet.ToArray(); //PlayerAccount.Client.Send(FinalizePacket(0x05, new DESCryptoServiceProvider(), PacketData)); PlayerAccount.Client.SendEncrypted((byte)PacketType.CHARACTER_LIST, PacketData); }
public static void HandleCityTokenRequest(NetworkClient Client, ProcessedPacket P) { string AccountName = P.ReadPascalString(); string CityGUID = P.ReadPascalString(); string CharGUID = P.ReadPascalString(); string Token = new Guid().ToString(); foreach (CityServerClient CServer in NetworkFacade.CServerListener.CityServers) { if (CityGUID == CServer.ServerInfo.UUID) { using (var db = DataAccess.Get()) { Account Acc = db.Accounts.GetByUsername(AccountName); PacketStream CServerPacket = new PacketStream(0x01, 0); CServerPacket.WriteHeader(); ushort PacketLength = (ushort)(PacketHeaders.UNENCRYPTED + 4 + (Client.RemoteIP.Length + 1) + (CharGUID.ToString().Length + 1) + (Token.ToString().Length + 1)); CServerPacket.WriteUInt16(PacketLength); CServerPacket.WriteInt32(Acc.AccountID); CServerPacket.WritePascalString(Client.RemoteIP); CServerPacket.WritePascalString(CharGUID.ToString()); CServerPacket.WritePascalString(Token.ToString()); CServer.Send(CServerPacket.ToArray()); break; } } } PacketStream Packet = new PacketStream((byte)PacketType.REQUEST_CITY_TOKEN, 0); Packet.WritePascalString(Token); Client.SendEncrypted((byte)PacketType.REQUEST_CITY_TOKEN, Packet.ToArray()); }