Ejemplo n.º 1
0
        private void RequestRegionInfoHandler(Packet packet, LLAgent agent)
        {
            RegionInfoPacket info = new RegionInfoPacket();

            info.AgentData.AgentID         = agent.ID;
            info.RegionInfo.SimName        = Utils.StringToBytes(m_scene.Name);
            info.RegionInfo.ParentEstateID = 1; // Hardcoded to what the viewer considers "mainland"
            info.RegionInfo.PricePerMeter  = 1; // Dummy value

            if (m_regionInfo != null)
            {
                // Region settings
                info.RegionInfo.MaxAgents       = (byte)Math.Min(255, m_regionInfo.MaxAgents);
                info.RegionInfo.WaterHeight     = m_regionInfo.WaterHeight;
                info.RegionInfo2.HardMaxAgents  = m_regionInfo.MaxAgents;
                info.RegionInfo2.HardMaxObjects = m_regionInfo.ObjectCapacity;
                info.RegionInfo2.MaxAgents32    = m_regionInfo.MaxAgents;
                info.RegionInfo2.ProductName    = Utils.StringToBytes(PRODUCT_NAME);
                info.RegionInfo2.ProductSKU     = Utils.EmptyBytes;
                info.RegionInfo.UseEstateSun    = m_regionInfo.UseEstateSun;
            }
            else
            {
                info.RegionInfo2.ProductName = Utils.EmptyBytes;
                info.RegionInfo2.ProductSKU  = Utils.EmptyBytes;
            }

            if (m_estate != null)
            {
                info.RegionInfo.RegionFlags       = (uint)m_estate.EstateFlags;
                info.RegionInfo.BillableFactor    = 0f;
                info.RegionInfo.EstateID          = m_estate.ID;
                info.RegionInfo.ObjectBonusFactor = m_estate.ObjectBonusFactor;
                info.RegionInfo.RedirectGridX     = 0; // TODO: What is this?
                info.RegionInfo.RedirectGridY     = 0; //
                info.RegionInfo.SimAccess         = (byte)m_estate.AccessFlags;
                info.RegionInfo.SunHour           = m_estate.SunHour;
                info.RegionInfo.TerrainLowerLimit = m_estate.TerrainLowerLimit;
                info.RegionInfo.TerrainRaiseLimit = m_estate.TerrainRaiseLimit;
            }
            else
            {
                if (m_regionInfo != null)
                {
                    info.RegionInfo.RegionFlags = (uint)m_regionInfo.RegionFlags;
                    info.RegionInfo.SimAccess   = (byte)m_regionInfo.SimAccess;
                }

                info.RegionInfo.TerrainRaiseLimit = 255f;
            }

            m_udp.SendPacket(agent, info, ThrottleCategory.Task, false);
        }
Ejemplo n.º 2
0
        private void SendImageFirstPart(ushort packetCount, byte[] imageData)
        {
            ImageDataPacket packet = new ImageDataPacket();

            packet.ImageID.ID      = TextureID;
            packet.ImageID.Packets = packetCount;
            packet.ImageID.Size    = (uint)m_asset.Length;
            packet.ImageID.Codec   = (byte)ImageCodec.J2C;

            packet.ImageData.Data = imageData;

            m_udp.SendPacket(m_agent, packet, ThrottleCategory.Texture, false);
        }
Ejemplo n.º 3
0
        private void PresenceAlertHandler(object sender, PresenceAlertArgs e)
        {
            if (e.Presence is LLAgent)
            {
                LLAgent agent = (LLAgent)e.Presence;

                AlertMessagePacket alert = new AlertMessagePacket();
                alert.AlertData.Message = Utils.StringToBytes(e.Message);
                alert.AlertInfo         = new AlertMessagePacket.AlertInfoBlock[0];

                m_udp.SendPacket(agent, alert, ThrottleCategory.Task, false);
            }
        }
