aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-10-22 02:16:46 +0100
committerJustin Clark-Casey (justincc)2011-10-22 02:16:46 +0100
commitffdf59a57c936189e3b161b79b4a76a3a9b260bb (patch)
treec857a6214e291e5b91f1241107b84baa3b9f246f /OpenSim/Region
parentredirect UserInventoryHelpers to use a different CreateNotecardAsset() so we ... (diff)
downloadopensim-SC_OLD-ffdf59a57c936189e3b161b79b4a76a3a9b260bb.zip
opensim-SC_OLD-ffdf59a57c936189e3b161b79b4a76a3a9b260bb.tar.gz
opensim-SC_OLD-ffdf59a57c936189e3b161b79b4a76a3a9b260bb.tar.bz2
opensim-SC_OLD-ffdf59a57c936189e3b161b79b4a76a3a9b260bb.tar.xz
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
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs38
2 files changed, 48 insertions, 16 deletions
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
85 // We count the uuid as gathered even if the asset itself is missing. 85 // We count the uuid as gathered even if the asset itself is missing.
86 Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); 86 Assert.That(foundAssetUuids.Count, Is.EqualTo(1));
87 } 87 }
88
89 [Test]
90 public void TestNotecardAsset()
91 {
92 TestHelpers.InMethod();
93// log4net.Config.XmlConfigurator.Configure();
94
95 UUID ownerId = TestHelpers.ParseTail(0x10);
96 UUID soAssetId = TestHelpers.ParseTail(0x20);
97 UUID ncAssetId = TestHelpers.ParseTail(0x30);
98
99 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId);
100 AssetBase soAsset = AssetHelpers.CreateAsset(soAssetId, so);
101 m_assetService.Store(soAsset);
102
103 AssetBase ncAsset = AssetHelpers.CreateNotecardAsset(ncAssetId, soAssetId.ToString());
104 m_assetService.Store(ncAsset);
105
106 IDictionary<UUID, AssetType> foundAssetUuids = new Dictionary<UUID, AssetType>();
107 m_uuidGatherer.GatherAssetUuids(ncAssetId, AssetType.Notecard, foundAssetUuids);
108
109 // We count the uuid as gathered even if the asset itself is corrupt.
110 Assert.That(foundAssetUuids.Count, Is.EqualTo(2));
111 Assert.That(foundAssetUuids.ContainsKey(ncAssetId));
112 Assert.That(foundAssetUuids.ContainsKey(soAssetId));
113 }
88 } 114 }
89} 115}
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
62 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate 62 /// Used as a temporary store of an asset which represents an object. This can be a null if no appropriate
63 /// asset was found by the asset service. 63 /// asset was found by the asset service.
64 /// </summary> 64 /// </summary>
65 protected AssetBase m_requestedObjectAsset; 65 private AssetBase m_requestedObjectAsset;
66 66
67 /// <summary> 67 /// <summary>
68 /// Signal whether we are currently waiting for the asset service to deliver an asset. 68 /// Signal whether we are currently waiting for the asset service to deliver an asset.
69 /// </summary> 69 /// </summary>
70 protected bool m_waitingForObjectAsset; 70 private bool m_waitingForObjectAsset;
71 71
72 public UuidGatherer(IAssetService assetCache) 72 public UuidGatherer(IAssetService assetCache)
73 { 73 {
@@ -103,9 +103,13 @@ namespace OpenSim.Region.Framework.Scenes
103 { 103 {
104 GetGestureAssetUuids(assetUuid, assetUuids); 104 GetGestureAssetUuids(assetUuid, assetUuids);
105 } 105 }
106 else if (AssetType.Notecard == assetType)
107 {
108 GetTextEmbeddedAssetUuids(assetUuid, assetUuids);
109 }
106 else if (AssetType.LSLText == assetType) 110 else if (AssetType.LSLText == assetType)
107 { 111 {
108 GetScriptAssetUuids(assetUuid, assetUuids); 112 GetTextEmbeddedAssetUuids(assetUuid, assetUuids);
109 } 113 }
110 else if (AssetType.Object == assetType) 114 else if (AssetType.Object == assetType)
111 { 115 {
@@ -194,7 +198,7 @@ namespace OpenSim.Region.Framework.Scenes
194 /// <summary> 198 /// <summary>
195 /// The callback made when we request the asset for an object from the asset service. 199 /// The callback made when we request the asset for an object from the asset service.
196 /// </summary> 200 /// </summary>
197 protected void AssetReceived(string id, Object sender, AssetBase asset) 201 private void AssetReceived(string id, Object sender, AssetBase asset)
198 { 202 {
199 lock (this) 203 lock (this)
200 { 204 {
@@ -238,23 +242,25 @@ namespace OpenSim.Region.Framework.Scenes
238 /// </summary> 242 /// </summary>
239 /// <param name="scriptUuid"></param> 243 /// <param name="scriptUuid"></param>
240 /// <param name="assetUuids">Dictionary in which to record the references</param> 244 /// <param name="assetUuids">Dictionary in which to record the references</param>
241 protected void GetScriptAssetUuids(UUID scriptUuid, IDictionary<UUID, AssetType> assetUuids) 245 private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, AssetType> assetUuids)
242 { 246 {
243 AssetBase scriptAsset = GetAsset(scriptUuid); 247 m_log.DebugFormat("[ASSET GATHERER]: Getting assets for asset {0}", embeddingAssetId);
248
249 AssetBase embeddingAsset = GetAsset(embeddingAssetId);
244 250
245 if (null != scriptAsset) 251 if (null != embeddingAsset)
246 { 252 {
247 string script = Utils.BytesToString(scriptAsset.Data); 253 string script = Utils.BytesToString(embeddingAsset.Data);
248 //m_log.DebugFormat("[ARCHIVER]: Script {0}", script); 254 m_log.DebugFormat("[ARCHIVER]: Script {0}", script);
249 MatchCollection uuidMatches = Util.UUIDPattern.Matches(script); 255 MatchCollection uuidMatches = Util.PermissiveUUIDPattern.Matches(script);
250 //m_log.DebugFormat("[ARCHIVER]: Found {0} matches in script", uuidMatches.Count); 256 m_log.DebugFormat("[ARCHIVER]: Found {0} matches in text", uuidMatches.Count);
251 257
252 foreach (Match uuidMatch in uuidMatches) 258 foreach (Match uuidMatch in uuidMatches)
253 { 259 {
254 UUID uuid = new UUID(uuidMatch.Value); 260 UUID uuid = new UUID(uuidMatch.Value);
255 //m_log.DebugFormat("[ARCHIVER]: Recording {0} in script", uuid); 261 m_log.DebugFormat("[ARCHIVER]: Recording {0} in text", uuid);
256 262
257 // Assume AssetIDs embedded in scripts are textures 263 // Assume AssetIDs embedded are textures.
258 assetUuids[uuid] = AssetType.Texture; 264 assetUuids[uuid] = AssetType.Texture;
259 } 265 }
260 } 266 }
@@ -265,7 +271,7 @@ namespace OpenSim.Region.Framework.Scenes
265 /// </summary> 271 /// </summary>
266 /// <param name="wearableAssetUuid"></param> 272 /// <param name="wearableAssetUuid"></param>
267 /// <param name="assetUuids">Dictionary in which to record the references</param> 273 /// <param name="assetUuids">Dictionary in which to record the references</param>
268 protected void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids) 274 private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids)
269 { 275 {
270 AssetBase assetBase = GetAsset(wearableAssetUuid); 276 AssetBase assetBase = GetAsset(wearableAssetUuid);
271 277
@@ -292,7 +298,7 @@ namespace OpenSim.Region.Framework.Scenes
292 /// </summary> 298 /// </summary>
293 /// <param name="sceneObject"></param> 299 /// <param name="sceneObject"></param>
294 /// <param name="assetUuids"></param> 300 /// <param name="assetUuids"></param>
295 protected void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids) 301 private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids)
296 { 302 {
297 AssetBase objectAsset = GetAsset(sceneObjectUuid); 303 AssetBase objectAsset = GetAsset(sceneObjectUuid);
298 304
@@ -321,7 +327,7 @@ namespace OpenSim.Region.Framework.Scenes
321 /// </summary> 327 /// </summary>
322 /// <param name="gestureUuid"></param> 328 /// <param name="gestureUuid"></param>
323 /// <param name="assetUuids"></param> 329 /// <param name="assetUuids"></param>
324 protected void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids) 330 private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids)
325 { 331 {
326 AssetBase assetBase = GetAsset(gestureUuid); 332 AssetBase assetBase = GetAsset(gestureUuid);
327 if (null == assetBase) 333 if (null == assetBase)