CacheSims() public static method

Caches sims received from the LoginServer to the disk.
public static CacheSims ( List FreshSims ) : void
FreshSims List A list of the sims received by the LoginServer.
return void
示例#1
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 = Guid.NewGuid();

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

                //This previously happened when clicking the accept button in CAS, causing
                //all chars to be cached even if the new char wasn't successfully created.
                lock (NetworkFacade.Avatars)
                    Cache.CacheSims(NetworkFacade.Avatars);
            }

            return(CCStatus);
        }
示例#2
0
        /// <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)
        {
            byte NumCharacters = (byte)Packet.ReadByte();
            byte NewCharacters = (byte)Packet.ReadByte();

            List <UISim> FreshSims = new List <UISim>();

            for (int i = 0; i < NewCharacters; 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(false);
                FreshSim.ResidingCity.Name      = Packet.ReadString();
                FreshSim.ResidingCity.Thumbnail = Packet.ReadUInt64();
                FreshSim.ResidingCity.UUID      = Packet.ReadString();
                FreshSim.ResidingCity.Map       = Packet.ReadUInt64();
                FreshSim.ResidingCity.IP        = Packet.ReadString();
                FreshSim.ResidingCity.Port      = Packet.ReadInt32();

                FreshSims.Add(FreshSim);
            }

            lock (NetworkFacade.Avatars)
            {
                if ((NumCharacters < 3) && (NewCharacters > 0))
                {
                    FreshSims             = Cache.LoadCachedSims(FreshSims);
                    NetworkFacade.Avatars = FreshSims;
                    Cache.CacheSims(FreshSims);
                }

                if (NewCharacters == 0 && NumCharacters > 0)
                {
                    NetworkFacade.Avatars = Cache.LoadAllSims();
                }
                else if (NewCharacters == 3 && NumCharacters == 3)
                {
                    NetworkFacade.Avatars = FreshSims;
                    Cache.CacheSims(FreshSims);
                }
                else if (NewCharacters == 0 && NumCharacters == 0)
                {
                    //Make sure if sims existed in the cache, they are deleted (because they didn't exist in DB).
                    Cache.DeleteCache();
                }
                else if (NumCharacters == 3 && NewCharacters == 3)
                {
                    NetworkFacade.Avatars = FreshSims;
                }
            }

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

            CityInfoRequest.WriteByte(0x00); //Dummy

            Client.SendEncrypted((byte)PacketType.CITY_LIST, CityInfoRequest.ToArray());
        }