Ejemplo n.º 4
0
        private void SendPreloadSoundsPacket(QueuedInterestListEvent[] eventDatas, IScenePresence presence)
        {
            if (!(presence is LLAgent) || presence.InterestList == null)
            {
                return;
            }
            LLAgent agent = (LLAgent)presence;

            PreloadSoundPacket preload = new PreloadSoundPacket();

            preload.DataBlock = new PreloadSoundPacket.DataBlockBlock[eventDatas.Length];

            for (int i = 0; i < eventDatas.Length; i++)
            {
                object[]     state   = (object[])eventDatas[i].Event.State;
                ISceneEntity source  = (ISceneEntity)state[0];
                UUID         soundID = (UUID)state[1];

                preload.DataBlock[i] = new PreloadSoundPacket.DataBlockBlock
                {
                    ObjectID = source.ID, OwnerID = source.OwnerID, SoundID = soundID
                };
            }

            m_udp.SendPacket(agent, preload, ThrottleCategory.Task, true);
        }
Ejemplo n.º 5
0
        private void SendTerrainPacket(QueuedInterestListEvent[] eventDatas, IScenePresence presence)
        {
            const int PATCHES_PER_PACKET = 3;

            if (!(presence is LLAgent) || presence.InterestList == null)
            {
                return;
            }
            LLAgent agent = (LLAgent)presence;

            List <int> patches = new List <int>(PATCHES_PER_PACKET);

            for (int i = 0; i < eventDatas.Length; i++)
            {
                int[] state = (int[])eventDatas[i].Event.State;
                int   x     = state[0];
                int   y     = state[1];

                patches.Add(y * 16 + x);

                if (patches.Count == PATCHES_PER_PACKET || i == eventDatas.Length - 1)
                {
                    LayerDataPacket packet = TerrainCompressor.CreateLandPacket(m_terrain.GetHeightmap(), patches.ToArray());
                    m_udp.SendPacket(agent, packet, ThrottleCategory.Land, false);
                    patches = new List <int>(PATCHES_PER_PACKET);
                }
            }
        }
Ejemplo n.º 6
0
        private void CompleteAgentMovementHandler(Packet packet, LLAgent agent)
        {
            //CompleteAgentMovementPacket cam = (CompleteAgentMovementPacket)packet;

            AgentMovementCompletePacket amc = new AgentMovementCompletePacket();

            amc.AgentData.AgentID      = agent.ID;
            amc.AgentData.SessionID    = agent.SessionID;
            amc.Data.LookAt            = Vector3.UnitX;
            amc.Data.Position          = new Vector3(128f, 128f, 25f);
            amc.Data.RegionHandle      = Util.PositionToRegionHandle(m_scene.MinPosition);
            amc.Data.Timestamp         = Utils.DateTimeToUnixTime(DateTime.UtcNow);
            amc.SimData.ChannelVersion = Utils.StringToBytes("Simian");

            m_log.Debug("Sending AgentMovementComplete to " + agent.Name);

            m_udp.SendPacket(agent, amc, ThrottleCategory.Task, false);
        }
Ejemplo n.º 7
0
        private void AgentDataUpdateRequestHandler(Packet packet, LLAgent agent)
        {
            string firstName, lastName;

            Util.GetFirstLastName(agent.Name, out firstName, out lastName);

            AgentDataUpdatePacket response = new AgentDataUpdatePacket();

            response.AgentData.AgentID   = agent.ID;
            response.AgentData.FirstName = Utils.StringToBytes(firstName);
            response.AgentData.LastName  = Utils.StringToBytes(lastName);

            bool groupFetchSuccess = false;
            User user;

            if (m_userClient != null && m_userClient.TryGetUser(agent.ID, out user))
            {
                OSDMap groupMap = user.GetField("active_group") as OSDMap;

                if (groupMap != null)
                {
                    response.AgentData.ActiveGroupID = groupMap["id"].AsUUID();
                    response.AgentData.GroupName     = Utils.StringToBytes(groupMap["name"].AsString());
                    response.AgentData.GroupPowers   = groupMap["powers"].AsULong();
                    response.AgentData.GroupTitle    = Utils.StringToBytes(groupMap["title"].AsString());

                    groupFetchSuccess = true;
                }
            }

            if (!groupFetchSuccess)
            {
                response.AgentData.GroupName  = Utils.EmptyBytes;
                response.AgentData.GroupTitle = Utils.EmptyBytes;
            }

            m_udp.SendPacket(agent, response, ThrottleCategory.Task, false);
        }
