示例#1
0
 /// <summary>
 /// A new player joined the session.
 /// </summary>
 /// <param name="Avatar">Player's avatar.</param>
 private void NetworkController_OnPlayerJoinedSession(Sim Avatar)
 {
     LstParticipants.Invoke(new MethodInvoker(delegate
         {
             LstParticipants.Items.Add(Avatar.Name);
         }));
 }
示例#2
0
        public ChatFrm(Sim Avatar)
        {
            InitializeComponent();

            m_CurrentSim = Avatar;
            PictureBox1.Image = Avatar.Thumbnail;
            LblName.Text = Avatar.Name;

            NetworkController.OnPlayerJoinedSession += new OnPlayerJoinedSessionDelegate(NetworkController_OnPlayerJoinedSession);
            NetworkController.OnReceivedMessage += new OnReceivedMessageDelegate(NetworkController_OnReceivedMessage);
        }
        /// <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<Sim> FreshSims = new List<Sim>();

            for (int i = 0; i < NewCharacters; 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();
                FreshSim.Description = Packet.ReadString();
                FreshSim.HeadOutfitID = Packet.ReadUInt64();
                FreshSim.BodyOutfitID = Packet.ReadUInt64();
                FreshSim.Appearance = (AppearanceType)Packet.ReadByte();
                
                FreshSim.ResidingCity = new CityInfo(false);
                FreshSim.ResidingCity.Name = Packet.ReadString();
                FreshSim.ResidingCity.Description = "";
                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);
            }

            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());
        }
        /// <summary>
        /// A player joined a session (game) in progress.
        /// </summary>
        public static Sim OnPlayerJoinedSession(ProcessedPacket Packet)
        {
            Sim Avatar = new Sim(Packet.ReadPascalString());
            Avatar.Name = Packet.ReadPascalString();
            Avatar.Sex = Packet.ReadPascalString();
            Avatar.Description = Packet.ReadPascalString();
            Avatar.HeadOutfitID = Packet.ReadUInt64();
            Avatar.BodyOutfitID = Packet.ReadUInt64();
            Avatar.Appearance = (AppearanceType)Packet.ReadInt32();

            lock (NetworkFacade.AvatarsInSession)
            {
                NetworkFacade.AvatarsInSession.Add(Avatar);
            }

            return Avatar;
        }