diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 252 |
1 files changed, 146 insertions, 106 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e2d96d9..7fa5509 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; |
@@ -698,6 +680,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
698 | return; | 680 | return; |
699 | } | 681 | } |
700 | 682 | ||
683 | if (newName == null) newName = item.Name; | ||
684 | |||
701 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 685 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
702 | 686 | ||
703 | if (asset != null) | 687 | if (asset != null) |
@@ -751,6 +735,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
751 | } | 735 | } |
752 | 736 | ||
753 | /// <summary> | 737 | /// <summary> |
738 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
739 | /// </summary> | ||
740 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
741 | { | ||
742 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
743 | foreach (InventoryItemBase b in items) | ||
744 | { | ||
745 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
746 | InventoryItemBase n = InventoryService.GetItem(b); | ||
747 | n.Folder = destfolder; | ||
748 | moveitems.Add(n); | ||
749 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
750 | } | ||
751 | |||
752 | MoveInventoryItem(remoteClient, moveitems); | ||
753 | } | ||
754 | |||
755 | /// <summary> | ||
754 | /// Move an item within the agent's inventory. | 756 | /// Move an item within the agent's inventory. |
755 | /// </summary> | 757 | /// </summary> |
756 | /// <param name="remoteClient"></param> | 758 | /// <param name="remoteClient"></param> |
@@ -983,8 +985,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
983 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 985 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
984 | { | 986 | { |
985 | SceneObjectPart part = GetSceneObjectPart(localID); | 987 | SceneObjectPart part = GetSceneObjectPart(localID); |
986 | SceneObjectGroup group = part.ParentGroup; | 988 | SceneObjectGroup group = null; |
987 | if (group != null) | 989 | if (part != null) |
990 | { | ||
991 | group = part.ParentGroup; | ||
992 | } | ||
993 | if (part != null && group != null) | ||
988 | { | 994 | { |
989 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | 995 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) |
990 | return; | 996 | return; |
@@ -1433,13 +1439,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1433 | { | 1439 | { |
1434 | agentTransactions.HandleTaskItemUpdateFromTransaction( | 1440 | agentTransactions.HandleTaskItemUpdateFromTransaction( |
1435 | remoteClient, part, transactionID, currentItem); | 1441 | remoteClient, part, transactionID, currentItem); |
1436 | |||
1437 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | ||
1438 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
1439 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | ||
1440 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
1441 | else | ||
1442 | remoteClient.SendAgentAlertMessage("Item saved", false); | ||
1443 | } | 1442 | } |
1444 | 1443 | ||
1445 | // Base ALWAYS has move | 1444 | // Base ALWAYS has move |
@@ -1580,7 +1579,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1580 | return; | 1579 | return; |
1581 | 1580 | ||
1582 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1581 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1583 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1582 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1584 | remoteClient.AgentId); | 1583 | remoteClient.AgentId); |
1585 | AssetService.Store(asset); | 1584 | AssetService.Store(asset); |
1586 | 1585 | ||
@@ -1733,23 +1732,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1733 | // build a list of eligible objects | 1732 | // build a list of eligible objects |
1734 | List<uint> deleteIDs = new List<uint>(); | 1733 | List<uint> deleteIDs = new List<uint>(); |
1735 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 1734 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
1736 | 1735 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
1737 | // Start with true for both, then remove the flags if objects | ||
1738 | // that we can't derez are part of the selection | ||
1739 | bool permissionToTake = true; | ||
1740 | bool permissionToTakeCopy = true; | ||
1741 | bool permissionToDelete = true; | ||
1742 | 1736 | ||
1743 | foreach (uint localID in localIDs) | 1737 | foreach (uint localID in localIDs) |
1744 | { | 1738 | { |
1739 | // Start with true for both, then remove the flags if objects | ||
1740 | // that we can't derez are part of the selection | ||
1741 | bool permissionToTake = true; | ||
1742 | bool permissionToTakeCopy = true; | ||
1743 | bool permissionToDelete = true; | ||
1744 | |||
1745 | // Invalid id | 1745 | // Invalid id |
1746 | SceneObjectPart part = GetSceneObjectPart(localID); | 1746 | SceneObjectPart part = GetSceneObjectPart(localID); |
1747 | if (part == null) | 1747 | if (part == null) |
1748 | { | ||
1749 | //Client still thinks the object exists, kill it | ||
1750 | deleteIDs.Add(localID); | ||
1748 | continue; | 1751 | continue; |
1752 | } | ||
1749 | 1753 | ||
1750 | // Already deleted by someone else | 1754 | // Already deleted by someone else |
1751 | if (part.ParentGroup == null || part.ParentGroup.IsDeleted) | 1755 | if (part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1756 | { | ||
1757 | //Client still thinks the object exists, kill it | ||
1758 | deleteIDs.Add(localID); | ||
1752 | continue; | 1759 | continue; |
1760 | } | ||
1753 | 1761 | ||
1754 | // Can't delete child prims | 1762 | // Can't delete child prims |
1755 | if (part != part.ParentGroup.RootPart) | 1763 | if (part != part.ParentGroup.RootPart) |
@@ -1757,9 +1765,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1757 | 1765 | ||
1758 | SceneObjectGroup grp = part.ParentGroup; | 1766 | SceneObjectGroup grp = part.ParentGroup; |
1759 | 1767 | ||
1760 | deleteIDs.Add(localID); | ||
1761 | deleteGroups.Add(grp); | ||
1762 | |||
1763 | if (remoteClient == null) | 1768 | if (remoteClient == null) |
1764 | { | 1769 | { |
1765 | // Autoreturn has a null client. Nothing else does. So | 1770 | // Autoreturn has a null client. Nothing else does. So |
@@ -1776,80 +1781,104 @@ namespace OpenSim.Region.Framework.Scenes | |||
1776 | } | 1781 | } |
1777 | else | 1782 | else |
1778 | { | 1783 | { |
1779 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 1784 | if (action == DeRezAction.TakeCopy) |
1785 | { | ||
1786 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
1787 | permissionToTakeCopy = false; | ||
1788 | } | ||
1789 | else | ||
1790 | { | ||
1780 | permissionToTakeCopy = false; | 1791 | permissionToTakeCopy = false; |
1781 | 1792 | } | |
1782 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 1793 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1783 | permissionToTake = false; | 1794 | permissionToTake = false; |
1784 | 1795 | ||
1785 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 1796 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
1786 | permissionToDelete = false; | 1797 | permissionToDelete = false; |
1787 | } | 1798 | } |
1788 | } | ||
1789 | 1799 | ||
1790 | // Handle god perms | 1800 | // Handle god perms |
1791 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 1801 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
1792 | { | 1802 | { |
1793 | permissionToTake = true; | 1803 | permissionToTake = true; |
1794 | permissionToTakeCopy = true; | 1804 | permissionToTakeCopy = true; |
1795 | permissionToDelete = true; | 1805 | permissionToDelete = true; |
1796 | } | 1806 | } |
1797 | 1807 | ||
1798 | // If we're re-saving, we don't even want to delete | 1808 | // If we're re-saving, we don't even want to delete |
1799 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | 1809 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
1800 | permissionToDelete = false; | 1810 | permissionToDelete = false; |
1801 | 1811 | ||
1802 | // if we want to take a copy, we also don't want to delete | 1812 | // if we want to take a copy, we also don't want to delete |
1803 | // Note: after this point, the permissionToTakeCopy flag | 1813 | // Note: after this point, the permissionToTakeCopy flag |
1804 | // becomes irrelevant. It already includes the permissionToTake | 1814 | // becomes irrelevant. It already includes the permissionToTake |
1805 | // permission and after excluding no copy items here, we can | 1815 | // permission and after excluding no copy items here, we can |
1806 | // just use that. | 1816 | // just use that. |
1807 | if (action == DeRezAction.TakeCopy) | 1817 | if (action == DeRezAction.TakeCopy) |
1808 | { | 1818 | { |
1809 | // If we don't have permission, stop right here | 1819 | // If we don't have permission, stop right here |
1810 | if (!permissionToTakeCopy) | 1820 | if (!permissionToTakeCopy) |
1811 | return; | 1821 | return; |
1812 | 1822 | ||
1813 | permissionToTake = true; | 1823 | permissionToTake = true; |
1814 | // Don't delete | 1824 | // Don't delete |
1815 | permissionToDelete = false; | 1825 | permissionToDelete = false; |
1816 | } | 1826 | } |
1817 | 1827 | ||
1818 | if (action == DeRezAction.Return) | 1828 | if (action == DeRezAction.Return) |
1819 | { | ||
1820 | if (remoteClient != null) | ||
1821 | { | 1829 | { |
1822 | if (Permissions.CanReturnObjects( | 1830 | if (remoteClient != null) |
1823 | null, | ||
1824 | remoteClient.AgentId, | ||
1825 | deleteGroups)) | ||
1826 | { | 1831 | { |
1827 | permissionToTake = true; | 1832 | if (Permissions.CanReturnObjects( |
1828 | permissionToDelete = true; | 1833 | null, |
1829 | 1834 | remoteClient.AgentId, | |
1830 | foreach (SceneObjectGroup g in deleteGroups) | 1835 | deleteGroups)) |
1831 | { | 1836 | { |
1832 | AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 1837 | permissionToTake = true; |
1838 | permissionToDelete = true; | ||
1839 | |||
1840 | AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
1833 | } | 1841 | } |
1834 | } | 1842 | } |
1843 | else // Auto return passes through here with null agent | ||
1844 | { | ||
1845 | permissionToTake = true; | ||
1846 | permissionToDelete = true; | ||
1847 | } | ||
1835 | } | 1848 | } |
1836 | else // Auto return passes through here with null agent | 1849 | |
1850 | if (permissionToTake && (!permissionToDelete)) | ||
1851 | takeGroups.Add(grp); | ||
1852 | |||
1853 | if (permissionToDelete) | ||
1837 | { | 1854 | { |
1838 | permissionToTake = true; | 1855 | if (permissionToTake) |
1839 | permissionToDelete = true; | 1856 | deleteGroups.Add(grp); |
1857 | deleteIDs.Add(grp.LocalId); | ||
1840 | } | 1858 | } |
1841 | } | 1859 | } |
1842 | 1860 | ||
1843 | if (permissionToTake) | 1861 | SendKillObject(deleteIDs); |
1862 | |||
1863 | if (deleteGroups.Count > 0) | ||
1844 | { | 1864 | { |
1865 | foreach (SceneObjectGroup g in deleteGroups) | ||
1866 | deleteIDs.Remove(g.LocalId); | ||
1867 | |||
1845 | m_asyncSceneObjectDeleter.DeleteToInventory( | 1868 | m_asyncSceneObjectDeleter.DeleteToInventory( |
1846 | action, destinationID, deleteGroups, remoteClient, | 1869 | action, destinationID, deleteGroups, remoteClient, |
1847 | permissionToDelete); | 1870 | true); |
1871 | } | ||
1872 | if (takeGroups.Count > 0) | ||
1873 | { | ||
1874 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
1875 | action, destinationID, takeGroups, remoteClient, | ||
1876 | false); | ||
1848 | } | 1877 | } |
1849 | else if (permissionToDelete) | 1878 | if (deleteIDs.Count > 0) |
1850 | { | 1879 | { |
1851 | foreach (SceneObjectGroup g in deleteGroups) | 1880 | foreach (SceneObjectGroup g in deleteGroups) |
1852 | DeleteSceneObject(g, false); | 1881 | DeleteSceneObject(g, true); |
1853 | } | 1882 | } |
1854 | } | 1883 | } |
1855 | 1884 | ||
@@ -1901,21 +1930,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1901 | else // oopsies | 1930 | else // oopsies |
1902 | item.Folder = UUID.Zero; | 1931 | item.Folder = UUID.Zero; |
1903 | 1932 | ||
1933 | // Set up base perms properly | ||
1934 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
1935 | permsBase &= grp.RootPart.BaseMask; | ||
1936 | permsBase |= (uint)PermissionMask.Move; | ||
1937 | |||
1938 | // Make sure we don't lock it | ||
1939 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
1940 | |||
1904 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | 1941 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) |
1905 | { | 1942 | { |
1906 | item.BasePermissions = grp.RootPart.NextOwnerMask; | 1943 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; |
1907 | item.CurrentPermissions = grp.RootPart.NextOwnerMask; | 1944 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; |
1908 | item.NextPermissions = grp.RootPart.NextOwnerMask; | 1945 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; |
1909 | item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | 1946 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; |
1910 | item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | 1947 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; |
1911 | } | 1948 | } |
1912 | else | 1949 | else |
1913 | { | 1950 | { |
1914 | item.BasePermissions = grp.RootPart.BaseMask; | 1951 | item.BasePermissions = permsBase; |
1915 | item.CurrentPermissions = grp.RootPart.OwnerMask; | 1952 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; |
1916 | item.NextPermissions = grp.RootPart.NextOwnerMask; | 1953 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; |
1917 | item.EveryOnePermissions = grp.RootPart.EveryoneMask; | 1954 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; |
1918 | item.GroupPermissions = grp.RootPart.GroupMask; | 1955 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; |
1919 | } | 1956 | } |
1920 | item.CreationDate = Util.UnixTimeSinceEpoch(); | 1957 | item.CreationDate = Util.UnixTimeSinceEpoch(); |
1921 | 1958 | ||
@@ -2021,6 +2058,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2021 | 2058 | ||
2022 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2059 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2023 | { | 2060 | { |
2061 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2062 | return; | ||
2063 | |||
2024 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2064 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2025 | if (part == null) | 2065 | if (part == null) |
2026 | return; | 2066 | return; |