Ejemplo n.º 8
0
        private void ParcelInfoRequestHandler(Packet packet, LLAgent agent)
        {
            ParcelInfoRequestPacket request = (ParcelInfoRequestPacket)packet;

            SceneParcel parcel;

            if (m_parcels.TryGetParcel(request.Data.ParcelID, out parcel))
            {
                Vector3d scenePosition = m_scene.MinPosition;
                Vector3  aabbMin, aabbMax;

                ParcelInfoReplyPacket reply = new ParcelInfoReplyPacket();
                reply.AgentData.AgentID = agent.ID;
                reply.Data.ActualArea   = ParcelManager.GetParcelArea(parcel, out aabbMin, out aabbMax);
                reply.Data.AuctionID    = 0;
                reply.Data.BillableArea = reply.Data.ActualArea;
                reply.Data.Desc         = Utils.StringToBytes(parcel.Desc);
                reply.Data.Dwell        = parcel.Dwell;
                reply.Data.Flags        = (byte)parcel.Flags;
                reply.Data.GlobalX      = (float)scenePosition.X + aabbMin.X;
                reply.Data.GlobalY      = (float)scenePosition.Y + aabbMin.Y;
                reply.Data.GlobalZ      = 0f; // FIXME:
                reply.Data.Name         = Utils.StringToBytes(parcel.Name);
                reply.Data.OwnerID      = parcel.OwnerID;
                reply.Data.ParcelID     = parcel.ID;
                reply.Data.SalePrice    = parcel.SalePrice;
                reply.Data.SimName      = Utils.StringToBytes(m_scene.Name);
                reply.Data.SnapshotID   = parcel.SnapshotID;

                m_udp.SendPacket(agent, reply, ThrottleCategory.Task, false);
            }
            else
            {
                m_log.Warn(agent.Name + " requested info for unknown parcel " + request.Data.ParcelID);
            }
        }
Ejemplo n.º 9
0
        private void SendAvatarAnimationPackets(QueuedInterestListEvent[] eventDatas, IScenePresence presence)
        {
            if (!(presence is LLAgent) || presence.InterestList == null)
            {
                return;
            }
            LLAgent agent = (LLAgent)presence;

            for (int i = 0; i < eventDatas.Length; i++)
            {
                LLAgent animAgent = (LLAgent)eventDatas[i].Event.State;

                AvatarAnimationPacket packet = new AvatarAnimationPacket();
                packet.Sender.ID = animAgent.ID;

                Animation[] animations = animAgent.Animations.GetAnimations();

                packet.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
                for (int j = 0; j < animations.Length; j++)
                {
                    Animation animation = animations[j];
                    packet.AnimationList[j] = new AvatarAnimationPacket.AnimationListBlock {
                        AnimID = animation.ID, AnimSequenceID = animation.SequenceNum
                    };
                }

                packet.AnimationSourceList    = new AvatarAnimationPacket.AnimationSourceListBlock[1];
                packet.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock {
                    ObjectID = animAgent.ID
                };

                packet.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];

                m_udp.SendPacket(agent, packet, ThrottleCategory.Task, false);
            }
        }
Ejemplo n.º 10
0
        private void RequestTaskInventoryHandler(Packet packet, LLAgent agent)
        {
            RequestTaskInventoryPacket request = (RequestTaskInventoryPacket)packet;

            // Try to find this object in the scene
            ISceneEntity entity;

            if (m_scene.TryGetEntity(request.InventoryData.LocalID, out entity) && entity is LLPrimitive)
            {
                LLPrimitive prim = (LLPrimitive)entity;

                ReplyTaskInventoryPacket reply = new ReplyTaskInventoryPacket();
                reply.InventoryData.Filename = Utils.StringToBytes(prim.Inventory.GetInventoryFilename());
                reply.InventoryData.Serial   = prim.Inventory.InventorySerial;
                reply.InventoryData.TaskID   = prim.ID;

                m_udp.SendPacket(agent, reply, ThrottleCategory.Task, false);
            }
            else
            {
                m_log.Warn(agent.Name + " requested task inventory for prim " + request.InventoryData.LocalID +
                           " that does not exist in this scene");
            }
        }
