aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-08-26 22:09:52 +0100
committerJustin Clark-Casey (justincc)2010-08-26 22:09:52 +0100
commit2b0f924557575777511432e5d72d21297a8002fd (patch)
tree1c36dcf3c28470adbc8cbe9277f07848aeff31d4 /OpenSim/Region
parentrefactor: break out attachment position change code in Scene.UpdatePrimPositi... (diff)
downloadopensim-SC_OLD-2b0f924557575777511432e5d72d21297a8002fd.zip
opensim-SC_OLD-2b0f924557575777511432e5d72d21297a8002fd.tar.gz
opensim-SC_OLD-2b0f924557575777511432e5d72d21297a8002fd.tar.bz2
opensim-SC_OLD-2b0f924557575777511432e5d72d21297a8002fd.tar.xz
refactor: Move Scene.Inventory.UpdateKnownItem() into Attachments module since this appears to relate solely to attachments
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs60
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs47
2 files changed, 58 insertions, 49 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index b3811bf..d56145a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -37,6 +37,7 @@ using OpenSim.Framework;
37using OpenSim.Region.Framework; 37using OpenSim.Region.Framework;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.Framework.Scenes.Serialization;
40 41
41namespace OpenSim.Region.CoreModules.Avatar.Attachments 42namespace OpenSim.Region.CoreModules.Avatar.Attachments
42{ 43{
@@ -448,7 +449,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
448 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); 449 m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
449 group.DetachToInventoryPrep(); 450 group.DetachToInventoryPrep();
450 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); 451 m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
451 m_scene.UpdateKnownItem(remoteClient, group,group.GetFromItemID(), group.OwnerID); 452 UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID);
452 m_scene.DeleteSceneObject(group, false); 453 m_scene.DeleteSceneObject(group, false);
453 return; 454 return;
454 } 455 }
@@ -471,8 +472,63 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
471 sog.UpdateGroupPosition(pos); 472 sog.UpdateGroupPosition(pos);
472 sog.RootPart.IsAttachment = false; 473 sog.RootPart.IsAttachment = false;
473 sog.AbsolutePosition = sog.RootPart.AttachedPos; 474 sog.AbsolutePosition = sog.RootPart.AttachedPos;
474 m_scene.UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID); 475 UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID);
475 sog.SetAttachmentPoint(attachmentPoint); 476 sog.SetAttachmentPoint(attachmentPoint);
476 } 477 }
478
479 /// <summary>
480 /// Update the attachment asset for the new sog details if they have changed.
481 /// </summary>
482 ///
483 /// This is essential for preserving attachment attributes such as permission. Unlike normal scene objects,
484 /// these details are not stored on the region.
485 ///
486 /// <param name="remoteClient"></param>
487 /// <param name="grp"></param>
488 /// <param name="itemID"></param>
489 /// <param name="agentID"></param>
490 protected void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
491 {
492 if (grp != null)
493 {
494 if (!grp.HasGroupChanged)
495 {
496 m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID);
497 return;
498 }
499
500 m_log.DebugFormat(
501 "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
502 grp.UUID, grp.GetAttachmentPoint());
503
504 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
505
506 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
507 item = m_scene.InventoryService.GetItem(item);
508
509 if (item != null)
510 {
511 AssetBase asset = m_scene.CreateAsset(
512 grp.GetPartName(grp.LocalId),
513 grp.GetPartDescription(grp.LocalId),
514 (sbyte)AssetType.Object,
515 Utils.StringToBytes(sceneObjectXml),
516 remoteClient.AgentId);
517 m_scene.AssetService.Store(asset);
518
519 item.AssetID = asset.FullID;
520 item.Description = asset.Description;
521 item.Name = asset.Name;
522 item.AssetType = asset.Type;
523 item.InvType = (int)InventoryType.Object;
524
525 m_scene.InventoryService.UpdateItem(item);
526
527 // this gets called when the agent logs off!
528 if (remoteClient != null)
529 remoteClient.SendInventoryItemCreateUpdate(item, 0);
530 }
531 }
532 }
477 } 533 }
478} \ No newline at end of file 534} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 379128a..8ed8b96 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1799,53 +1799,6 @@ namespace OpenSim.Region.Framework.Scenes
1799 } 1799 }
1800 } 1800 }
1801 1801
1802 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
1803 {
1804 SceneObjectGroup objectGroup = grp;
1805 if (objectGroup != null)
1806 {
1807 if (!grp.HasGroupChanged)
1808 {
1809 m_log.InfoFormat("[ATTACHMENT]: Save request for {0} which is unchanged", grp.UUID);
1810 return;
1811 }
1812
1813 m_log.InfoFormat(
1814 "[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}",
1815 grp.UUID, grp.GetAttachmentPoint());
1816
1817 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1818
1819 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
1820 item = InventoryService.GetItem(item);
1821
1822 if (item != null)
1823 {
1824 AssetBase asset = CreateAsset(
1825 objectGroup.GetPartName(objectGroup.LocalId),
1826 objectGroup.GetPartDescription(objectGroup.LocalId),
1827 (sbyte)AssetType.Object,
1828 Utils.StringToBytes(sceneObjectXml),
1829 remoteClient.AgentId);
1830 AssetService.Store(asset);
1831
1832 item.AssetID = asset.FullID;
1833 item.Description = asset.Description;
1834 item.Name = asset.Name;
1835 item.AssetType = asset.Type;
1836 item.InvType = (int)InventoryType.Object;
1837
1838 InventoryService.UpdateItem(item);
1839
1840 // this gets called when the agent loggs off!
1841 if (remoteClient != null)
1842 {
1843 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1844 }
1845 }
1846 }
1847 }
1848
1849 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) 1802 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
1850 { 1803 {
1851 itemID = UUID.Zero; 1804 itemID = UUID.Zero;