/// <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, ProcessedPacket Packet)
        {
            //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.cache"))
                {
                    //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
                {
                    string LastDateCached = Cache.GetDateCached();
                    if (LastDateCached == "")
                    {
                        UIPacketSenders.SendCharacterInfoRequest(DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss"));
                    }
                    else
                    {
                        UIPacketSenders.SendCharacterInfoRequest(LastDateCached);
                    }
                }
            }
        }
        public static void OnCityInfoResponse(ProcessedPacket Packet)
        {
            byte NumCities = (byte)Packet.ReadByte();

            if (Packet.DecryptedLength > 1)
            {
                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(Name, Description, Thumbnail, UUID, Map, IP, Port);
                    Info.Online = true;
                    Info.Status = Status;
                    NetworkFacade.Cities.Add(Info);
                }
            }
        }
 public void _OnLoginNotify(NetworkClient Client, ProcessedPacket packet)
 {
     UIPacketHandlers.OnInitLoginNotify(NetworkFacade.Client, packet);
     OnLoginProgress(new ProgressEvent(EventCodes.PROGRESS_UPDATE)
     {
         Done = 2, Total = 4
     });
 }
 public void _OnInvalidVersion(NetworkClient Client, ProcessedPacket packet)
 {
     UIPacketHandlers.OnInvalidVersionResponse(ref NetworkFacade.Client, packet);
     OnLoginStatus(new LoginEvent(EventCodes.LOGIN_RESULT)
     {
         Success = false, VersionOK = false
     });
 }
 /// <summary>
 /// Received list of characters for account from login server.
 /// </summary>
 public void _OnCharacterList(NetworkClient Client, ProcessedPacket packet)
 {
     OnLoginProgress(new ProgressEvent(EventCodes.PROGRESS_UPDATE)
     {
         Done = 3, Total = 4
     });
     UIPacketHandlers.OnCharacterInfoResponse(packet, NetworkFacade.Client);
 }
 /// <summary>
 /// Received a list of available cities from the login server.
 /// </summary>
 public void _OnCityList(NetworkClient Client, ProcessedPacket packet)
 {
     UIPacketHandlers.OnCityInfoResponse(packet);
     OnLoginProgress(new ProgressEvent(EventCodes.PROGRESS_UPDATE)
     {
         Done = 4, Total = 4
     });
     OnLoginStatus(new LoginEvent(EventCodes.LOGIN_RESULT)
     {
         Success = true
     });
 }
        /// <summary>
        /// LoginServer sent information about the player's characters.
        /// </summary>
        /// <param name="Packet">The packet that was received.</param>
        public static void OnCharacterInfoResponse(ProcessedPacket Packet, NetworkClient Client)
        {
            //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 (Packet.DecryptedLength > 1)
            {
                byte         NumCharacters = (byte)Packet.ReadByte();
                List <UISim> FreshSims     = new List <UISim>();

                for (int i = 0; i < NumCharacters; i++)
                {
                    int CharacterID = Packet.ReadInt32();

                    UISim FreshSim = new UISim(Packet.ReadString(), false);
                    FreshSim.CharacterID       = CharacterID;
                    FreshSim.Timestamp         = Packet.ReadString();
                    FreshSim.Name              = Packet.ReadString();
                    FreshSim.Sex               = Packet.ReadString();
                    FreshSim.Description       = Packet.ReadString();
                    FreshSim.HeadOutfitID      = Packet.ReadUInt64();
                    FreshSim.BodyOutfitID      = Packet.ReadUInt64();
                    FreshSim.Avatar.Appearance = (AppearanceType)Packet.ReadByte();
                    FreshSim.ResidingCity      = new CityInfo(Packet.ReadString(), "", Packet.ReadUInt64(), Packet.ReadString(),
                                                              Packet.ReadUInt64(), Packet.ReadString(), Packet.ReadInt32());

                    FreshSims.Add(FreshSim);
                }

                if (NumCharacters < 3)
                {
                    FreshSims = Cache.LoadCachedSims(FreshSims);
                }
                NetworkFacade.Avatars = FreshSims;
                Cache.CacheSims(FreshSims);
            }
            else
            {
                NetworkFacade.Avatars = Cache.LoadAllSims();
            }

            PacketStream CityInfoRequest = new PacketStream(0x06, 0);

            CityInfoRequest.WriteByte(0x00); //Dummy

            Client.SendEncrypted((byte)PacketType.CITY_LIST, CityInfoRequest.ToArray());
        }