Ejemplo n.º 11
0
        public static void SendRegionHandshake(LLAgent agent, LLUDP udp, IScene scene, RegionInfo regionInfo, LLPermissions permissions)
        {
            RegionHandshakePacket handshake = new RegionHandshakePacket();

            // If the CacheID changes, the viewer will purge its object cache for this scene. We
            // just use the sceneID as the cacheID to make sure the viewer retains its object cache
            handshake.RegionInfo.CacheID         = scene.ID;
            handshake.RegionInfo.SimName         = Utils.StringToBytes(scene.Name);
            handshake.RegionInfo2.RegionID       = scene.ID;
            handshake.RegionInfo.IsEstateManager = (permissions != null) ? permissions.IsEstateManager(agent) : true;
            handshake.RegionInfo3.ColoName       = Utils.EmptyBytes;
            handshake.RegionInfo3.CPUClassID     = 0;
            handshake.RegionInfo3.CPURatio       = 0;

            if (regionInfo != null)
            {
                handshake.RegionInfo3.ProductName         = Utils.StringToBytes(PRODUCT_NAME);
                handshake.RegionInfo3.ProductSKU          = Utils.EmptyBytes;
                handshake.RegionInfo.RegionFlags          = (uint)regionInfo.RegionFlags;
                handshake.RegionInfo.SimAccess            = (byte)regionInfo.SimAccess;
                handshake.RegionInfo.SimOwner             = regionInfo.OwnerID;
                handshake.RegionInfo.TerrainBase0         = UUID.Zero;
                handshake.RegionInfo.TerrainBase1         = UUID.Zero;
                handshake.RegionInfo.TerrainBase2         = UUID.Zero;
                handshake.RegionInfo.TerrainBase3         = UUID.Zero;
                handshake.RegionInfo.TerrainDetail0       = regionInfo.TerrainDetail0;
                handshake.RegionInfo.TerrainDetail1       = regionInfo.TerrainDetail1;
                handshake.RegionInfo.TerrainDetail2       = regionInfo.TerrainDetail2;
                handshake.RegionInfo.TerrainDetail3       = regionInfo.TerrainDetail3;
                handshake.RegionInfo.TerrainHeightRange00 = regionInfo.TerrainHeightRange00;
                handshake.RegionInfo.TerrainHeightRange01 = regionInfo.TerrainHeightRange01;
                handshake.RegionInfo.TerrainHeightRange10 = regionInfo.TerrainHeightRange10;
                handshake.RegionInfo.TerrainHeightRange11 = regionInfo.TerrainHeightRange11;
                handshake.RegionInfo.TerrainStartHeight00 = regionInfo.TerrainStartHeight00;
                handshake.RegionInfo.TerrainStartHeight01 = regionInfo.TerrainStartHeight01;
                handshake.RegionInfo.TerrainStartHeight10 = regionInfo.TerrainStartHeight10;
                handshake.RegionInfo.TerrainStartHeight11 = regionInfo.TerrainStartHeight11;
                handshake.RegionInfo.WaterHeight          = regionInfo.WaterHeight;
            }
            else
            {
                handshake.RegionInfo3.ProductName = Utils.EmptyBytes;
                handshake.RegionInfo3.ProductSKU  = Utils.EmptyBytes;
                handshake.RegionInfo.SimAccess    = (byte)SimAccess.PG;
            }

            udp.SendPacket(agent, handshake, ThrottleCategory.Task, false);
        }
