Exemplo n.º 1
0
        /// <summary>
        /// Adds the asset uuid for inspection during the gathering process.
        /// </summary>
        /// <returns><c>true</c>, if for inspection was added, <c>false</c> otherwise.</returns>
        /// <param name="uuid">UUID.</param>
        public bool AddForInspection(UUID uuid)
        {
            if (uuid == UUID.Zero)
            {
                return(false);
            }

            if (FailedUUIDs.Contains(uuid))
            {
                if (UncertainAssetsUUIDs.Contains(uuid))
                {
                    possibleNotAssetCount++;
                }
                else
                {
                    ErrorCount++;
                }
                return(false);
            }
            if (GatheredUuids.ContainsKey(uuid))
            {
                return(false);
            }
            if (m_assetUuidsToInspect.Contains(uuid))
            {
                return(false);
            }

//            m_log.DebugFormat("[UUID GATHERER]: Adding asset {0} for inspection", uuid);

            m_assetUuidsToInspect.Enqueue(uuid);
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gather all the asset uuids associated with the asset referenced by a given uuid
        /// </summary>
        /// <remarks>
        /// This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        /// This method assumes that the asset type associated with this asset in persistent storage is correct (which
        /// should always be the case).  So with this method we always need to retrieve asset data even if the asset
        /// is of a type which is known not to reference any other assets
        /// </remarks>
        /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
        private void GetAssetUuids(UUID assetUuid)
        {
            // avoid infinite loops
            if (GatheredUuids.ContainsKey(assetUuid))
            {
                return;
            }

            try
            {
                AssetBase assetBase = GetAsset(assetUuid);

                if (null != assetBase)
                {
                    sbyte assetType = assetBase.Type;
                    GatheredUuids[assetUuid] = assetType;

                    if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType)
                    {
                        RecordWearableAssetUuids(assetBase);
                    }
                    else if ((sbyte)AssetType.Gesture == assetType)
                    {
                        RecordGestureAssetUuids(assetBase);
                    }
                    else if ((sbyte)AssetType.Notecard == assetType)
                    {
                        RecordTextEmbeddedAssetUuids(assetBase);
                    }
                    else if ((sbyte)AssetType.LSLText == assetType)
                    {
                        RecordTextEmbeddedAssetUuids(assetBase);
                    }
                    else if ((sbyte)OpenSimAssetType.Material == assetType)
                    {
                        RecordMaterialAssetUuids(assetBase);
                    }
                    else if ((sbyte)AssetType.Object == assetType)
                    {
                        RecordSceneObjectAssetUuids(assetBase);
                    }
                }
            }
            catch (Exception)
            {
                m_log.ErrorFormat("[UUID GATHERER]: Failed to gather uuids for asset id {0}", assetUuid);
                throw;
            }
        }
