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.cs561
1 files changed, 33 insertions, 528 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index c6cee75..ded001b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -35,7 +35,7 @@ using OpenMetaverse;
35using OpenMetaverse.Packets; 35using OpenMetaverse.Packets;
36using log4net; 36using log4net;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications.Cache; 38
39using OpenSim.Region.Framework; 39using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes.Serialization; 41using OpenSim.Region.Framework.Scenes.Serialization;
@@ -101,12 +101,6 @@ namespace OpenSim.Region.Framework.Scenes
101 { 101 {
102 userlevel = 1; 102 userlevel = 1;
103 } 103 }
104 // TODO: remove this cruft once MasterAvatar is fully deprecated
105 //
106 if (m_regInfo.MasterAvatarAssignedUUID == AgentID)
107 {
108 userlevel = 2;
109 }
110 EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); 104 EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel);
111 } 105 }
112 else 106 else
@@ -132,61 +126,6 @@ namespace OpenSim.Region.Framework.Scenes
132 } 126 }
133 127
134 /// <summary> 128 /// <summary>
135 /// Capability originating call to update the asset of an item in an agent's inventory
136 /// </summary>
137 /// <param name="remoteClient"></param>
138 /// <param name="itemID"></param>
139 /// <param name="data"></param>
140 /// <returns></returns>
141 public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
142 {
143 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
144 item = InventoryService.GetItem(item);
145
146 if (item != null)
147 {
148 if ((InventoryType)item.InvType == InventoryType.Notecard)
149 {
150 if (!Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
151 {
152 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
153 return UUID.Zero;
154 }
155
156 remoteClient.SendAgentAlertMessage("Notecard saved", false);
157 }
158 else if ((InventoryType)item.InvType == InventoryType.LSL)
159 {
160 if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
161 {
162 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
163 return UUID.Zero;
164 }
165
166 remoteClient.SendAgentAlertMessage("Script saved", false);
167 }
168
169 AssetBase asset =
170 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data);
171 item.AssetID = asset.FullID;
172 AssetService.Store(asset);
173
174 InventoryService.UpdateItem(item);
175
176 // remoteClient.SendInventoryItemCreateUpdate(item);
177 return (asset.FullID);
178 }
179 else
180 {
181 m_log.ErrorFormat(
182 "[AGENT INVENTORY]: Could not find item {0} for caps inventory update",
183 itemID);
184 }
185
186 return UUID.Zero;
187 }
188
189 /// <summary>
190 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> 129 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
191 /// </summary> 130 /// </summary>
192 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) 131 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data)
@@ -195,7 +134,9 @@ namespace OpenSim.Region.Framework.Scenes
195 134
196 if (TryGetAvatar(avatarId, out avatar)) 135 if (TryGetAvatar(avatarId, out avatar))
197 { 136 {
198 return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); 137 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
138 if (invAccess != null)
139 return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
199 } 140 }
200 else 141 else
201 { 142 {
@@ -478,7 +419,11 @@ namespace OpenSim.Region.Framework.Scenes
478 itemCopy.SaleType = item.SaleType; 419 itemCopy.SaleType = item.SaleType;
479 420
480 if (InventoryService.AddItem(itemCopy)) 421 if (InventoryService.AddItem(itemCopy))
481 TransferInventoryAssets(itemCopy, senderId, recipient); 422 {
423 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
424 if (invAccess != null)
425 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
426 }
482 427
483 if (!Permissions.BypassPermissions()) 428 if (!Permissions.BypassPermissions())
484 { 429 {
@@ -500,10 +445,6 @@ namespace OpenSim.Region.Framework.Scenes
500 445
501 } 446 }
502 447
503 protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
504 {
505 }
506
507 /// <summary> 448 /// <summary>
508 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent 449 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent
509 /// folders) is given. 450 /// folders) is given.
@@ -573,7 +514,9 @@ namespace OpenSim.Region.Framework.Scenes
573 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", 514 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
574 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); 515 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
575 516
576 InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); 517 InventoryItemBase item = null;
518 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
519 item = LibraryService.LibraryRootFolder.FindItem(oldItemID);
577 520
578 if (item == null) 521 if (item == null)
579 { 522 {
@@ -745,13 +688,9 @@ namespace OpenSim.Region.Framework.Scenes
745 688
746 if (transactionID == UUID.Zero) 689 if (transactionID == UUID.Zero)
747 { 690 {
748 CachedUserInfo userInfo 691 ScenePresence presence;
749 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 692 if (TryGetAvatar(remoteClient.AgentId, out presence))
750
751 if (userInfo != null)
752 { 693 {
753 ScenePresence presence;
754 TryGetAvatar(remoteClient.AgentId, out presence);
755 byte[] data = null; 694 byte[] data = null;
756 695
757 if (invType == (sbyte)InventoryType.Landmark && presence != null) 696 if (invType == (sbyte)InventoryType.Landmark && presence != null)
@@ -773,7 +712,7 @@ namespace OpenSim.Region.Framework.Scenes
773 else 712 else
774 { 713 {
775 m_log.ErrorFormat( 714 m_log.ErrorFormat(
776 "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", 715 "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
777 remoteClient.AgentId); 716 remoteClient.AgentId);
778 } 717 }
779 } 718 }
@@ -1166,15 +1105,21 @@ namespace OpenSim.Region.Framework.Scenes
1166 1105
1167 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) 1106 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems)
1168 { 1107 {
1108 if (folder == null)
1109 return;
1110
1169 m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); 1111 m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName);
1170 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); 1112 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID);
1171 InventoryFolderBase containingFolder = new InventoryFolderBase(); 1113 InventoryFolderBase containingFolder = new InventoryFolderBase();
1172 containingFolder.ID = folder.ID; 1114 containingFolder.ID = folder.ID;
1173 containingFolder.Owner = client.AgentId; 1115 containingFolder.Owner = client.AgentId;
1174 containingFolder = InventoryService.GetFolder(containingFolder); 1116 containingFolder = InventoryService.GetFolder(containingFolder);
1175 int version = containingFolder.Version; 1117 if (containingFolder != null)
1118 {
1119 int version = containingFolder.Version;
1176 1120
1177 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); 1121 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems);
1122 }
1178 } 1123 }
1179 1124
1180 /// <summary> 1125 /// <summary>
@@ -1216,9 +1161,9 @@ namespace OpenSim.Region.Framework.Scenes
1216 item = InventoryService.GetItem(item); 1161 item = InventoryService.GetItem(item);
1217 1162
1218 // Try library 1163 // Try library
1219 if (null == item) 1164 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1220 { 1165 {
1221 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1166 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1222 } 1167 }
1223 1168
1224 if (item != null) 1169 if (item != null)
@@ -1285,9 +1230,9 @@ namespace OpenSim.Region.Framework.Scenes
1285 1230
1286 // Try library 1231 // Try library
1287 // XXX clumsy, possibly should be one call 1232 // XXX clumsy, possibly should be one call
1288 if (null == item) 1233 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1289 { 1234 {
1290 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1235 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1291 } 1236 }
1292 1237
1293 if (item != null) 1238 if (item != null)
@@ -1612,232 +1557,6 @@ namespace OpenSim.Region.Framework.Scenes
1612 } 1557 }
1613 } 1558 }
1614 1559
1615 /// <summary>
1616 /// Delete a scene object from a scene and place in the given avatar's inventory.
1617 /// Returns the UUID of the newly created asset.
1618 /// </summary>
1619 /// <param name="action"></param>
1620 /// <param name="folderID"></param>
1621 /// <param name="objectGroup"></param>
1622 /// <param name="remoteClient"> </param>
1623 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
1624 SceneObjectGroup objectGroup, IClientAPI remoteClient)
1625 {
1626 UUID assetID = UUID.Zero;
1627
1628 Vector3 inventoryStoredPosition = new Vector3
1629 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1630 ? 250
1631 : objectGroup.AbsolutePosition.X)
1632 ,
1633 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1634 ? 250
1635 : objectGroup.AbsolutePosition.X,
1636 objectGroup.AbsolutePosition.Z);
1637
1638 Vector3 originalPosition = objectGroup.AbsolutePosition;
1639
1640 objectGroup.AbsolutePosition = inventoryStoredPosition;
1641
1642 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1643
1644 objectGroup.AbsolutePosition = originalPosition;
1645
1646 // Get the user info of the item destination
1647 //
1648 UUID userID = UUID.Zero;
1649
1650 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
1651 action == DeRezAction.SaveToExistingUserInventoryItem)
1652 {
1653 // Take or take copy require a taker
1654 // Saving changes requires a local user
1655 //
1656 if (remoteClient == null)
1657 return UUID.Zero;
1658
1659 userID = remoteClient.AgentId;
1660 }
1661 else
1662 {
1663 // All returns / deletes go to the object owner
1664 //
1665
1666 userID = objectGroup.RootPart.OwnerID;
1667 }
1668
1669 if (userID == UUID.Zero) // Can't proceed
1670 {
1671 return UUID.Zero;
1672 }
1673
1674 // If we're returning someone's item, it goes back to the
1675 // owner's Lost And Found folder.
1676 // Delete is treated like return in this case
1677 // Deleting your own items makes them go to trash
1678 //
1679
1680 InventoryFolderBase folder = null;
1681 InventoryItemBase item = null;
1682
1683 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1684 {
1685 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID);
1686 item = InventoryService.GetItem(item);
1687
1688 //item = userInfo.RootFolder.FindItem(
1689 // objectGroup.RootPart.FromUserInventoryItemID);
1690
1691 if (null == item)
1692 {
1693 m_log.DebugFormat(
1694 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
1695 objectGroup.Name, objectGroup.UUID);
1696 return UUID.Zero;
1697 }
1698 }
1699 else
1700 {
1701 // Folder magic
1702 //
1703 if (action == DeRezAction.Delete)
1704 {
1705 // Deleting someone else's item
1706 //
1707
1708
1709 if (remoteClient == null ||
1710 objectGroup.OwnerID != remoteClient.AgentId)
1711 {
1712 // Folder skeleton may not be loaded and we
1713 // have to wait for the inventory to find
1714 // the destination folder
1715 //
1716 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1717 }
1718 else
1719 {
1720 // Assume inventory skeleton was loaded during login
1721 // and all folders can be found
1722 //
1723 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1724 }
1725 }
1726 else if (action == DeRezAction.Return)
1727 {
1728
1729 // Dump to lost + found unconditionally
1730 //
1731 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1732 }
1733
1734 if (folderID == UUID.Zero && folder == null)
1735 {
1736 if (action == DeRezAction.Delete)
1737 {
1738 // Deletes go to trash by default
1739 //
1740 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1741 }
1742 else
1743 {
1744 // Catch all. Use lost & found
1745 //
1746
1747 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1748 }
1749 }
1750
1751 if (folder == null) // None of the above
1752 {
1753 //folder = userInfo.RootFolder.FindFolder(folderID);
1754 folder = new InventoryFolderBase(folderID);
1755
1756 if (folder == null) // Nowhere to put it
1757 {
1758 return UUID.Zero;
1759 }
1760 }
1761
1762 item = new InventoryItemBase();
1763 item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
1764 item.ID = UUID.Random();
1765 item.InvType = (int)InventoryType.Object;
1766 item.Folder = folder.ID;
1767 item.Owner = userID;
1768 }
1769
1770 AssetBase asset = CreateAsset(
1771 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
1772 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
1773 (sbyte)AssetType.Object,
1774 Utils.StringToBytes(sceneObjectXml));
1775 AssetService.Store(asset);
1776 assetID = asset.FullID;
1777
1778 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1779 {
1780 item.AssetID = asset.FullID;
1781 InventoryService.UpdateItem(item);
1782 }
1783 else
1784 {
1785 item.AssetID = asset.FullID;
1786
1787 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
1788 {
1789 uint perms=objectGroup.GetEffectivePermissions();
1790 uint nextPerms=(perms & 7) << 13;
1791 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
1792 perms &= ~(uint)PermissionMask.Copy;
1793 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
1794 perms &= ~(uint)PermissionMask.Transfer;
1795 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
1796 perms &= ~(uint)PermissionMask.Modify;
1797
1798 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
1799 item.CurrentPermissions = item.BasePermissions;
1800 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1801 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
1802 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
1803 item.CurrentPermissions |= 8; // Slam!
1804 }
1805 else
1806 {
1807 item.BasePermissions = objectGroup.GetEffectivePermissions();
1808 item.CurrentPermissions = objectGroup.GetEffectivePermissions();
1809 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1810 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1811 item.GroupPermissions = objectGroup.RootPart.GroupMask;
1812
1813 item.CurrentPermissions |= 8; // Slam!
1814 }
1815
1816 // TODO: add the new fields (Flags, Sale info, etc)
1817 item.CreationDate = Util.UnixTimeSinceEpoch();
1818 item.Description = asset.Description;
1819 item.Name = asset.Name;
1820 item.AssetType = asset.Type;
1821
1822 InventoryService.AddItem(item);
1823
1824 if (remoteClient != null && item.Owner == remoteClient.AgentId)
1825 {
1826 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1827 }
1828 else
1829 {
1830 ScenePresence notifyUser = GetScenePresence(item.Owner);
1831 if (notifyUser != null)
1832 {
1833 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
1834 }
1835 }
1836 }
1837
1838 return assetID;
1839 }
1840
1841 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) 1560 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
1842 { 1561 {
1843 SceneObjectGroup objectGroup = grp; 1562 SceneObjectGroup objectGroup = grp;
@@ -1978,225 +1697,11 @@ namespace OpenSim.Region.Framework.Scenes
1978 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1697 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1979 bool RezSelected, bool RemoveItem, UUID fromTaskID) 1698 bool RezSelected, bool RemoveItem, UUID fromTaskID)
1980 { 1699 {
1981 RezObject( 1700 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
1982 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 1701 if (invAccess != null)
1983 RezSelected, RemoveItem, fromTaskID, false); 1702 invAccess.RezObject(
1984 } 1703 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1985 1704 RezSelected, RemoveItem, fromTaskID, false);
1986 /// <summary>
1987 /// Rez an object into the scene from the user's inventory
1988 /// </summary>
1989 /// <param name="remoteClient"></param>
1990 /// <param name="itemID"></param>
1991 /// <param name="RayEnd"></param>
1992 /// <param name="RayStart"></param>
1993 /// <param name="RayTargetID"></param>
1994 /// <param name="BypassRayCast"></param>
1995 /// <param name="RayEndIsIntersection"></param>
1996 /// <param name="RezSelected"></param>
1997 /// <param name="RemoveItem"></param>
1998 /// <param name="fromTaskID"></param>
1999 /// <param name="attachment"></param>
2000 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
2001 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
2002 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
2003 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
2004 {
2005 // Work out position details
2006 byte bRayEndIsIntersection = (byte)0;
2007
2008 if (RayEndIsIntersection)
2009 {
2010 bRayEndIsIntersection = (byte)1;
2011 }
2012 else
2013 {
2014 bRayEndIsIntersection = (byte)0;
2015 }
2016
2017 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
2018
2019
2020 Vector3 pos = GetNewRezLocation(
2021 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2022 BypassRayCast, bRayEndIsIntersection,true,scale, false);
2023
2024 // Rez object
2025 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2026 item = InventoryService.GetItem(item);
2027
2028 if (item != null)
2029 {
2030 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString());
2031
2032 if (rezAsset != null)
2033 {
2034 UUID itemId = UUID.Zero;
2035
2036 // If we have permission to copy then link the rezzed object back to the user inventory
2037 // item that it came from. This allows us to enable 'save object to inventory'
2038 if (!Permissions.BypassPermissions())
2039 {
2040 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
2041 {
2042 itemId = item.ID;
2043 }
2044 }
2045 else
2046 {
2047 // Brave new fullperm world
2048 //
2049 itemId = item.ID;
2050 }
2051
2052 string xmlData = Utils.BytesToString(rezAsset.Data);
2053 SceneObjectGroup group
2054 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
2055
2056 if (!Permissions.CanRezObject(
2057 group.Children.Count, remoteClient.AgentId, pos)
2058 && !attachment)
2059 {
2060 // The client operates in no fail mode. It will
2061 // have already removed the item from the folder
2062 // if it's no copy.
2063 // Put it back if it's not an attachment
2064 //
2065 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
2066 remoteClient.SendBulkUpdateInventory(item);
2067 return null;
2068 }
2069
2070 group.ResetIDs();
2071
2072 if (attachment)
2073 {
2074 group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
2075 group.RootPart.IsAttachment = true;
2076 }
2077
2078 AddNewSceneObject(group, true);
2079
2080 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
2081 // if attachment we set it's asset id so object updates can reflect that
2082 // if not, we set it's position in world.
2083 if (!attachment)
2084 {
2085 float offsetHeight = 0;
2086 pos = GetNewRezLocation(
2087 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2088 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
2089 pos.Z += offsetHeight;
2090 group.AbsolutePosition = pos;
2091 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
2092
2093 }
2094 else
2095 {
2096 group.SetFromItemID(itemID);
2097 }
2098
2099 SceneObjectPart rootPart = null;
2100 try
2101 {
2102 rootPart = group.GetChildPart(group.UUID);
2103 }
2104 catch (NullReferenceException)
2105 {
2106 string isAttachment = "";
2107
2108 if (attachment)
2109 isAttachment = " Object was an attachment";
2110
2111 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
2112 }
2113
2114 // Since renaming the item in the inventory does not affect the name stored
2115 // in the serialization, transfer the correct name from the inventory to the
2116 // object itself before we rez.
2117 rootPart.Name = item.Name;
2118 rootPart.Description = item.Description;
2119
2120 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
2121
2122 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
2123 if (rootPart.OwnerID != item.Owner)
2124 {
2125 //Need to kill the for sale here
2126 rootPart.ObjectSaleType = 0;
2127 rootPart.SalePrice = 10;
2128
2129 if (Permissions.PropagatePermissions())
2130 {
2131 if ((item.CurrentPermissions & 8) != 0)
2132 {
2133 foreach (SceneObjectPart part in partList)
2134 {
2135 part.EveryoneMask = item.EveryOnePermissions;
2136 part.NextOwnerMask = item.NextPermissions;
2137 part.GroupMask = 0; // DO NOT propagate here
2138 }
2139 }
2140 group.ApplyNextOwnerPermissions();
2141 }
2142 }
2143
2144 foreach (SceneObjectPart part in partList)
2145 {
2146 if (part.OwnerID != item.Owner)
2147 {
2148 part.LastOwnerID = part.OwnerID;
2149 part.OwnerID = item.Owner;
2150 part.Inventory.ChangeInventoryOwner(item.Owner);
2151 }
2152 else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
2153 {
2154 part.EveryoneMask = item.EveryOnePermissions;
2155 part.NextOwnerMask = item.NextPermissions;
2156
2157 part.GroupMask = 0; // DO NOT propagate here
2158 }
2159 }
2160
2161 rootPart.TrimPermissions();
2162
2163 if (!attachment)
2164 {
2165 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
2166 {
2167 group.ClearPartAttachmentData();
2168 }
2169 }
2170
2171 if (!attachment)
2172 {
2173 // Fire on_rez
2174 group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
2175
2176 rootPart.ScheduleFullUpdate();
2177 }
2178
2179 if (!Permissions.BypassPermissions())
2180 {
2181 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
2182 {
2183 // If this is done on attachments, no
2184 // copy ones will be lost, so avoid it
2185 //
2186 if (!attachment)
2187 {
2188 List<UUID> uuids = new List<UUID>();
2189 uuids.Add(item.ID);
2190 InventoryService.DeleteItems(item.Owner, uuids);
2191 }
2192 }
2193 }
2194
2195 return rootPart.ParentGroup;
2196 }
2197 }
2198
2199 return null;
2200 } 1705 }
2201 1706
2202 /// <summary> 1707 /// <summary>
@@ -2420,7 +1925,7 @@ namespace OpenSim.Region.Framework.Scenes
2420 // XXYY!! 1925 // XXYY!!
2421 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 1926 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2422 item = InventoryService.GetItem(item); 1927 item = InventoryService.GetItem(item);
2423 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 1928 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
2424 1929
2425 if (m_AvatarFactory != null) 1930 if (m_AvatarFactory != null)
2426 { 1931 {