Ejemplo n.º 12
0
        public bool SendInstantMessage(UUID messageID, UUID toAgentID, string fromName, Vector3 fromPosition,
                                       UUID fromRegionID, bool fromGroup, InstantMessageDialog type, string message, bool allowOffline,
                                       DateTime timestamp, byte[] binaryBucket)
        {
            // Cap the message length at 1023 + null terminator
            if (!String.IsNullOrEmpty(message) && message.Length > 1023)
            {
                message = message.Substring(0, 1023);
            }

            // FIXME: Support IMing to remote agents
            IScenePresence presence;

            if (m_scene.TryGetPresence(toAgentID, out presence) && presence is LLAgent)
            {
                LLAgent agent = (LLAgent)presence;

                ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket();
                im.AgentData.AgentID           = agent.ID;
                im.MessageBlock.Dialog         = (byte)type;
                im.MessageBlock.FromAgentName  = Utils.StringToBytes(fromName);
                im.MessageBlock.FromGroup      = fromGroup;
                im.MessageBlock.ID             = messageID;
                im.MessageBlock.Message        = Utils.StringToBytes(message);
                im.MessageBlock.Offline        = (byte)((allowOffline) ? 1 : 0);
                im.MessageBlock.ParentEstateID = 0;
                im.MessageBlock.Position       = fromPosition;
                im.MessageBlock.RegionID       = fromRegionID;
                im.MessageBlock.Timestamp      = Utils.DateTimeToUnixTime(timestamp);
                im.MessageBlock.ToAgentID      = agent.ID;
                im.MessageBlock.BinaryBucket   = binaryBucket ?? Utils.EmptyBytes;

                m_udp.SendPacket(agent, im, ThrottleCategory.Task, false);
                return(true);
            }
            else
            {
                m_log.Warn("Dropping instant message from " + fromName + " to " + toAgentID + " that does not exist in the local scene");
                return(false);
            }
        }
Ejemplo n.º 13
0
        private void RequestXferHandler(Packet packet, LLAgent agent)
        {
            RequestXferPacket request = (RequestXferPacket)packet;

            string filename = Utils.BytesToString(request.XferID.Filename);

            UUID taskInventoryID;

            if (filename.StartsWith("inventory_") && filename.EndsWith(".tmp") && UUID.TryParse(filename.Substring(10, 36), out taskInventoryID))
            {
                // This is a request for a task inventory listing, which we generate on demand
                ISceneEntity entity;
                if (m_scene.TryGetEntity(taskInventoryID, out entity) && entity is LLPrimitive)
                {
                    LLPrimitive prim      = (LLPrimitive)entity;
                    byte[]      assetData = Encoding.UTF8.GetBytes(prim.Inventory.GetTaskInventoryAsset());

                    SendXferPacketPacket xfer = new SendXferPacketPacket();
                    xfer.XferID.ID = request.XferID.ID;

                    if (assetData.Length < 1000)
                    {
                        xfer.XferID.Packet   = 0 | LAST_PACKET_MARKER;
                        xfer.DataPacket.Data = new byte[assetData.Length + 4];
                        Utils.IntToBytes(assetData.Length, xfer.DataPacket.Data, 0);
                        Buffer.BlockCopy(assetData, 0, xfer.DataPacket.Data, 4, assetData.Length);

                        m_udp.SendPacket(agent, xfer, ThrottleCategory.Asset, false);
                        m_log.Debug("Completed single packet xfer download of " + filename);
                    }
                    else
                    {
                        xfer.XferID.Packet   = 0;
                        xfer.DataPacket.Data = new byte[1000 + 4];
                        Utils.IntToBytes(assetData.Length, xfer.DataPacket.Data, 0);
                        Buffer.BlockCopy(assetData, 0, xfer.DataPacket.Data, 4, 1000);

                        // We don't need the entire XferDownload class, just the asset data and the current packet number
                        XferDownload download = new XferDownload();
                        download.AssetData = assetData;
                        download.PacketNum = 1;
                        download.Filename  = filename;
                        lock (currentDownloads)
                            currentDownloads[request.XferID.ID] = download;

                        m_udp.SendPacket(agent, xfer, ThrottleCategory.Asset, false);
                    }
                }
                else
                {
                    m_log.Warn("Could not find primitive " + taskInventoryID);
                }
            }
            else
            {
                m_log.Warn("Got a RequestXfer for an unknown file: " + filename);
            }
        }