Exemplo n.º 3
0
        private void AddForInspection(UUID assetUuid, sbyte assetType)
        {
            if (assetUuid == UUID.Zero)
            {
                return;
            }

            // Here, we want to collect uuids which require further asset fetches but mark the others as gathered
            if (FailedUUIDs.Contains(assetUuid))
            {
                if (UncertainAssetsUUIDs.Contains(assetUuid))
                {
                    possibleNotAssetCount++;
                }
                else
                {
                    ErrorCount++;
                }
                return;
            }
            if (GatheredUuids.ContainsKey(assetUuid))
            {
                return;
            }
            try
            {
                if ((sbyte)AssetType.Bodypart == assetType ||
                    (sbyte)AssetType.Clothing == assetType ||
                    (sbyte)AssetType.Gesture == assetType ||
                    (sbyte)AssetType.Notecard == assetType ||
                    (sbyte)AssetType.LSLText == assetType ||
                    (sbyte)OpenSimAssetType.Material == assetType ||
                    (sbyte)AssetType.Object == assetType)
                {
                    AddForInspection(assetUuid);
                }
                else
                {
                    GatheredUuids[assetUuid] = assetType;
                }
            }
            catch (Exception)
            {
                m_log.ErrorFormat(
                    "[UUID GATHERER]: Failed to gather uuids for asset id {0}, type {1}",
                    assetUuid, assetType);
                throw;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gather all the asset uuids associated with a given object.
        /// </summary>
        /// <remarks>
        /// This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        /// </remarks>
        /// <param name="sceneObject">The scene object for which to gather assets</param>
        public void AddForInspection(SceneObjectGroup sceneObject)
        {
            //            m_log.DebugFormat(
            //                "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);

            SceneObjectPart[] parts = sceneObject.Parts;
            for (int i = 0; i < parts.Length; i++)
            {
                SceneObjectPart part = parts[i];

                //                m_log.DebugFormat(
                //                    "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);

                try
                {
                    Primitive.TextureEntry textureEntry = part.Shape.Textures;
                    if (textureEntry != null)
                    {
                        // Get the prim's default texture.  This will be used for faces which don't have their own texture
                        if (textureEntry.DefaultTexture != null)
                        {
                            RecordTextureEntryAssetUuids(textureEntry.DefaultTexture);
                        }

                        if (textureEntry.FaceTextures != null)
                        {
                            // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture)
                            foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
                            {
                                if (texture != null)
                                {
                                    RecordTextureEntryAssetUuids(texture);
                                }
                            }
                        }
                    }

                    // If the prim is a sculpt then preserve this information too
                    if (part.Shape.SculptTexture != UUID.Zero)
                    {
                        GatheredUuids[part.Shape.SculptTexture] = (sbyte)AssetType.Texture;
                    }

                    if (part.Shape.ProjectionTextureUUID != UUID.Zero)
                    {
                        GatheredUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture;
                    }

                    if (part.CollisionSound != UUID.Zero)
                    {
                        GatheredUuids[part.CollisionSound] = (sbyte)AssetType.Sound;
                    }

                    if (part.ParticleSystem.Length > 0)
                    {
                        try
                        {
                            Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0);
                            if (ps.Texture != UUID.Zero)
                            {
                                GatheredUuids[ps.Texture] = (sbyte)AssetType.Texture;
                            }
                        }
                        catch (Exception)
                        {
                            m_log.WarnFormat(
                                "[UUID GATHERER]: Could not check particle system for part {0} {1} in object {2} {3} since it is corrupt.  Continuing.",
                                part.Name, part.UUID, sceneObject.Name, sceneObject.UUID);
                        }
                    }

                    TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();

                    // Now analyze this prim's inventory items to preserve all the uuids that they reference
                    foreach (TaskInventoryItem tii in taskDictionary.Values)
                    {
                        //                        m_log.DebugFormat(
                        //                            "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}",
                        //                            tii.Name, tii.Type, part.Name, part.UUID);

                        if (!GatheredUuids.ContainsKey(tii.AssetID))
                        {
                            AddForInspection(tii.AssetID, (sbyte)tii.Type);
                        }
                    }

                    // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed
                    // to be called with scene objects that are in a scene (e.g. in the case of hg asset mapping and
                    // inventory transfer.  There needs to be a way for a module to register a method without assuming a
                    // Scene.EventManager is present.
                    //                    part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);


                    // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs
                    RecordMaterialsUuids(part);
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e);
                    m_log.DebugFormat(
                        "[UUID GATHERER]: Texture entry length for prim was {0} (min is 46)",
                        part.Shape.TextureEntry.Length);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gather all the asset uuids associated with the asset referenced by a given uuid
        /// </summary>
        /// <remarks>
        /// This includes both those directly associated with
        /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
        /// within this object).
        /// This method assumes that the asset type associated with this asset in persistent storage is correct (which
        /// should always be the case).  So with this method we always need to retrieve asset data even if the asset
        /// is of a type which is known not to reference any other assets
        /// </remarks>
        /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
        private void GetAssetUuids(UUID assetUuid)
        {
            if (assetUuid == UUID.Zero)
            {
                return;
            }

            if (FailedUUIDs.Contains(assetUuid))
            {
                if (UncertainAssetsUUIDs.Contains(assetUuid))
                {
                    possibleNotAssetCount++;
                }
                else
                {
                    ErrorCount++;
                }
                return;
            }

            // avoid infinite loops
            if (GatheredUuids.ContainsKey(assetUuid))
            {
                return;
            }

            AssetBase assetBase;

            try
            {
                assetBase = GetAsset(assetUuid);
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[UUID GATHERER]: Failed to get asset {0} : {1}", assetUuid, e.Message);
                ErrorCount++;
                FailedUUIDs.Add(assetUuid);
                return;
            }

            if (assetBase == null)
            {
                FailedUUIDs.Add(assetUuid);
                if (UncertainAssetsUUIDs.Contains(assetUuid))
                {
                    possibleNotAssetCount++;
                }
                else
                {
                    ErrorCount++;
                }
                return;
            }

            if (UncertainAssetsUUIDs.Contains(assetUuid))
            {
                UncertainAssetsUUIDs.Remove(assetUuid);
            }

            sbyte assetType = assetBase.Type;

            if (assetBase.Data == null || assetBase.Data.Length == 0)
            {
                ErrorCount++;
                FailedUUIDs.Add(assetUuid);
                return;
            }

            GatheredUuids[assetUuid] = assetType;
            try
            {
                if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType)
                {
                    RecordWearableAssetUuids(assetBase);
                }
                else if ((sbyte)AssetType.Gesture == assetType)
                {
                    RecordGestureAssetUuids(assetBase);
                }
                else if ((sbyte)AssetType.Notecard == assetType)
                {
                    RecordTextEmbeddedAssetUuids(assetBase);
                }
                else if ((sbyte)AssetType.LSLText == assetType)
                {
                    RecordTextEmbeddedAssetUuids(assetBase);
                }
                else if ((sbyte)OpenSimAssetType.Material == assetType)
                {
                    RecordMaterialAssetUuids(assetBase);
                }
                else if ((sbyte)AssetType.Object == assetType)
                {
                    RecordSceneObjectAssetUuids(assetBase);
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[UUID GATHERER]: Failed to gather uuids for asset with id {0} type {1}: {2}", assetUuid, assetType, e.Message);
                GatheredUuids.Remove(assetUuid);
                ErrorCount++;
                FailedUUIDs.Add(assetUuid);
            }
        }