diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 561 |
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 7df3e50..e032a07 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -35,7 +35,7 @@ using OpenMetaverse; | |||
35 | using OpenMetaverse.Packets; | 35 | using OpenMetaverse.Packets; |
36 | using log4net; | 36 | using log4net; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications.Cache; | 38 | |
39 | using OpenSim.Region.Framework; | 39 | using OpenSim.Region.Framework; |
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes.Serialization; | 41 | using 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 | { |
@@ -742,13 +685,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
742 | 685 | ||
743 | if (transactionID == UUID.Zero) | 686 | if (transactionID == UUID.Zero) |
744 | { | 687 | { |
745 | CachedUserInfo userInfo | 688 | ScenePresence presence; |
746 | = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | 689 | if (TryGetAvatar(remoteClient.AgentId, out presence)) |
747 | |||
748 | if (userInfo != null) | ||
749 | { | 690 | { |
750 | ScenePresence presence; | ||
751 | TryGetAvatar(remoteClient.AgentId, out presence); | ||
752 | byte[] data = null; | 691 | byte[] data = null; |
753 | 692 | ||
754 | if (invType == (sbyte)InventoryType.Landmark && presence != null) | 693 | if (invType == (sbyte)InventoryType.Landmark && presence != null) |
@@ -770,7 +709,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
770 | else | 709 | else |
771 | { | 710 | { |
772 | m_log.ErrorFormat( | 711 | m_log.ErrorFormat( |
773 | "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", | 712 | "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", |
774 | remoteClient.AgentId); | 713 | remoteClient.AgentId); |
775 | } | 714 | } |
776 | } | 715 | } |
@@ -1163,15 +1102,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1163 | 1102 | ||
1164 | private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) | 1103 | private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) |
1165 | { | 1104 | { |
1105 | if (folder == null) | ||
1106 | return; | ||
1107 | |||
1166 | m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); | 1108 | m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); |
1167 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); | 1109 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); |
1168 | InventoryFolderBase containingFolder = new InventoryFolderBase(); | 1110 | InventoryFolderBase containingFolder = new InventoryFolderBase(); |
1169 | containingFolder.ID = folder.ID; | 1111 | containingFolder.ID = folder.ID; |
1170 | containingFolder.Owner = client.AgentId; | 1112 | containingFolder.Owner = client.AgentId; |
1171 | containingFolder = InventoryService.GetFolder(containingFolder); | 1113 | containingFolder = InventoryService.GetFolder(containingFolder); |
1172 | int version = containingFolder.Version; | 1114 | if (containingFolder != null) |
1115 | { | ||
1116 | int version = containingFolder.Version; | ||
1173 | 1117 | ||
1174 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); | 1118 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); |
1119 | } | ||
1175 | } | 1120 | } |
1176 | 1121 | ||
1177 | /// <summary> | 1122 | /// <summary> |
@@ -1213,9 +1158,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1213 | item = InventoryService.GetItem(item); | 1158 | item = InventoryService.GetItem(item); |
1214 | 1159 | ||
1215 | // Try library | 1160 | // Try library |
1216 | if (null == item) | 1161 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1217 | { | 1162 | { |
1218 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1163 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1219 | } | 1164 | } |
1220 | 1165 | ||
1221 | if (item != null) | 1166 | if (item != null) |
@@ -1282,9 +1227,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1282 | 1227 | ||
1283 | // Try library | 1228 | // Try library |
1284 | // XXX clumsy, possibly should be one call | 1229 | // XXX clumsy, possibly should be one call |
1285 | if (null == item) | 1230 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1286 | { | 1231 | { |
1287 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1232 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1288 | } | 1233 | } |
1289 | 1234 | ||
1290 | if (item != null) | 1235 | if (item != null) |
@@ -1609,232 +1554,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1609 | } | 1554 | } |
1610 | } | 1555 | } |
1611 | 1556 | ||
1612 | /// <summary> | ||
1613 | /// Delete a scene object from a scene and place in the given avatar's inventory. | ||
1614 | /// Returns the UUID of the newly created asset. | ||
1615 | /// </summary> | ||
1616 | /// <param name="action"></param> | ||
1617 | /// <param name="folderID"></param> | ||
1618 | /// <param name="objectGroup"></param> | ||
1619 | /// <param name="remoteClient"> </param> | ||
1620 | public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, | ||
1621 | SceneObjectGroup objectGroup, IClientAPI remoteClient) | ||
1622 | { | ||
1623 | UUID assetID = UUID.Zero; | ||
1624 | |||
1625 | Vector3 inventoryStoredPosition = new Vector3 | ||
1626 | (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1627 | ? 250 | ||
1628 | : objectGroup.AbsolutePosition.X) | ||
1629 | , | ||
1630 | (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1631 | ? 250 | ||
1632 | : objectGroup.AbsolutePosition.X, | ||
1633 | objectGroup.AbsolutePosition.Z); | ||
1634 | |||
1635 | Vector3 originalPosition = objectGroup.AbsolutePosition; | ||
1636 | |||
1637 | objectGroup.AbsolutePosition = inventoryStoredPosition; | ||
1638 | |||
1639 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); | ||
1640 | |||
1641 | objectGroup.AbsolutePosition = originalPosition; | ||
1642 | |||
1643 | // Get the user info of the item destination | ||
1644 | // | ||
1645 | UUID userID = UUID.Zero; | ||
1646 | |||
1647 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || | ||
1648 | action == DeRezAction.SaveToExistingUserInventoryItem) | ||
1649 | { | ||
1650 | // Take or take copy require a taker | ||
1651 | // Saving changes requires a local user | ||
1652 | // | ||
1653 | if (remoteClient == null) | ||
1654 | return UUID.Zero; | ||
1655 | |||
1656 | userID = remoteClient.AgentId; | ||
1657 | } | ||
1658 | else | ||
1659 | { | ||
1660 | // All returns / deletes go to the object owner | ||
1661 | // | ||
1662 | |||
1663 | userID = objectGroup.RootPart.OwnerID; | ||
1664 | } | ||
1665 | |||
1666 | if (userID == UUID.Zero) // Can't proceed | ||
1667 | { | ||
1668 | return UUID.Zero; | ||
1669 | } | ||
1670 | |||
1671 | // If we're returning someone's item, it goes back to the | ||
1672 | // owner's Lost And Found folder. | ||
1673 | // Delete is treated like return in this case | ||
1674 | // Deleting your own items makes them go to trash | ||
1675 | // | ||
1676 | |||
1677 | InventoryFolderBase folder = null; | ||
1678 | InventoryItemBase item = null; | ||
1679 | |||
1680 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
1681 | { | ||
1682 | item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); | ||
1683 | item = InventoryService.GetItem(item); | ||
1684 | |||
1685 | //item = userInfo.RootFolder.FindItem( | ||
1686 | // objectGroup.RootPart.FromUserInventoryItemID); | ||
1687 | |||
1688 | if (null == item) | ||
1689 | { | ||
1690 | m_log.DebugFormat( | ||
1691 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", | ||
1692 | objectGroup.Name, objectGroup.UUID); | ||
1693 | return UUID.Zero; | ||
1694 | } | ||
1695 | } | ||
1696 | else | ||
1697 | { | ||
1698 | // Folder magic | ||
1699 | // | ||
1700 | if (action == DeRezAction.Delete) | ||
1701 | { | ||
1702 | // Deleting someone else's item | ||
1703 | // | ||
1704 | |||
1705 | |||
1706 | if (remoteClient == null || | ||
1707 | objectGroup.OwnerID != remoteClient.AgentId) | ||
1708 | { | ||
1709 | // Folder skeleton may not be loaded and we | ||
1710 | // have to wait for the inventory to find | ||
1711 | // the destination folder | ||
1712 | // | ||
1713 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1714 | } | ||
1715 | else | ||
1716 | { | ||
1717 | // Assume inventory skeleton was loaded during login | ||
1718 | // and all folders can be found | ||
1719 | // | ||
1720 | folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
1721 | } | ||
1722 | } | ||
1723 | else if (action == DeRezAction.Return) | ||
1724 | { | ||
1725 | |||
1726 | // Dump to lost + found unconditionally | ||
1727 | // | ||
1728 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1729 | } | ||
1730 | |||
1731 | if (folderID == UUID.Zero && folder == null) | ||
1732 | { | ||
1733 | if (action == DeRezAction.Delete) | ||
1734 | { | ||
1735 | // Deletes go to trash by default | ||
1736 | // | ||
1737 | folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
1738 | } | ||
1739 | else | ||
1740 | { | ||
1741 | // Catch all. Use lost & found | ||
1742 | // | ||
1743 | |||
1744 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1745 | } | ||
1746 | } | ||
1747 | |||
1748 | if (folder == null) // None of the above | ||
1749 | { | ||
1750 | //folder = userInfo.RootFolder.FindFolder(folderID); | ||
1751 | folder = new InventoryFolderBase(folderID); | ||
1752 | |||
1753 | if (folder == null) // Nowhere to put it | ||
1754 | { | ||
1755 | return UUID.Zero; | ||
1756 | } | ||
1757 | } | ||
1758 | |||
1759 | item = new InventoryItemBase(); | ||
1760 | item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); | ||
1761 | item.ID = UUID.Random(); | ||
1762 | item.InvType = (int)InventoryType.Object; | ||
1763 | item.Folder = folder.ID; | ||
1764 | item.Owner = userID; | ||
1765 | } | ||
1766 | |||
1767 | AssetBase asset = CreateAsset( | ||
1768 | objectGroup.GetPartName(objectGroup.RootPart.LocalId), | ||
1769 | objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), | ||
1770 | (sbyte)AssetType.Object, | ||
1771 | Utils.StringToBytes(sceneObjectXml)); | ||
1772 | AssetService.Store(asset); | ||
1773 | assetID = asset.FullID; | ||
1774 | |||
1775 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
1776 | { | ||
1777 | item.AssetID = asset.FullID; | ||
1778 | InventoryService.UpdateItem(item); | ||
1779 | } | ||
1780 | else | ||
1781 | { | ||
1782 | item.AssetID = asset.FullID; | ||
1783 | |||
1784 | if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
1785 | { | ||
1786 | uint perms=objectGroup.GetEffectivePermissions(); | ||
1787 | uint nextPerms=(perms & 7) << 13; | ||
1788 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
1789 | perms &= ~(uint)PermissionMask.Copy; | ||
1790 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
1791 | perms &= ~(uint)PermissionMask.Transfer; | ||
1792 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
1793 | perms &= ~(uint)PermissionMask.Modify; | ||
1794 | |||
1795 | item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; | ||
1796 | item.CurrentPermissions = item.BasePermissions; | ||
1797 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1798 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; | ||
1799 | item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; | ||
1800 | item.CurrentPermissions |= 8; // Slam! | ||
1801 | } | ||
1802 | else | ||
1803 | { | ||
1804 | item.BasePermissions = objectGroup.GetEffectivePermissions(); | ||
1805 | item.CurrentPermissions = objectGroup.GetEffectivePermissions(); | ||
1806 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1807 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; | ||
1808 | item.GroupPermissions = objectGroup.RootPart.GroupMask; | ||
1809 | |||
1810 | item.CurrentPermissions |= 8; // Slam! | ||
1811 | } | ||
1812 | |||
1813 | // TODO: add the new fields (Flags, Sale info, etc) | ||
1814 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
1815 | item.Description = asset.Description; | ||
1816 | item.Name = asset.Name; | ||
1817 | item.AssetType = asset.Type; | ||
1818 | |||
1819 | InventoryService.AddItem(item); | ||
1820 | |||
1821 | if (remoteClient != null && item.Owner == remoteClient.AgentId) | ||
1822 | { | ||
1823 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
1824 | } | ||
1825 | else | ||
1826 | { | ||
1827 | ScenePresence notifyUser = GetScenePresence(item.Owner); | ||
1828 | if (notifyUser != null) | ||
1829 | { | ||
1830 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); | ||
1831 | } | ||
1832 | } | ||
1833 | } | ||
1834 | |||
1835 | return assetID; | ||
1836 | } | ||
1837 | |||
1838 | public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) | 1557 | public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) |
1839 | { | 1558 | { |
1840 | SceneObjectGroup objectGroup = grp; | 1559 | SceneObjectGroup objectGroup = grp; |
@@ -1975,225 +1694,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1975 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 1694 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, |
1976 | bool RezSelected, bool RemoveItem, UUID fromTaskID) | 1695 | bool RezSelected, bool RemoveItem, UUID fromTaskID) |
1977 | { | 1696 | { |
1978 | RezObject( | 1697 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); |
1979 | remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 1698 | if (invAccess != null) |
1980 | RezSelected, RemoveItem, fromTaskID, false); | 1699 | invAccess.RezObject( |
1981 | } | 1700 | remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
1982 | 1701 | RezSelected, RemoveItem, fromTaskID, false); | |
1983 | /// <summary> | ||
1984 | /// Rez an object into the scene from the user's inventory | ||
1985 | /// </summary> | ||
1986 | /// <param name="remoteClient"></param> | ||
1987 | /// <param name="itemID"></param> | ||
1988 | /// <param name="RayEnd"></param> | ||
1989 | /// <param name="RayStart"></param> | ||
1990 | /// <param name="RayTargetID"></param> | ||
1991 | /// <param name="BypassRayCast"></param> | ||
1992 | /// <param name="RayEndIsIntersection"></param> | ||
1993 | /// <param name="RezSelected"></param> | ||
1994 | /// <param name="RemoveItem"></param> | ||
1995 | /// <param name="fromTaskID"></param> | ||
1996 | /// <param name="attachment"></param> | ||
1997 | /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns> | ||
1998 | public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | ||
1999 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
2000 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
2001 | { | ||
2002 | // Work out position details | ||
2003 | byte bRayEndIsIntersection = (byte)0; | ||
2004 | |||
2005 | if (RayEndIsIntersection) | ||
2006 | { | ||
2007 | bRayEndIsIntersection = (byte)1; | ||
2008 | } | ||
2009 | else | ||
2010 | { | ||
2011 | bRayEndIsIntersection = (byte)0; | ||
2012 | } | ||
2013 | |||
2014 | Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); | ||
2015 | |||
2016 | |||
2017 | Vector3 pos = GetNewRezLocation( | ||
2018 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | ||
2019 | BypassRayCast, bRayEndIsIntersection,true,scale, false); | ||
2020 | |||
2021 | // Rez object | ||
2022 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
2023 | item = InventoryService.GetItem(item); | ||
2024 | |||
2025 | if (item != null) | ||
2026 | { | ||
2027 | AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); | ||
2028 | |||
2029 | if (rezAsset != null) | ||
2030 | { | ||
2031 | UUID itemId = UUID.Zero; | ||
2032 | |||
2033 | // If we have permission to copy then link the rezzed object back to the user inventory | ||
2034 | // item that it came from. This allows us to enable 'save object to inventory' | ||
2035 | if (!Permissions.BypassPermissions()) | ||
2036 | { | ||
2037 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) | ||
2038 | { | ||
2039 | itemId = item.ID; | ||
2040 | } | ||
2041 | } | ||
2042 | else | ||
2043 | { | ||
2044 | // Brave new fullperm world | ||
2045 | // | ||
2046 | itemId = item.ID; | ||
2047 | } | ||
2048 | |||
2049 | string xmlData = Utils.BytesToString(rezAsset.Data); | ||
2050 | SceneObjectGroup group | ||
2051 | = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); | ||
2052 | |||
2053 | if (!Permissions.CanRezObject( | ||
2054 | group.Children.Count, remoteClient.AgentId, pos) | ||
2055 | && !attachment) | ||
2056 | { | ||
2057 | // The client operates in no fail mode. It will | ||
2058 | // have already removed the item from the folder | ||
2059 | // if it's no copy. | ||
2060 | // Put it back if it's not an attachment | ||
2061 | // | ||
2062 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) | ||
2063 | remoteClient.SendBulkUpdateInventory(item); | ||
2064 | return null; | ||
2065 | } | ||
2066 | |||
2067 | group.ResetIDs(); | ||
2068 | |||
2069 | if (attachment) | ||
2070 | { | ||
2071 | group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; | ||
2072 | group.RootPart.IsAttachment = true; | ||
2073 | } | ||
2074 | |||
2075 | AddNewSceneObject(group, true); | ||
2076 | |||
2077 | // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); | ||
2078 | // if attachment we set it's asset id so object updates can reflect that | ||
2079 | // if not, we set it's position in world. | ||
2080 | if (!attachment) | ||
2081 | { | ||
2082 | float offsetHeight = 0; | ||
2083 | pos = GetNewRezLocation( | ||
2084 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | ||
2085 | BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false); | ||
2086 | pos.Z += offsetHeight; | ||
2087 | group.AbsolutePosition = pos; | ||
2088 | // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight); | ||
2089 | |||
2090 | } | ||
2091 | else | ||
2092 | { | ||
2093 | group.SetFromItemID(itemID); | ||
2094 | } | ||
2095 | |||
2096 | SceneObjectPart rootPart = null; | ||
2097 | try | ||
2098 | { | ||
2099 | rootPart = group.GetChildPart(group.UUID); | ||
2100 | } | ||
2101 | catch (NullReferenceException) | ||
2102 | { | ||
2103 | string isAttachment = ""; | ||
2104 | |||
2105 | if (attachment) | ||
2106 | isAttachment = " Object was an attachment"; | ||
2107 | |||
2108 | m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); | ||
2109 | } | ||
2110 | |||
2111 | // Since renaming the item in the inventory does not affect the name stored | ||
2112 | // in the serialization, transfer the correct name from the inventory to the | ||
2113 | // object itself before we rez. | ||
2114 | rootPart.Name = item.Name; | ||
2115 | rootPart.Description = item.Description; | ||
2116 | |||
2117 | List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); | ||
2118 | |||
2119 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | ||
2120 | if (rootPart.OwnerID != item.Owner) | ||
2121 | { | ||
2122 | //Need to kill the for sale here | ||
2123 | rootPart.ObjectSaleType = 0; | ||
2124 | rootPart.SalePrice = 10; | ||
2125 | |||
2126 | if (Permissions.PropagatePermissions()) | ||
2127 | { | ||
2128 | if ((item.CurrentPermissions & 8) != 0) | ||
2129 | { | ||
2130 | foreach (SceneObjectPart part in partList) | ||
2131 | { | ||
2132 | part.EveryoneMask = item.EveryOnePermissions; | ||
2133 | part.NextOwnerMask = item.NextPermissions; | ||
2134 | part.GroupMask = 0; // DO NOT propagate here | ||
2135 | } | ||
2136 | } | ||
2137 | group.ApplyNextOwnerPermissions(); | ||
2138 | } | ||
2139 | } | ||
2140 | |||
2141 | foreach (SceneObjectPart part in partList) | ||
2142 | { | ||
2143 | if (part.OwnerID != item.Owner) | ||
2144 | { | ||
2145 | part.LastOwnerID = part.OwnerID; | ||
2146 | part.OwnerID = item.Owner; | ||
2147 | part.Inventory.ChangeInventoryOwner(item.Owner); | ||
2148 | } | ||
2149 | else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam! | ||
2150 | { | ||
2151 | part.EveryoneMask = item.EveryOnePermissions; | ||
2152 | part.NextOwnerMask = item.NextPermissions; | ||
2153 | |||
2154 | part.GroupMask = 0; // DO NOT propagate here | ||
2155 | } | ||
2156 | } | ||
2157 | |||
2158 | rootPart.TrimPermissions(); | ||
2159 | |||
2160 | if (!attachment) | ||
2161 | { | ||
2162 | if (group.RootPart.Shape.PCode == (byte)PCode.Prim) | ||
2163 | { | ||
2164 | group.ClearPartAttachmentData(); | ||
2165 | } | ||
2166 | } | ||
2167 | |||
2168 | if (!attachment) | ||
2169 | { | ||
2170 | // Fire on_rez | ||
2171 | group.CreateScriptInstances(0, true, DefaultScriptEngine, 0); | ||
2172 | |||
2173 | rootPart.ScheduleFullUpdate(); | ||
2174 | } | ||
2175 | |||
2176 | if (!Permissions.BypassPermissions()) | ||
2177 | { | ||
2178 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
2179 | { | ||
2180 | // If this is done on attachments, no | ||
2181 | // copy ones will be lost, so avoid it | ||
2182 | // | ||
2183 | if (!attachment) | ||
2184 | { | ||
2185 | List<UUID> uuids = new List<UUID>(); | ||
2186 | uuids.Add(item.ID); | ||
2187 | InventoryService.DeleteItems(item.Owner, uuids); | ||
2188 | } | ||
2189 | } | ||
2190 | } | ||
2191 | |||
2192 | return rootPart.ParentGroup; | ||
2193 | } | ||
2194 | } | ||
2195 | |||
2196 | return null; | ||
2197 | } | 1702 | } |
2198 | 1703 | ||
2199 | /// <summary> | 1704 | /// <summary> |
@@ -2417,7 +1922,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2417 | // XXYY!! | 1922 | // XXYY!! |
2418 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 1923 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
2419 | item = InventoryService.GetItem(item); | 1924 | item = InventoryService.GetItem(item); |
2420 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); | 1925 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); |
2421 | 1926 | ||
2422 | if (m_AvatarFactory != null) | 1927 | if (m_AvatarFactory != null) |
2423 | { | 1928 | { |