Ejemplo n.º 14
0
        public static void SendRegionHandshake(LLAgent agent, LLUDP udp, IScene scene, RegionInfo regionInfo, LLPermissions permissions)
        {
            RegionHandshakePacket handshake = new RegionHandshakePacket();

            // If the CacheID changes, the viewer will purge its object cache for this scene. We
            // just use the sceneID as the cacheID to make sure the viewer retains its object cache
            handshake.RegionInfo.CacheID = scene.ID;
            handshake.RegionInfo.SimName = Utils.StringToBytes(scene.Name);
            handshake.RegionInfo2.RegionID = scene.ID;
            handshake.RegionInfo.IsEstateManager = (permissions != null) ? permissions.IsEstateManager(agent) : true;
            handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
            handshake.RegionInfo3.CPUClassID = 0;
            handshake.RegionInfo3.CPURatio = 0;

            if (regionInfo != null)
            {
                handshake.RegionInfo3.ProductName = Utils.StringToBytes(PRODUCT_NAME);
                handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
                handshake.RegionInfo.RegionFlags = (uint)regionInfo.RegionFlags;
                handshake.RegionInfo.SimAccess = (byte)regionInfo.SimAccess;
                handshake.RegionInfo.SimOwner = regionInfo.OwnerID;
                handshake.RegionInfo.TerrainBase0 = UUID.Zero;
                handshake.RegionInfo.TerrainBase1 = UUID.Zero;
                handshake.RegionInfo.TerrainBase2 = UUID.Zero;
                handshake.RegionInfo.TerrainBase3 = UUID.Zero;
                handshake.RegionInfo.TerrainDetail0 = regionInfo.TerrainDetail0;
                handshake.RegionInfo.TerrainDetail1 = regionInfo.TerrainDetail1;
                handshake.RegionInfo.TerrainDetail2 = regionInfo.TerrainDetail2;
                handshake.RegionInfo.TerrainDetail3 = regionInfo.TerrainDetail3;
                handshake.RegionInfo.TerrainHeightRange00 = regionInfo.TerrainHeightRange00;
                handshake.RegionInfo.TerrainHeightRange01 = regionInfo.TerrainHeightRange01;
                handshake.RegionInfo.TerrainHeightRange10 = regionInfo.TerrainHeightRange10;
                handshake.RegionInfo.TerrainHeightRange11 = regionInfo.TerrainHeightRange11;
                handshake.RegionInfo.TerrainStartHeight00 = regionInfo.TerrainStartHeight00;
                handshake.RegionInfo.TerrainStartHeight01 = regionInfo.TerrainStartHeight01;
                handshake.RegionInfo.TerrainStartHeight10 = regionInfo.TerrainStartHeight10;
                handshake.RegionInfo.TerrainStartHeight11 = regionInfo.TerrainStartHeight11;
                handshake.RegionInfo.WaterHeight = regionInfo.WaterHeight;
            }
            else
            {
                handshake.RegionInfo3.ProductName = Utils.EmptyBytes;
                handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
                handshake.RegionInfo.SimAccess = (byte)SimAccess.PG;
            }

            udp.SendPacket(agent, handshake, ThrottleCategory.Task, false);
        }
