aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs189
1 files changed, 46 insertions, 143 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index ab18c93..8760c84 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -122,7 +122,7 @@ namespace OpenSim.Region.Framework.Scenes
122 else 122 else
123 { 123 {
124 m_log.WarnFormat( 124 m_log.WarnFormat(
125 "[AGENT INVENTORY]: Agent {1} could not add item {2} {3}", 125 "[AGENT INVENTORY]: Agent {0} could not add item {1} {2}",
126 AgentID, item.Name, item.ID); 126 AgentID, item.Name, item.ID);
127 127
128 return; 128 return;
@@ -984,7 +984,6 @@ namespace OpenSim.Region.Framework.Scenes
984 984
985 private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) 985 private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId)
986 { 986 {
987 Console.WriteLine("CreateAgentInventoryItemFromTask");
988 TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId); 987 TaskInventoryItem taskItem = part.Inventory.GetInventoryItem(itemId);
989 988
990 if (null == taskItem) 989 if (null == taskItem)
@@ -1055,7 +1054,10 @@ namespace OpenSim.Region.Framework.Scenes
1055 /// <param name="itemID"></param> 1054 /// <param name="itemID"></param>
1056 public InventoryItemBase MoveTaskInventoryItem(IClientAPI remoteClient, UUID folderId, SceneObjectPart part, UUID itemId) 1055 public InventoryItemBase MoveTaskInventoryItem(IClientAPI remoteClient, UUID folderId, SceneObjectPart part, UUID itemId)
1057 { 1056 {
1058 m_log.Info("Adding task inventory"); 1057 m_log.DebugFormat(
1058 "[PRIM INVENTORY]: Adding item {0} from {1} to folder {2} for {3}",
1059 itemId, part.Name, folderId, remoteClient.Name);
1060
1059 InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId); 1061 InventoryItemBase agentItem = CreateAgentInventoryItemFromTask(remoteClient.AgentId, part, itemId);
1060 1062
1061 if (agentItem == null) 1063 if (agentItem == null)
@@ -1121,7 +1123,11 @@ namespace OpenSim.Region.Framework.Scenes
1121 /// <see>MoveTaskInventoryItem</see> 1123 /// <see>MoveTaskInventoryItem</see>
1122 /// </summary> 1124 /// </summary>
1123 /// <param name="remoteClient"></param> 1125 /// <param name="remoteClient"></param>
1124 /// <param name="folderID"></param> 1126 /// <param name="folderID">
1127 /// The user inventory folder to move (or copy) the item to. If null, then the most
1128 /// suitable system folder is used (e.g. the Objects folder for objects). If there is no suitable folder, then
1129 /// the item is placed in the user's root inventory folder
1130 /// </param>
1125 /// <param name="part"></param> 1131 /// <param name="part"></param>
1126 /// <param name="itemID"></param> 1132 /// <param name="itemID"></param>
1127 public InventoryItemBase MoveTaskInventoryItem(UUID avatarId, UUID folderId, SceneObjectPart part, UUID itemId) 1133 public InventoryItemBase MoveTaskInventoryItem(UUID avatarId, UUID folderId, SceneObjectPart part, UUID itemId)
@@ -1846,53 +1852,6 @@ namespace OpenSim.Region.Framework.Scenes
1846 } 1852 }
1847 } 1853 }
1848 1854
1849 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
1850 {
1851 SceneObjectGroup objectGroup = grp;
1852 if (objectGroup != null)
1853 {
1854 if (!grp.HasGroupChanged)
1855 {
1856 m_log.InfoFormat("[ATTACHMENT]: Save request for {0} which is unchanged", grp.UUID);
1857 return;
1858 }
1859
1860 m_log.InfoFormat(
1861 "[ATTACHMENT]: Updating asset for attachment {0}, attachpoint {1}",
1862 grp.UUID, grp.GetAttachmentPoint());
1863
1864 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1865
1866 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
1867 item = InventoryService.GetItem(item);
1868
1869 if (item != null)
1870 {
1871 AssetBase asset = CreateAsset(
1872 objectGroup.GetPartName(objectGroup.LocalId),
1873 objectGroup.GetPartDescription(objectGroup.LocalId),
1874 (sbyte)AssetType.Object,
1875 Utils.StringToBytes(sceneObjectXml),
1876 remoteClient.AgentId);
1877 AssetService.Store(asset);
1878
1879 item.AssetID = asset.FullID;
1880 item.Description = asset.Description;
1881 item.Name = asset.Name;
1882 item.AssetType = asset.Type;
1883 item.InvType = (int)InventoryType.Object;
1884
1885 InventoryService.UpdateItem(item);
1886
1887 // this gets called when the agent loggs off!
1888 if (remoteClient != null)
1889 {
1890 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1891 }
1892 }
1893 }
1894 }
1895
1896 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) 1855 public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID)
1897 { 1856 {
1898 itemID = UUID.Zero; 1857 itemID = UUID.Zero;
@@ -1998,7 +1957,7 @@ namespace OpenSim.Region.Framework.Scenes
1998 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 1957 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1999 RezSelected, RemoveItem, fromTaskID, false); 1958 RezSelected, RemoveItem, fromTaskID, false);
2000 } 1959 }
2001 1960
2002 /// <summary> 1961 /// <summary>
2003 /// Rez an object into the scene from a prim's inventory. 1962 /// Rez an object into the scene from a prim's inventory.
2004 /// </summary> 1963 /// </summary>
@@ -2013,95 +1972,32 @@ namespace OpenSim.Region.Framework.Scenes
2013 SceneObjectPart sourcePart, TaskInventoryItem item, 1972 SceneObjectPart sourcePart, TaskInventoryItem item,
2014 Vector3 pos, Quaternion rot, Vector3 vel, int param) 1973 Vector3 pos, Quaternion rot, Vector3 vel, int param)
2015 { 1974 {
2016 // Rez object 1975 if (null == item)
2017 if (item != null) 1976 return null;
2018 { 1977
2019 UUID ownerID = item.OwnerID; 1978 SceneObjectGroup group = sourcePart.Inventory.GetRezReadySceneObject(item);
2020 1979
2021 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); 1980 if (null == group)
2022 1981 return null;
2023 if (rezAsset != null) 1982
2024 { 1983 if (!Permissions.CanRezObject(group.PrimCount, item.OwnerID, pos))
2025 string xmlData = Utils.BytesToString(rezAsset.Data); 1984 return null;
2026 SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
2027
2028 if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos))
2029 {
2030 return null;
2031 }
2032 group.ResetIDs();
2033
2034 AddNewSceneObject(group, true);
2035
2036 // we set it's position in world.
2037 group.AbsolutePosition = pos;
2038
2039 SceneObjectPart rootPart = group.GetChildPart(group.UUID);
2040
2041 // Since renaming the item in the inventory does not affect the name stored
2042 // in the serialization, transfer the correct name from the inventory to the
2043 // object itself before we rez.
2044 rootPart.Name = item.Name;
2045 rootPart.Description = item.Description;
2046
2047 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
2048
2049 group.SetGroup(sourcePart.GroupID, null);
2050
2051 if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
2052 {
2053 if (Permissions.PropagatePermissions())
2054 {
2055 foreach (SceneObjectPart part in partList)
2056 {
2057 part.EveryoneMask = item.EveryonePermissions;
2058 part.NextOwnerMask = item.NextPermissions;
2059 }
2060 group.ApplyNextOwnerPermissions();
2061 }
2062 }
2063
2064 foreach (SceneObjectPart part in partList)
2065 {
2066 if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
2067 {
2068 part.LastOwnerID = part.OwnerID;
2069 part.OwnerID = item.OwnerID;
2070 part.Inventory.ChangeInventoryOwner(item.OwnerID);
2071 }
2072 part.EveryoneMask = item.EveryonePermissions;
2073 part.NextOwnerMask = item.NextPermissions;
2074 }
2075
2076 rootPart.TrimPermissions();
2077
2078 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
2079 {
2080 group.ClearPartAttachmentData();
2081 }
2082
2083 group.UpdateGroupRotationR(rot);
2084
2085 //group.ApplyPhysics(m_physicalPrim);
2086 if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero)
2087 {
2088 group.RootPart.ApplyImpulse((vel * group.GetMass()), false);
2089 group.Velocity = vel;
2090 rootPart.ScheduleFullUpdate();
2091 }
2092 group.CreateScriptInstances(param, true, DefaultScriptEngine, 2);
2093 rootPart.ScheduleFullUpdate();
2094 1985
2095 if (!Permissions.BypassPermissions()) 1986 if (!Permissions.BypassPermissions())
2096 { 1987 {
2097 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) 1988 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
2098 sourcePart.Inventory.RemoveInventoryItem(item.ItemID); 1989 sourcePart.Inventory.RemoveInventoryItem(item.ItemID);
2099 }
2100 return rootPart.ParentGroup;
2101 }
2102 } 1990 }
2103 1991
2104 return null; 1992 AddNewSceneObject(group, true, pos, rot, vel);
1993
1994 // We can only call this after adding the scene object, since the scene object references the scene
1995 // to find out if scripts should be activated at all.
1996 group.CreateScriptInstances(param, true, DefaultScriptEngine, 2);
1997
1998 group.ScheduleGroupForFullUpdate();
1999
2000 return group;
2105 } 2001 }
2106 2002
2107 public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId) 2003 public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId)
@@ -2161,7 +2057,11 @@ namespace OpenSim.Region.Framework.Scenes
2161 sog.SetGroup(groupID, remoteClient); 2057 sog.SetGroup(groupID, remoteClient);
2162 sog.ScheduleGroupForFullUpdate(); 2058 sog.ScheduleGroupForFullUpdate();
2163 2059
2164 foreach (SceneObjectPart child in sog.Children.Values) 2060 List<SceneObjectPart> partList = null;
2061 lock (sog.Children)
2062 partList = new List<SceneObjectPart>(sog.Children.Values);
2063
2064 foreach (SceneObjectPart child in partList)
2165 child.Inventory.ChangeInventoryOwner(ownerID); 2065 child.Inventory.ChangeInventoryOwner(ownerID);
2166 } 2066 }
2167 else 2067 else
@@ -2171,8 +2071,12 @@ namespace OpenSim.Region.Framework.Scenes
2171 2071
2172 if (sog.GroupID != groupID) 2072 if (sog.GroupID != groupID)
2173 continue; 2073 continue;
2074
2075 List<SceneObjectPart> partList = null;
2076 lock (sog.Children)
2077 partList = new List<SceneObjectPart>(sog.Children.Values);
2174 2078
2175 foreach (SceneObjectPart child in sog.Children.Values) 2079 foreach (SceneObjectPart child in partList)
2176 { 2080 {
2177 child.LastOwnerID = child.OwnerID; 2081 child.LastOwnerID = child.OwnerID;
2178 child.Inventory.ChangeInventoryOwner(groupID); 2082 child.Inventory.ChangeInventoryOwner(groupID);
@@ -2180,8 +2084,7 @@ namespace OpenSim.Region.Framework.Scenes
2180 2084
2181 sog.SetOwnerId(groupID); 2085 sog.SetOwnerId(groupID);
2182 sog.ApplyNextOwnerPermissions(); 2086 sog.ApplyNextOwnerPermissions();
2183 } 2087 }
2184
2185 } 2088 }
2186 2089
2187 foreach (uint localID in localIDs) 2090 foreach (uint localID in localIDs)