From ffdf59a57c936189e3b161b79b4a76a3a9b260bb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 22 Oct 2011 02:16:46 +0100 Subject: Get UUIDGatherer to scan notecards in the graph for asset uuids. This is to support npc baked texture saving in oars and iars. May address http://opensimulator.org/mantis/view.php?id=5743 --- .../Framework/Scenes/Tests/UuidGathererTests.cs | 26 +++++++++++++++ OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 38 +++++++++++++--------- 2 files changed, 48 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index 24de56e..d9fe87c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs @@ -85,5 +85,31 @@ namespace OpenSim.Region.Framework.Scenes.Tests // We count the uuid as gathered even if the asset itself is missing. Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); } + + [Test] + public void TestNotecardAsset() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID ownerId = TestHelpers.ParseTail(0x10); + UUID soAssetId = TestHelpers.ParseTail(0x20); + UUID ncAssetId = TestHelpers.ParseTail(0x30); + + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId); + AssetBase soAsset = AssetHelpers.CreateAsset(soAssetId, so); + m_assetService.Store(soAsset); + + AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString()); + m_assetService.Store(ncAsset); + + IDictionary foundAssetUuids = new Dictionary(); + m_uuidGatherer.GatherAssetUuids(ncAssetId, AssetType.Notecard, foundAssetUuids); + + // We count the uuid as gathered even if the asset itself is corrupt. + Assert.That(foundAssetUuids.Count, Is.EqualTo(2)); + Assert.That(foundAssetUuids.ContainsKey(ncAssetId)); + Assert.That(foundAssetUuids.ContainsKey(soAssetId)); + } } } diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 3acdaf8..cc3f7a3 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs @@ -62,12 +62,12 @@ namespace OpenSim.Region.Framework.Scenes /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate /// asset was found by the asset service. /// - protected AssetBase m_requestedObjectAsset; + private AssetBase m_requestedObjectAsset; /// /// Signal whether we are currently waiting for the asset service to deliver an asset. /// - protected bool m_waitingForObjectAsset; + private bool m_waitingForObjectAsset; public UuidGatherer(IAssetService assetCache) { @@ -103,9 +103,13 @@ namespace OpenSim.Region.Framework.Scenes { GetGestureAssetUuids(assetUuid, assetUuids); } + else if (AssetType.Notecard == assetType) + { + GetTextEmbeddedAssetUuids(assetUuid, assetUuids); + } else if (AssetType.LSLText == assetType) { - GetScriptAssetUuids(assetUuid, assetUuids); + GetTextEmbeddedAssetUuids(assetUuid, assetUuids); } else if (AssetType.Object == assetType) { @@ -194,7 +198,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// The callback made when we request the asset for an object from the asset service. /// - protected void AssetReceived(string id, Object sender, AssetBase asset) + private void AssetReceived(string id, Object sender, AssetBase asset) { lock (this) { @@ -238,23 +242,25 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// Dictionary in which to record the references - protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary assetUuids) + private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary assetUuids) { - AssetBase scriptAsset = GetAsset(scriptUuid); + m_log.DebugFormat("[ASSET GATHERER]: Getting assets for asset {0}", embeddingAssetId); + + AssetBase embeddingAsset = GetAsset(embeddingAssetId); - if (null != scriptAsset) + if (null != embeddingAsset) { - string script = Utils.BytesToString(scriptAsset.Data); - //m_log.DebugFormat("[ARCHIVER]: Script {0}", script); - MatchCollection uuidMatches = Util.UUIDPattern.Matches(script); - //m_log.DebugFormat("[ARCHIVER]: Found {0} matches in script", uuidMatches.Count); + string script = Utils.BytesToString(embeddingAsset.Data); + m_log.DebugFormat("[ARCHIVER]: Script {0}", script); + MatchCollection uuidMatches = Util.PermissiveUUIDPattern.Matches(script); + m_log.DebugFormat("[ARCHIVER]: Found {0} matches in text", uuidMatches.Count); foreach (Match uuidMatch in uuidMatches) { UUID uuid = new UUID(uuidMatch.Value); - //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid); + m_log.DebugFormat("[ARCHIVER]: Recording {0} in text", uuid); - // Assume AssetIDs embedded in scripts are textures + // Assume AssetIDs embedded are textures. assetUuids[uuid] = AssetType.Texture; } } @@ -265,7 +271,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// Dictionary in which to record the references - protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary assetUuids) + private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary assetUuids) { AssetBase assetBase = GetAsset(wearableAssetUuid); @@ -292,7 +298,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary assetUuids) + private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary assetUuids) { AssetBase objectAsset = GetAsset(sceneObjectUuid); @@ -321,7 +327,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// - protected void GetGestureAssetUuids(UUID gestureUuid, IDictionary assetUuids) + private void GetGestureAssetUuids(UUID gestureUuid, IDictionary assetUuids) { AssetBase assetBase = GetAsset(gestureUuid); if (null == assetBase) -- cgit v1.1