Ejemplo n.º 15
0
        private void EnqueueRequest(LLAgent agent, UUID textureID, sbyte discardLevel, float priority, uint packetNumber, uint sequenceNumber)
        {
            J2KImage image;

            // Look up this texture download
            lock (m_priorityQueue)
                m_queuedTextures.TryGetValue(textureID, out image);

            if (image != null)
            {
                // Update for an existing texture request
                if (discardLevel == -1 && priority == 0f)
                {
                    //m_log.Debug("[TEX]: (CAN) ID=" + textureID);

                    try
                    {
                        lock (m_priorityQueue)
                        {
                            m_priorityQueue.Delete(image.PriorityQueueHandle);
                            m_queuedTextures.Remove(textureID);
                        }
                    }
                    catch (Exception) { }
                }
                else
                {
                    //m_log.DebugFormat("[TEX]: (UPD) ID={0}: D={1}, S={2}, P={3}", textureID, discardLevel, packetNumber, priority);

                    // Check the packet sequence to make sure this update isn't older than
                    // one we've already received
                    if (sequenceNumber > image.LastSequence)
                    {
                        // Update the sequence number of the last RequestImage packet
                        image.LastSequence = sequenceNumber;

                        //Update the requested discard level
                        image.DiscardLevel = discardLevel;

                        //Update the requested packet number
                        image.StartPacket = Math.Max(1, packetNumber);

                        //Update the requested priority
                        image.Priority = priority;

                        // Update the start/end offsets for this request
                        image.UpdateOffsets();

                        UpdateImageInQueue(image);
                    }
                }
            }
            else
            {
                // New texture request
                if (discardLevel == -1 && priority == 0f)
                {
                    //m_log.DebugFormat("[TEX]: (IGN) ID={0}", textureID);
                }
                else
                {
                    //m_log.DebugFormat("[TEX]: (NEW) ID={0}: D={1}, S={2}, P={3}", textureID, discardLevel, packetNumber, priority);

                    Asset asset;
                    if (m_assetClient.TryGetAsset(textureID, "image/x-j2c", out asset))
                    {
                        image = new J2KImage(m_udp, asset, agent, discardLevel, Math.Max(1, packetNumber), priority);

                        // Update the start/end offsets for this request
                        image.UpdateOffsets();

                        // Add this download to the priority queue
                        UpdateImageInQueue(image);
                    }
                    else
                    {
                        ImageNotInDatabasePacket missing = new ImageNotInDatabasePacket();
                        missing.ImageID.ID = textureID;
                        m_udp.SendPacket(agent, missing, ThrottleCategory.Asset, true);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private void AgentWearablesRequestHandler(Packet packet, LLAgent agent)
        {
            AgentWearablesUpdatePacket update = new AgentWearablesUpdatePacket();

            update.AgentData.AgentID = agent.ID;

            User user;

            if (m_userClient != null && m_userClient.TryGetUser(agent.ID, out user))
            {
                OSDMap appearanceMap = user.GetField("LLAppearance") as OSDMap;

                if (appearanceMap != null)
                {
                    Dictionary <WearableType, UUID> items  = new Dictionary <WearableType, UUID>();
                    Dictionary <WearableType, UUID> assets = new Dictionary <WearableType, UUID>();

                    foreach (KeyValuePair <string, OSD> kvp in appearanceMap)
                    {
                        UUID id = kvp.Value.AsUUID();
                        if (id != UUID.Zero)
                        {
                            #region LLAppearance Parsing

                            switch (kvp.Key)
                            {
                            case "ShapeItem":
                                items[WearableType.Shape] = id;
                                break;

                            case "SkinItem":
                                items[WearableType.Skin] = id;
                                break;

                            case "HairItem":
                                items[WearableType.Hair] = id;
                                break;

                            case "EyesItem":
                                items[WearableType.Eyes] = id;
                                break;

                            case "ShirtItem":
                                items[WearableType.Shirt] = id;
                                break;

                            case "PantsItem":
                                items[WearableType.Pants] = id;
                                break;

                            case "ShoesItem":
                                items[WearableType.Shoes] = id;
                                break;

                            case "SocksItem":
                                items[WearableType.Socks] = id;
                                break;

                            case "JacketItem":
                                items[WearableType.Jacket] = id;
                                break;

                            case "GlovesItem":
                                items[WearableType.Gloves] = id;
                                break;

                            case "UndershirtItem":
                                items[WearableType.Undershirt] = id;
                                break;

                            case "UnderpantsItem":
                                items[WearableType.Underpants] = id;
                                break;

                            case "SkirtItem":
                                items[WearableType.Skirt] = id;
                                break;

                            case "AlphaItem":
                                items[WearableType.Alpha] = id;
                                break;

                            case "TattooItem":
                                items[WearableType.Tattoo] = id;
                                break;

                            case "ShapeAsset":
                                assets[WearableType.Shape] = id;
                                break;

                            case "SkinAsset":
                                assets[WearableType.Skin] = id;
                                break;

                            case "HairAsset":
                                assets[WearableType.Hair] = id;
                                break;

                            case "EyesAsset":
                                assets[WearableType.Eyes] = id;
                                break;

                            case "ShirtAsset":
                                assets[WearableType.Shirt] = id;
                                break;

                            case "PantsAsset":
                                assets[WearableType.Pants] = id;
                                break;

                            case "ShoesAsset":
                                assets[WearableType.Shoes] = id;
                                break;

                            case "SocksAsset":
                                assets[WearableType.Socks] = id;
                                break;

                            case "JacketAsset":
                                assets[WearableType.Jacket] = id;
                                break;

                            case "GlovesAsset":
                                assets[WearableType.Gloves] = id;
                                break;

                            case "UndershirtAsset":
                                assets[WearableType.Undershirt] = id;
                                break;

                            case "UnderpantsAsset":
                                assets[WearableType.Underpants] = id;
                                break;

                            case "SkirtAsset":
                                assets[WearableType.Skirt] = id;
                                break;

                            case "AlphaAsset":
                                assets[WearableType.Alpha] = id;
                                break;

                            case "TattooAsset":
                                assets[WearableType.Tattoo] = id;
                                break;
                            }

                            #endregion LLAppearance Parsing
                        }
                    }

                    update.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[items.Count];
                    int i = 0;
                    foreach (KeyValuePair <WearableType, UUID> kvp in items)
                    {
                        update.WearableData[i] = new AgentWearablesUpdatePacket.WearableDataBlock();
                        update.WearableData[i].WearableType = (byte)kvp.Key;
                        update.WearableData[i].ItemID       = kvp.Value;
                        assets.TryGetValue(kvp.Key, out update.WearableData[i].AssetID);
                        ++i;
                    }
                }
                else
                {
                    // FIXME: Don't allow clouds! In this case we should assign a default appearance
                    m_log.Warn("User record does not contain an LLAppearance entry, appearance will not be set");
                }
            }

            if (update.WearableData == null)
            {
                update.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[0];
            }

            m_log.DebugFormat("Sending info about {0} wearables to {1}", update.WearableData.Length, agent.Name);

            update.AgentData.SerialNum = (uint)System.Threading.Interlocked.Increment(ref agent.CurrentWearablesSerialNum);
            m_udp.SendPacket(agent, update, ThrottleCategory.Asset, false);
        }
Ejemplo n.º 17
0
        private void AgentRequestSitHandler(Packet packet, LLAgent agent)
        {
            AgentRequestSitPacket request = (AgentRequestSitPacket)packet;

            agent.RequestedSitTarget = request.TargetObject.TargetID;
            agent.RequestedSitOffset = request.TargetObject.Offset;

            //TODO: move to AgentSitHandler when we figure out how to make the client send AgentSit
            ISceneEntity seat;

            if (m_scene.TryGetEntity(agent.RequestedSitTarget, out seat) && seat is ILinkable)
            {
                agent.SetParent((ILinkable)seat, false, false);

                AvatarSitResponsePacket response = new AvatarSitResponsePacket();
                response.SitObject.ID = agent.RequestedSitTarget;

                if (seat is LLPrimitive)
                {
                    LLPrimitive prim = (LLPrimitive)seat;
                    if (prim.SitPosition != Vector3.Zero)
                    {
                        // llSitTarget is set

                        response.SitTransform.SitPosition = prim.SitPosition;
                        response.SitTransform.SitRotation = prim.SitRotation;

                        agent.RelativePosition = LLUtil.GetSitTarget(prim.SitPosition, agent.Scale);
                        agent.RelativeRotation = prim.SitRotation;
                    }
                    else
                    {
                        // No sit target set

                        Vector3 sitPos = LLUtil.GetSitTarget(agent.RequestedSitOffset, agent.Scale);

                        response.SitTransform.SitPosition = sitPos;
                        response.SitTransform.SitRotation = Quaternion.Identity;

                        agent.RelativePosition = sitPos;
                        agent.RelativeRotation = Quaternion.Identity;
                    }
                }

                m_udp.SendPacket(agent, response, ThrottleCategory.Task, false);

                m_scene.EntityAddOrUpdate(this, agent, UpdateFlags.Parent, 0);

                agent.Animations.SetDefaultAnimation(OpenMetaverse.Animations.SIT, 1);
                m_scene.SendPresenceAnimations(this, agent);

                if (m_lslScriptEngine != null)
                {
                    m_lslScriptEngine.PostObjectEvent(seat.ID, "changed", new object[] { CHANGED_LINK }, new DetectParams[0]);
                }
            }
            else
            {
                //TODO: send error message
            }
        }