Пример #8
0
        /// <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>
        public static void OnLoginFailResponse(ref NetworkClient Client, ProcessedPacket Packet)
        {
            EventObject Event;

            switch (Packet.ReadByte())
            {
            case 0x01:
                Event = new EventObject(EventCodes.BAD_USERNAME);
                EventSink.RegisterEvent(Event);
                break;

            case 0x02:
                Event = new EventObject(EventCodes.BAD_PASSWORD);
                EventSink.RegisterEvent(Event);
                break;
            }

            Client.Disconnect();
        }
        public void _OnRetireCharacterStatus(NetworkClient Client, ProcessedPacket Packet)
        {
            string GUID = UIPacketHandlers.OnCharacterRetirement(Client, Packet);

            OnCharacterRetirement(GUID);
        }
 public void _OnCityToken(NetworkClient Client, ProcessedPacket packet)
 {
     UIPacketHandlers.OnCityToken(Client, packet);
     OnCityToken(PlayerAccount.CurrentlyActiveSim.ResidingCity);
 }
        public void _OnCityTokenResponse(NetworkClient Client, ProcessedPacket packet)
        {
            CityTransferStatus Status = UIPacketHandlers.OnCityTokenResponse(Client, packet);

            OnCityTransferProgress(Status);
        }
        /// <summary>
        /// Received from the LoginServer in response to a RETIRE_CHARACTER packet.
        /// </summary>
        /// <returns>Name of character that was retired.</returns>
        public static string OnCharacterRetirement(NetworkClient Client, ProcessedPacket Packet)
        {
            string GUID = Packet.ReadPascalString();

            return(GUID);
        }
        public void _OnCharacterCreationStatus(NetworkClient Client, ProcessedPacket packet)
        {
            CharacterCreationStatus CCStatus = UIPacketHandlers.OnCharacterCreationStatus(Client, packet);

            OnCharacterCreationStatus(CCStatus);
        }
Пример #14
0
 public static void OnInvalidVersionResponse(ref NetworkClient Client, ProcessedPacket Packet)
 {
     Client.Disconnect();
 }
Пример #15
0
        /// <summary>
        /// Received CharacterCreation packet from LoginServer.
        /// </summary>
        /// <returns>The result of the character creation.</returns>
        public static CharacterCreationStatus OnCharacterCreationProgress(NetworkClient Client, ProcessedPacket Packet)
        {
            CharacterCreationStatus CCStatus = (CharacterCreationStatus)Packet.ReadByte();

            if (CCStatus == CharacterCreationStatus.Success)
            {
                Guid CharacterGUID = new Guid();

                CharacterGUID           = new Guid(Packet.ReadPascalString());
                PlayerAccount.CityToken = Packet.ReadPascalString();
                PlayerAccount.CurrentlyActiveSim.AssignGUID(CharacterGUID.ToString());
            }

            return(CCStatus);
        }
Пример #16
0
        /// <summary>
        /// Received CharacterCreation packet from CityServer.
        /// </summary>
        /// <returns>The result of the character creation.</returns>
        public static CharacterCreationStatus OnCharacterCreationStatus(NetworkClient Client, ProcessedPacket Packet)
        {
            CharacterCreationStatus CCStatus = (CharacterCreationStatus)Packet.ReadByte();

            return(CCStatus);
        }
Пример #17
0
 /// <summary>
 /// Received from the LoginServer in response to a CITY_TOKEN_REQUEST packet.
 /// </summary>
 public static void OnCityToken(NetworkClient Client, ProcessedPacket Packet)
 {
     PlayerAccount.CityToken = Packet.ReadPascalString();
 }
Пример #18
0
        /// <summary>
        /// Received from the CityServer in response to a CITY_TOKEN packet.
        /// </summary>
        public static CityTransferStatus OnCityTokenResponse(NetworkClient Client, ProcessedPacket Packet)
        {
            CityTransferStatus Status = (CityTransferStatus)Packet.ReadByte();

            return(Status);
        }