diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 221 |
1 files changed, 125 insertions, 96 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 06f8ac1..e6201a8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -99,34 +99,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
99 | /// <param name="item"></param> | 99 | /// <param name="item"></param> |
100 | public bool AddInventoryItem(InventoryItemBase item) | 100 | public bool AddInventoryItem(InventoryItemBase item) |
101 | { | 101 | { |
102 | if (UUID.Zero == item.Folder) | 102 | InventoryFolderBase folder; |
103 | |||
104 | if (item.Folder == UUID.Zero) | ||
103 | { | 105 | { |
104 | InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); | 106 | folder = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); |
105 | if (f != null) | 107 | if (folder == null) |
106 | { | ||
107 | // m_log.DebugFormat( | ||
108 | // "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}", | ||
109 | // f.Name, (AssetType)f.Type, item.Name); | ||
110 | |||
111 | item.Folder = f.ID; | ||
112 | } | ||
113 | else | ||
114 | { | 108 | { |
115 | f = InventoryService.GetRootFolder(item.Owner); | 109 | folder = InventoryService.GetRootFolder(item.Owner); |
116 | if (f != null) | 110 | |
117 | { | 111 | if (folder == null) |
118 | item.Folder = f.ID; | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | m_log.WarnFormat( | ||
123 | "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", | ||
124 | item.Owner, item.Name); | ||
125 | return false; | 112 | return false; |
126 | } | ||
127 | } | 113 | } |
114 | |||
115 | item.Folder = folder.ID; | ||
128 | } | 116 | } |
129 | 117 | ||
130 | if (InventoryService.AddItem(item)) | 118 | if (InventoryService.AddItem(item)) |
131 | { | 119 | { |
132 | int userlevel = 0; | 120 | int userlevel = 0; |
@@ -252,8 +240,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
252 | 240 | ||
253 | // Update item with new asset | 241 | // Update item with new asset |
254 | item.AssetID = asset.FullID; | 242 | item.AssetID = asset.FullID; |
255 | if (group.UpdateInventoryItem(item)) | 243 | group.UpdateInventoryItem(item); |
256 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
257 | 244 | ||
258 | part.GetProperties(remoteClient); | 245 | part.GetProperties(remoteClient); |
259 | 246 | ||
@@ -264,12 +251,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
264 | { | 251 | { |
265 | // Needs to determine which engine was running it and use that | 252 | // Needs to determine which engine was running it and use that |
266 | // | 253 | // |
267 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 254 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0); |
268 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
269 | } | ||
270 | else | ||
271 | { | ||
272 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
273 | } | 255 | } |
274 | part.ParentGroup.ResumeScripts(); | 256 | part.ParentGroup.ResumeScripts(); |
275 | return errors; | 257 | return errors; |
@@ -684,6 +666,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
684 | return; | 666 | return; |
685 | } | 667 | } |
686 | 668 | ||
669 | if (newName == null) newName = item.Name; | ||
670 | |||
687 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 671 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
688 | 672 | ||
689 | if (asset != null) | 673 | if (asset != null) |
@@ -731,6 +715,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
731 | } | 715 | } |
732 | 716 | ||
733 | /// <summary> | 717 | /// <summary> |
718 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
719 | /// </summary> | ||
720 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
721 | { | ||
722 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
723 | foreach (InventoryItemBase b in items) | ||
724 | { | ||
725 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
726 | InventoryItemBase n = InventoryService.GetItem(b); | ||
727 | n.Folder = destfolder; | ||
728 | moveitems.Add(n); | ||
729 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
730 | } | ||
731 | |||
732 | MoveInventoryItem(remoteClient, moveitems); | ||
733 | } | ||
734 | |||
735 | /// <summary> | ||
734 | /// Move an item within the agent's inventory. | 736 | /// Move an item within the agent's inventory. |
735 | /// </summary> | 737 | /// </summary> |
736 | /// <param name="remoteClient"></param> | 738 | /// <param name="remoteClient"></param> |
@@ -974,8 +976,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
974 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 976 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
975 | { | 977 | { |
976 | SceneObjectPart part = GetSceneObjectPart(localID); | 978 | SceneObjectPart part = GetSceneObjectPart(localID); |
977 | SceneObjectGroup group = part.ParentGroup; | 979 | SceneObjectGroup group = null; |
978 | if (group != null) | 980 | if (part != null) |
981 | { | ||
982 | group = part.ParentGroup; | ||
983 | } | ||
984 | if (part != null && group != null) | ||
979 | { | 985 | { |
980 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | 986 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) |
981 | return; | 987 | return; |
@@ -1424,13 +1430,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1424 | { | 1430 | { |
1425 | agentTransactions.HandleTaskItemUpdateFromTransaction( | 1431 | agentTransactions.HandleTaskItemUpdateFromTransaction( |
1426 | remoteClient, part, transactionID, currentItem); | 1432 | remoteClient, part, transactionID, currentItem); |
1427 | |||
1428 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | ||
1429 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
1430 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | ||
1431 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
1432 | else | ||
1433 | remoteClient.SendAgentAlertMessage("Item saved", false); | ||
1434 | } | 1433 | } |
1435 | 1434 | ||
1436 | // Base ALWAYS has move | 1435 | // Base ALWAYS has move |
@@ -1548,7 +1547,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1548 | return; | 1547 | return; |
1549 | 1548 | ||
1550 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1549 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1551 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1550 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1552 | remoteClient.AgentId); | 1551 | remoteClient.AgentId); |
1553 | AssetService.Store(asset); | 1552 | AssetService.Store(asset); |
1554 | 1553 | ||
@@ -1701,23 +1700,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1701 | // build a list of eligible objects | 1700 | // build a list of eligible objects |
1702 | List<uint> deleteIDs = new List<uint>(); | 1701 | List<uint> deleteIDs = new List<uint>(); |
1703 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 1702 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
1704 | 1703 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
1705 | // Start with true for both, then remove the flags if objects | ||
1706 | // that we can't derez are part of the selection | ||
1707 | bool permissionToTake = true; | ||
1708 | bool permissionToTakeCopy = true; | ||
1709 | bool permissionToDelete = true; | ||
1710 | 1704 | ||
1711 | foreach (uint localID in localIDs) | 1705 | foreach (uint localID in localIDs) |
1712 | { | 1706 | { |
1707 | // Start with true for both, then remove the flags if objects | ||
1708 | // that we can't derez are part of the selection | ||
1709 | bool permissionToTake = true; | ||
1710 | bool permissionToTakeCopy = true; | ||
1711 | bool permissionToDelete = true; | ||
1712 | |||
1713 | // Invalid id | 1713 | // Invalid id |
1714 | SceneObjectPart part = GetSceneObjectPart(localID); | 1714 | SceneObjectPart part = GetSceneObjectPart(localID); |
1715 | if (part == null) | 1715 | if (part == null) |
1716 | { | ||
1717 | //Client still thinks the object exists, kill it | ||
1718 | deleteIDs.Add(localID); | ||
1716 | continue; | 1719 | continue; |
1720 | } | ||
1717 | 1721 | ||
1718 | // Already deleted by someone else | 1722 | // Already deleted by someone else |
1719 | if (part.ParentGroup == null || part.ParentGroup.IsDeleted) | 1723 | if (part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1724 | { | ||
1725 | //Client still thinks the object exists, kill it | ||
1726 | deleteIDs.Add(localID); | ||
1720 | continue; | 1727 | continue; |
1728 | } | ||
1721 | 1729 | ||
1722 | // Can't delete child prims | 1730 | // Can't delete child prims |
1723 | if (part != part.ParentGroup.RootPart) | 1731 | if (part != part.ParentGroup.RootPart) |
@@ -1725,9 +1733,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1725 | 1733 | ||
1726 | SceneObjectGroup grp = part.ParentGroup; | 1734 | SceneObjectGroup grp = part.ParentGroup; |
1727 | 1735 | ||
1728 | deleteIDs.Add(localID); | ||
1729 | deleteGroups.Add(grp); | ||
1730 | |||
1731 | if (remoteClient == null) | 1736 | if (remoteClient == null) |
1732 | { | 1737 | { |
1733 | // Autoreturn has a null client. Nothing else does. So | 1738 | // Autoreturn has a null client. Nothing else does. So |
@@ -1744,80 +1749,104 @@ namespace OpenSim.Region.Framework.Scenes | |||
1744 | } | 1749 | } |
1745 | else | 1750 | else |
1746 | { | 1751 | { |
1747 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 1752 | if (action == DeRezAction.TakeCopy) |
1753 | { | ||
1754 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
1755 | permissionToTakeCopy = false; | ||
1756 | } | ||
1757 | else | ||
1758 | { | ||
1748 | permissionToTakeCopy = false; | 1759 | permissionToTakeCopy = false; |
1749 | 1760 | } | |
1750 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 1761 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1751 | permissionToTake = false; | 1762 | permissionToTake = false; |
1752 | 1763 | ||
1753 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 1764 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
1754 | permissionToDelete = false; | 1765 | permissionToDelete = false; |
1755 | } | 1766 | } |
1756 | } | ||
1757 | 1767 | ||
1758 | // Handle god perms | 1768 | // Handle god perms |
1759 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 1769 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
1760 | { | 1770 | { |
1761 | permissionToTake = true; | 1771 | permissionToTake = true; |
1762 | permissionToTakeCopy = true; | 1772 | permissionToTakeCopy = true; |
1763 | permissionToDelete = true; | 1773 | permissionToDelete = true; |
1764 | } | 1774 | } |
1765 | 1775 | ||
1766 | // If we're re-saving, we don't even want to delete | 1776 | // If we're re-saving, we don't even want to delete |
1767 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | 1777 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
1768 | permissionToDelete = false; | 1778 | permissionToDelete = false; |
1769 | 1779 | ||
1770 | // if we want to take a copy, we also don't want to delete | 1780 | // if we want to take a copy, we also don't want to delete |
1771 | // Note: after this point, the permissionToTakeCopy flag | 1781 | // Note: after this point, the permissionToTakeCopy flag |
1772 | // becomes irrelevant. It already includes the permissionToTake | 1782 | // becomes irrelevant. It already includes the permissionToTake |
1773 | // permission and after excluding no copy items here, we can | 1783 | // permission and after excluding no copy items here, we can |
1774 | // just use that. | 1784 | // just use that. |
1775 | if (action == DeRezAction.TakeCopy) | 1785 | if (action == DeRezAction.TakeCopy) |
1776 | { | 1786 | { |
1777 | // If we don't have permission, stop right here | 1787 | // If we don't have permission, stop right here |
1778 | if (!permissionToTakeCopy) | 1788 | if (!permissionToTakeCopy) |
1779 | return; | 1789 | return; |
1780 | 1790 | ||
1781 | permissionToTake = true; | 1791 | permissionToTake = true; |
1782 | // Don't delete | 1792 | // Don't delete |
1783 | permissionToDelete = false; | 1793 | permissionToDelete = false; |
1784 | } | 1794 | } |
1785 | 1795 | ||
1786 | if (action == DeRezAction.Return) | 1796 | if (action == DeRezAction.Return) |
1787 | { | ||
1788 | if (remoteClient != null) | ||
1789 | { | 1797 | { |
1790 | if (Permissions.CanReturnObjects( | 1798 | if (remoteClient != null) |
1791 | null, | ||
1792 | remoteClient.AgentId, | ||
1793 | deleteGroups)) | ||
1794 | { | 1799 | { |
1795 | permissionToTake = true; | 1800 | if (Permissions.CanReturnObjects( |
1796 | permissionToDelete = true; | 1801 | null, |
1797 | 1802 | remoteClient.AgentId, | |
1798 | foreach (SceneObjectGroup g in deleteGroups) | 1803 | deleteGroups)) |
1799 | { | 1804 | { |
1800 | AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 1805 | permissionToTake = true; |
1806 | permissionToDelete = true; | ||
1807 | |||
1808 | AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
1801 | } | 1809 | } |
1802 | } | 1810 | } |
1811 | else // Auto return passes through here with null agent | ||
1812 | { | ||
1813 | permissionToTake = true; | ||
1814 | permissionToDelete = true; | ||
1815 | } | ||
1803 | } | 1816 | } |
1804 | else // Auto return passes through here with null agent | 1817 | |
1818 | if (permissionToTake && (!permissionToDelete)) | ||
1819 | takeGroups.Add(grp); | ||
1820 | |||
1821 | if (permissionToDelete) | ||
1805 | { | 1822 | { |
1806 | permissionToTake = true; | 1823 | if (permissionToTake) |
1807 | permissionToDelete = true; | 1824 | deleteGroups.Add(grp); |
1825 | deleteIDs.Add(grp.LocalId); | ||
1808 | } | 1826 | } |
1809 | } | 1827 | } |
1810 | 1828 | ||
1811 | if (permissionToTake) | 1829 | SendKillObject(deleteIDs); |
1830 | |||
1831 | if (deleteGroups.Count > 0) | ||
1812 | { | 1832 | { |
1833 | foreach (SceneObjectGroup g in deleteGroups) | ||
1834 | deleteIDs.Remove(g.LocalId); | ||
1835 | |||
1813 | m_asyncSceneObjectDeleter.DeleteToInventory( | 1836 | m_asyncSceneObjectDeleter.DeleteToInventory( |
1814 | action, destinationID, deleteGroups, remoteClient, | 1837 | action, destinationID, deleteGroups, remoteClient, |
1815 | permissionToDelete); | 1838 | true); |
1839 | } | ||
1840 | if (takeGroups.Count > 0) | ||
1841 | { | ||
1842 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
1843 | action, destinationID, takeGroups, remoteClient, | ||
1844 | false); | ||
1816 | } | 1845 | } |
1817 | else if (permissionToDelete) | 1846 | if (deleteIDs.Count > 0) |
1818 | { | 1847 | { |
1819 | foreach (SceneObjectGroup g in deleteGroups) | 1848 | foreach (SceneObjectGroup g in deleteGroups) |
1820 | DeleteSceneObject(g, false); | 1849 | DeleteSceneObject(g, true); |
1821 | } | 1850 | } |
1822 | } | 1851 | } |
1823 | 1852 | ||