aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs102
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs84
2 files changed, 100 insertions, 86 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 88fc9e4..5661254 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -46,7 +46,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 protected Scene m_scene = null; 49 private Scene m_scene = null;
50 private IDialogModule m_dialogModule;
50 51
51 public string Name { get { return "Attachments Module"; } } 52 public string Name { get { return "Attachments Module"; } }
52 public Type ReplaceableInterface { get { return null; } } 53 public Type ReplaceableInterface { get { return null; } }
@@ -56,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
56 public void AddRegion(Scene scene) 57 public void AddRegion(Scene scene)
57 { 58 {
58 m_scene = scene; 59 m_scene = scene;
60 m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>();
59 m_scene.RegisterModuleInterface<IAttachmentsModule>(this); 61 m_scene.RegisterModuleInterface<IAttachmentsModule>(this);
60 m_scene.EventManager.OnNewClient += SubscribeToClientEvents; 62 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
61 // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI 63 // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI
@@ -228,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
228 230
229 itemID = group.GetFromItemID(); 231 itemID = group.GetFromItemID();
230 if (itemID == UUID.Zero) 232 if (itemID == UUID.Zero)
231 m_scene.attachObjectAssetStore(sp.ControllingClient, group, out itemID); 233 AddSceneObjectAsAttachment(sp.ControllingClient, group, out itemID);
232 234
233 ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); 235 ShowAttachInUserInventory(sp, AttachmentPt, itemID, group);
234 236
@@ -656,5 +658,101 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
656 // it get cleaned up 658 // it get cleaned up
657 so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); 659 so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
658 } 660 }
661
662 /// <summary>
663 /// Add a scene object that was previously free in the scene as an attachment to an avatar.
664 /// </summary>
665 /// <param name="remoteClient"></param>
666 /// <param name="grp"></param>
667 /// <param name="itemID"></param>
668 /// <returns></returns>
669 private UUID AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID)
670 {
671// m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
672
673 itemID = UUID.Zero;
674
675 Vector3 inventoryStoredPosition = new Vector3
676 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
677 ? Constants.RegionSize - 6
678 : grp.AbsolutePosition.X)
679 ,
680 (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
681 ? Constants.RegionSize - 6
682 : grp.AbsolutePosition.Y,
683 grp.AbsolutePosition.Z);
684
685 Vector3 originalPosition = grp.AbsolutePosition;
686
687 grp.AbsolutePosition = inventoryStoredPosition;
688
689 // If we're being called from a script, then trying to serialize that same script's state will not complete
690 // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
691 // the client/server crashes rather than logging out normally, the attachment's scripts will resume
692 // without state on relog. Arguably, this is what we want anyway.
693 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
694
695 grp.AbsolutePosition = originalPosition;
696
697 AssetBase asset = m_scene.CreateAsset(
698 grp.GetPartName(grp.LocalId),
699 grp.GetPartDescription(grp.LocalId),
700 (sbyte)AssetType.Object,
701 Utils.StringToBytes(sceneObjectXml),
702 remoteClient.AgentId);
703
704 m_scene.AssetService.Store(asset);
705
706 InventoryItemBase item = new InventoryItemBase();
707 item.CreatorId = grp.RootPart.CreatorID.ToString();
708 item.CreatorData = grp.RootPart.CreatorData;
709 item.Owner = remoteClient.AgentId;
710 item.ID = UUID.Random();
711 item.AssetID = asset.FullID;
712 item.Description = asset.Description;
713 item.Name = asset.Name;
714 item.AssetType = asset.Type;
715 item.InvType = (int)InventoryType.Object;
716
717 InventoryFolderBase folder = m_scene.InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
718 if (folder != null)
719 item.Folder = folder.ID;
720 else // oopsies
721 item.Folder = UUID.Zero;
722
723 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && m_scene.Permissions.PropagatePermissions())
724 {
725 item.BasePermissions = grp.RootPart.NextOwnerMask;
726 item.CurrentPermissions = grp.RootPart.NextOwnerMask;
727 item.NextPermissions = grp.RootPart.NextOwnerMask;
728 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
729 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
730 }
731 else
732 {
733 item.BasePermissions = grp.RootPart.BaseMask;
734 item.CurrentPermissions = grp.RootPart.OwnerMask;
735 item.NextPermissions = grp.RootPart.NextOwnerMask;
736 item.EveryOnePermissions = grp.RootPart.EveryoneMask;
737 item.GroupPermissions = grp.RootPart.GroupMask;
738 }
739 item.CreationDate = Util.UnixTimeSinceEpoch();
740
741 // sets itemID so client can show item as 'attached' in inventory
742 grp.SetFromItemID(item.ID);
743
744 if (m_scene.AddInventoryItem(item))
745 {
746 remoteClient.SendInventoryItemCreateUpdate(item, 0);
747 }
748 else
749 {
750 if (m_dialogModule != null)
751 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
752 }
753
754 itemID = item.ID;
755 return item.AssetID;
756 }
659 } 757 }
660} 758}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index ac73abd..9358e7b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1871,90 +1871,6 @@ namespace OpenSim.Region.Framework.Scenes
1871 } 1871 }
1872 } 1872 }
1873 1873
1874 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID)
1875 {
1876// m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId);
1877
1878 itemID = UUID.Zero;
1879
1880 Vector3 inventoryStoredPosition = new Vector3
1881 (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
1882 ? Constants.RegionSize - 6
1883 : grp.AbsolutePosition.X)
1884 ,
1885 (grp.AbsolutePosition.Y > (int)Constants.RegionSize)
1886 ? Constants.RegionSize - 6
1887 : grp.AbsolutePosition.Y,
1888 grp.AbsolutePosition.Z);
1889
1890 Vector3 originalPosition = grp.AbsolutePosition;
1891
1892 grp.AbsolutePosition = inventoryStoredPosition;
1893
1894 // If we're being called from a script, then trying to serialize that same script's state will not complete
1895 // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if
1896 // the client/server crashes rather than logging out normally, the attachment's scripts will resume
1897 // without state on relog. Arguably, this is what we want anyway.
1898 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false);
1899
1900 grp.AbsolutePosition = originalPosition;
1901
1902 AssetBase asset = CreateAsset(
1903 grp.GetPartName(grp.LocalId),
1904 grp.GetPartDescription(grp.LocalId),
1905 (sbyte)AssetType.Object,
1906 Utils.StringToBytes(sceneObjectXml),
1907 remoteClient.AgentId);
1908
1909 AssetService.Store(asset);
1910
1911 InventoryItemBase item = new InventoryItemBase();
1912 item.CreatorId = grp.RootPart.CreatorID.ToString();
1913 item.CreatorData = grp.RootPart.CreatorData;
1914 item.Owner = remoteClient.AgentId;
1915 item.ID = UUID.Random();
1916 item.AssetID = asset.FullID;
1917 item.Description = asset.Description;
1918 item.Name = asset.Name;
1919 item.AssetType = asset.Type;
1920 item.InvType = (int)InventoryType.Object;
1921
1922 InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object);
1923 if (folder != null)
1924 item.Folder = folder.ID;
1925 else // oopsies
1926 item.Folder = UUID.Zero;
1927
1928 if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions())
1929 {
1930 item.BasePermissions = grp.RootPart.NextOwnerMask;
1931 item.CurrentPermissions = grp.RootPart.NextOwnerMask;
1932 item.NextPermissions = grp.RootPart.NextOwnerMask;
1933 item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask;
1934 item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask;
1935 }
1936 else
1937 {
1938 item.BasePermissions = grp.RootPart.BaseMask;
1939 item.CurrentPermissions = grp.RootPart.OwnerMask;
1940 item.NextPermissions = grp.RootPart.NextOwnerMask;
1941 item.EveryOnePermissions = grp.RootPart.EveryoneMask;
1942 item.GroupPermissions = grp.RootPart.GroupMask;
1943 }
1944 item.CreationDate = Util.UnixTimeSinceEpoch();
1945
1946 // sets itemID so client can show item as 'attached' in inventory
1947 grp.SetFromItemID(item.ID);
1948
1949 if (AddInventoryItem(item))
1950 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1951 else
1952 m_dialogModule.SendAlertToUser(remoteClient, "Operation failed");
1953
1954 itemID = item.ID;
1955 return item.AssetID;
1956 }
1957
1958 /// <summary> 1874 /// <summary>
1959 /// Event Handler Rez an object into a scene 1875 /// Event Handler Rez an object into a scene
1960 /// Calls the non-void event handler 1876 /// Calls the non-void event handler