diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 355 |
1 files changed, 244 insertions, 111 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b62023b..83990b1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -117,34 +117,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
117 | /// <param name="item"></param> | 117 | /// <param name="item"></param> |
118 | public bool AddInventoryItem(InventoryItemBase item) | 118 | public bool AddInventoryItem(InventoryItemBase item) |
119 | { | 119 | { |
120 | if (UUID.Zero == item.Folder) | 120 | InventoryFolderBase folder; |
121 | |||
122 | if (item.Folder == UUID.Zero) | ||
121 | { | 123 | { |
122 | InventoryFolderBase f = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); | 124 | folder = InventoryService.GetFolderForType(item.Owner, (AssetType)item.AssetType); |
123 | if (f != null) | 125 | if (folder == null) |
124 | { | 126 | { |
125 | // m_log.DebugFormat( | 127 | folder = InventoryService.GetRootFolder(item.Owner); |
126 | // "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}", | 128 | |
127 | // f.Name, (AssetType)f.Type, item.Name); | 129 | if (folder == null) |
128 | |||
129 | item.Folder = f.ID; | ||
130 | } | ||
131 | else | ||
132 | { | ||
133 | f = InventoryService.GetRootFolder(item.Owner); | ||
134 | if (f != null) | ||
135 | { | ||
136 | item.Folder = f.ID; | ||
137 | } | ||
138 | else | ||
139 | { | ||
140 | m_log.WarnFormat( | ||
141 | "[AGENT INVENTORY]: Could not find root folder for {0} when trying to add item {1} with no parent folder specified", | ||
142 | item.Owner, item.Name); | ||
143 | return false; | 130 | return false; |
144 | } | ||
145 | } | 131 | } |
132 | |||
133 | item.Folder = folder.ID; | ||
146 | } | 134 | } |
147 | 135 | ||
148 | if (InventoryService.AddItem(item)) | 136 | if (InventoryService.AddItem(item)) |
149 | { | 137 | { |
150 | int userlevel = 0; | 138 | int userlevel = 0; |
@@ -264,8 +252,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
264 | 252 | ||
265 | // Update item with new asset | 253 | // Update item with new asset |
266 | item.AssetID = asset.FullID; | 254 | item.AssetID = asset.FullID; |
267 | if (group.UpdateInventoryItem(item)) | 255 | group.UpdateInventoryItem(item); |
268 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
269 | 256 | ||
270 | part.SendPropertiesToClient(remoteClient); | 257 | part.SendPropertiesToClient(remoteClient); |
271 | 258 | ||
@@ -276,12 +263,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
276 | { | 263 | { |
277 | // Needs to determine which engine was running it and use that | 264 | // Needs to determine which engine was running it and use that |
278 | // | 265 | // |
279 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 266 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0); |
280 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
281 | } | ||
282 | else | ||
283 | { | ||
284 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
285 | } | 267 | } |
286 | part.ParentGroup.ResumeScripts(); | 268 | part.ParentGroup.ResumeScripts(); |
287 | return errors; | 269 | return errors; |
@@ -345,6 +327,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
345 | 327 | ||
346 | if (UUID.Zero == transactionID) | 328 | if (UUID.Zero == transactionID) |
347 | { | 329 | { |
330 | item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); | ||
348 | item.Name = itemUpd.Name; | 331 | item.Name = itemUpd.Name; |
349 | item.Description = itemUpd.Description; | 332 | item.Description = itemUpd.Description; |
350 | if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) | 333 | if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) |
@@ -723,6 +706,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
723 | return; | 706 | return; |
724 | } | 707 | } |
725 | 708 | ||
709 | if (newName == null) newName = item.Name; | ||
710 | |||
726 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 711 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
727 | 712 | ||
728 | if (asset != null) | 713 | if (asset != null) |
@@ -779,6 +764,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
779 | } | 764 | } |
780 | 765 | ||
781 | /// <summary> | 766 | /// <summary> |
767 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
768 | /// </summary> | ||
769 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
770 | { | ||
771 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
772 | foreach (InventoryItemBase b in items) | ||
773 | { | ||
774 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
775 | InventoryItemBase n = InventoryService.GetItem(b); | ||
776 | n.Folder = destfolder; | ||
777 | moveitems.Add(n); | ||
778 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
779 | } | ||
780 | |||
781 | MoveInventoryItem(remoteClient, moveitems); | ||
782 | } | ||
783 | |||
784 | /// <summary> | ||
782 | /// Move an item within the agent's inventory. | 785 | /// Move an item within the agent's inventory. |
783 | /// </summary> | 786 | /// </summary> |
784 | /// <param name="remoteClient"></param> | 787 | /// <param name="remoteClient"></param> |
@@ -979,25 +982,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
979 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 982 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
980 | { | 983 | { |
981 | SceneObjectPart part = GetSceneObjectPart(localID); | 984 | SceneObjectPart part = GetSceneObjectPart(localID); |
982 | if (part == null) | 985 | SceneObjectGroup group = null; |
983 | return; | 986 | if (part != null) |
987 | { | ||
988 | group = part.ParentGroup; | ||
989 | } | ||
990 | if (part != null && group != null) | ||
991 | { | ||
992 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | ||
993 | return; | ||
984 | 994 | ||
985 | SceneObjectGroup group = part.ParentGroup; | 995 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); |
986 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | 996 | if (item == null) |
987 | return; | 997 | return; |
988 | |||
989 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); | ||
990 | if (item == null) | ||
991 | return; | ||
992 | 998 | ||
993 | if (item.Type == 10) | 999 | if (item.Type == 10) |
994 | { | 1000 | { |
995 | part.RemoveScriptEvents(itemID); | 1001 | part.RemoveScriptEvents(itemID); |
996 | EventManager.TriggerRemoveScript(localID, itemID); | 1002 | EventManager.TriggerRemoveScript(localID, itemID); |
1003 | } | ||
1004 | |||
1005 | group.RemoveInventoryItem(localID, itemID); | ||
1006 | part.SendPropertiesToClient(remoteClient); | ||
997 | } | 1007 | } |
998 | |||
999 | group.RemoveInventoryItem(localID, itemID); | ||
1000 | part.SendPropertiesToClient(remoteClient); | ||
1001 | } | 1008 | } |
1002 | 1009 | ||
1003 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) | 1010 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) |
@@ -1208,6 +1215,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1208 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) | 1215 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) |
1209 | return; | 1216 | return; |
1210 | 1217 | ||
1218 | bool overrideNoMod = false; | ||
1219 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1220 | overrideNoMod = true; | ||
1221 | |||
1211 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | 1222 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) |
1212 | { | 1223 | { |
1213 | // object cannot copy items to an object owned by a different owner | 1224 | // object cannot copy items to an object owned by a different owner |
@@ -1217,7 +1228,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1217 | } | 1228 | } |
1218 | 1229 | ||
1219 | // must have both move and modify permission to put an item in an object | 1230 | // must have both move and modify permission to put an item in an object |
1220 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1231 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1221 | { | 1232 | { |
1222 | return; | 1233 | return; |
1223 | } | 1234 | } |
@@ -1276,6 +1287,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1276 | 1287 | ||
1277 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1288 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1278 | { | 1289 | { |
1290 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1291 | if (destPart != null) // Move into a prim | ||
1292 | { | ||
1293 | foreach(UUID itemID in items) | ||
1294 | MoveTaskInventoryItem(destID, host, itemID); | ||
1295 | return destID; // Prim folder ID == prim ID | ||
1296 | } | ||
1297 | |||
1279 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1298 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1280 | 1299 | ||
1281 | UUID newFolderID = UUID.Random(); | 1300 | UUID newFolderID = UUID.Random(); |
@@ -1455,13 +1474,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1455 | { | 1474 | { |
1456 | agentTransactions.HandleTaskItemUpdateFromTransaction( | 1475 | agentTransactions.HandleTaskItemUpdateFromTransaction( |
1457 | remoteClient, part, transactionID, currentItem); | 1476 | remoteClient, part, transactionID, currentItem); |
1458 | |||
1459 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | ||
1460 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
1461 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | ||
1462 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
1463 | else | ||
1464 | remoteClient.SendAgentAlertMessage("Item saved", false); | ||
1465 | } | 1477 | } |
1466 | 1478 | ||
1467 | // Base ALWAYS has move | 1479 | // Base ALWAYS has move |
@@ -1602,7 +1614,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1602 | return; | 1614 | return; |
1603 | 1615 | ||
1604 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1616 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1605 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1617 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1606 | remoteClient.AgentId); | 1618 | remoteClient.AgentId); |
1607 | AssetService.Store(asset); | 1619 | AssetService.Store(asset); |
1608 | 1620 | ||
@@ -1755,23 +1767,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1755 | // build a list of eligible objects | 1767 | // build a list of eligible objects |
1756 | List<uint> deleteIDs = new List<uint>(); | 1768 | List<uint> deleteIDs = new List<uint>(); |
1757 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 1769 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
1758 | 1770 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
1759 | // Start with true for both, then remove the flags if objects | ||
1760 | // that we can't derez are part of the selection | ||
1761 | bool permissionToTake = true; | ||
1762 | bool permissionToTakeCopy = true; | ||
1763 | bool permissionToDelete = true; | ||
1764 | 1771 | ||
1765 | foreach (uint localID in localIDs) | 1772 | foreach (uint localID in localIDs) |
1766 | { | 1773 | { |
1774 | // Start with true for both, then remove the flags if objects | ||
1775 | // that we can't derez are part of the selection | ||
1776 | bool permissionToTake = true; | ||
1777 | bool permissionToTakeCopy = true; | ||
1778 | bool permissionToDelete = true; | ||
1779 | |||
1767 | // Invalid id | 1780 | // Invalid id |
1768 | SceneObjectPart part = GetSceneObjectPart(localID); | 1781 | SceneObjectPart part = GetSceneObjectPart(localID); |
1769 | if (part == null) | 1782 | if (part == null) |
1783 | { | ||
1784 | //Client still thinks the object exists, kill it | ||
1785 | deleteIDs.Add(localID); | ||
1770 | continue; | 1786 | continue; |
1787 | } | ||
1771 | 1788 | ||
1772 | // Already deleted by someone else | 1789 | // Already deleted by someone else |
1773 | if (part.ParentGroup.IsDeleted) | 1790 | if (part.ParentGroup.IsDeleted) |
1791 | { | ||
1792 | //Client still thinks the object exists, kill it | ||
1793 | deleteIDs.Add(localID); | ||
1774 | continue; | 1794 | continue; |
1795 | } | ||
1775 | 1796 | ||
1776 | // Can't delete child prims | 1797 | // Can't delete child prims |
1777 | if (part != part.ParentGroup.RootPart) | 1798 | if (part != part.ParentGroup.RootPart) |
@@ -1779,9 +1800,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1779 | 1800 | ||
1780 | SceneObjectGroup grp = part.ParentGroup; | 1801 | SceneObjectGroup grp = part.ParentGroup; |
1781 | 1802 | ||
1782 | deleteIDs.Add(localID); | ||
1783 | deleteGroups.Add(grp); | ||
1784 | |||
1785 | if (remoteClient == null) | 1803 | if (remoteClient == null) |
1786 | { | 1804 | { |
1787 | // Autoreturn has a null client. Nothing else does. So | 1805 | // Autoreturn has a null client. Nothing else does. So |
@@ -1798,81 +1816,193 @@ namespace OpenSim.Region.Framework.Scenes | |||
1798 | } | 1816 | } |
1799 | else | 1817 | else |
1800 | { | 1818 | { |
1801 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 1819 | if (action == DeRezAction.TakeCopy) |
1820 | { | ||
1821 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
1822 | permissionToTakeCopy = false; | ||
1823 | } | ||
1824 | else | ||
1825 | { | ||
1802 | permissionToTakeCopy = false; | 1826 | permissionToTakeCopy = false; |
1803 | 1827 | } | |
1804 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 1828 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1805 | permissionToTake = false; | 1829 | permissionToTake = false; |
1806 | 1830 | ||
1807 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 1831 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
1808 | permissionToDelete = false; | 1832 | permissionToDelete = false; |
1809 | } | 1833 | } |
1810 | } | ||
1811 | 1834 | ||
1812 | // Handle god perms | 1835 | // Handle god perms |
1813 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 1836 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
1814 | { | 1837 | { |
1815 | permissionToTake = true; | 1838 | permissionToTake = true; |
1816 | permissionToTakeCopy = true; | 1839 | permissionToTakeCopy = true; |
1817 | permissionToDelete = true; | 1840 | permissionToDelete = true; |
1818 | } | 1841 | } |
1819 | 1842 | ||
1820 | // If we're re-saving, we don't even want to delete | 1843 | // If we're re-saving, we don't even want to delete |
1821 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | 1844 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
1822 | permissionToDelete = false; | 1845 | permissionToDelete = false; |
1823 | 1846 | ||
1824 | // if we want to take a copy, we also don't want to delete | 1847 | // if we want to take a copy, we also don't want to delete |
1825 | // Note: after this point, the permissionToTakeCopy flag | 1848 | // Note: after this point, the permissionToTakeCopy flag |
1826 | // becomes irrelevant. It already includes the permissionToTake | 1849 | // becomes irrelevant. It already includes the permissionToTake |
1827 | // permission and after excluding no copy items here, we can | 1850 | // permission and after excluding no copy items here, we can |
1828 | // just use that. | 1851 | // just use that. |
1829 | if (action == DeRezAction.TakeCopy) | 1852 | if (action == DeRezAction.TakeCopy) |
1830 | { | 1853 | { |
1831 | // If we don't have permission, stop right here | 1854 | // If we don't have permission, stop right here |
1832 | if (!permissionToTakeCopy) | 1855 | if (!permissionToTakeCopy) |
1833 | return; | 1856 | return; |
1834 | 1857 | ||
1835 | permissionToTake = true; | 1858 | permissionToTake = true; |
1836 | // Don't delete | 1859 | // Don't delete |
1837 | permissionToDelete = false; | 1860 | permissionToDelete = false; |
1838 | } | 1861 | } |
1839 | 1862 | ||
1840 | if (action == DeRezAction.Return) | 1863 | if (action == DeRezAction.Return) |
1841 | { | ||
1842 | if (remoteClient != null) | ||
1843 | { | 1864 | { |
1844 | if (Permissions.CanReturnObjects( | 1865 | if (remoteClient != null) |
1845 | null, | ||
1846 | remoteClient.AgentId, | ||
1847 | deleteGroups)) | ||
1848 | { | 1866 | { |
1849 | permissionToTake = true; | 1867 | if (Permissions.CanReturnObjects( |
1850 | permissionToDelete = true; | 1868 | null, |
1851 | 1869 | remoteClient.AgentId, | |
1852 | foreach (SceneObjectGroup g in deleteGroups) | 1870 | deleteGroups)) |
1853 | { | 1871 | { |
1854 | AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 1872 | permissionToTake = true; |
1873 | permissionToDelete = true; | ||
1874 | |||
1875 | AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
1855 | } | 1876 | } |
1856 | } | 1877 | } |
1878 | else // Auto return passes through here with null agent | ||
1879 | { | ||
1880 | permissionToTake = true; | ||
1881 | permissionToDelete = true; | ||
1882 | } | ||
1857 | } | 1883 | } |
1858 | else // Auto return passes through here with null agent | 1884 | |
1885 | if (permissionToTake && (!permissionToDelete)) | ||
1886 | takeGroups.Add(grp); | ||
1887 | |||
1888 | if (permissionToDelete) | ||
1859 | { | 1889 | { |
1860 | permissionToTake = true; | 1890 | if (permissionToTake) |
1861 | permissionToDelete = true; | 1891 | deleteGroups.Add(grp); |
1892 | deleteIDs.Add(grp.LocalId); | ||
1862 | } | 1893 | } |
1863 | } | 1894 | } |
1864 | 1895 | ||
1865 | if (permissionToTake) | 1896 | SendKillObject(deleteIDs); |
1897 | |||
1898 | if (deleteGroups.Count > 0) | ||
1866 | { | 1899 | { |
1900 | foreach (SceneObjectGroup g in deleteGroups) | ||
1901 | deleteIDs.Remove(g.LocalId); | ||
1902 | |||
1867 | m_asyncSceneObjectDeleter.DeleteToInventory( | 1903 | m_asyncSceneObjectDeleter.DeleteToInventory( |
1868 | action, destinationID, deleteGroups, remoteClient, | 1904 | action, destinationID, deleteGroups, remoteClient, |
1869 | permissionToDelete); | 1905 | true); |
1870 | } | 1906 | } |
1871 | else if (permissionToDelete) | 1907 | if (takeGroups.Count > 0) |
1908 | { | ||
1909 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
1910 | action, destinationID, takeGroups, remoteClient, | ||
1911 | false); | ||
1912 | } | ||
1913 | if (deleteIDs.Count > 0) | ||
1872 | { | 1914 | { |
1873 | foreach (SceneObjectGroup g in deleteGroups) | 1915 | foreach (SceneObjectGroup g in deleteGroups) |
1874 | DeleteSceneObject(g, false); | 1916 | DeleteSceneObject(g, true); |
1917 | } | ||
1918 | } | ||
1919 | |||
1920 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
1921 | { | ||
1922 | itemID = UUID.Zero; | ||
1923 | if (grp != null) | ||
1924 | { | ||
1925 | Vector3 inventoryStoredPosition = new Vector3 | ||
1926 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1927 | ? 250 | ||
1928 | : grp.AbsolutePosition.X) | ||
1929 | , | ||
1930 | (grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1931 | ? 250 | ||
1932 | : grp.AbsolutePosition.X, | ||
1933 | grp.AbsolutePosition.Z); | ||
1934 | |||
1935 | Vector3 originalPosition = grp.AbsolutePosition; | ||
1936 | |||
1937 | grp.AbsolutePosition = inventoryStoredPosition; | ||
1938 | |||
1939 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
1940 | |||
1941 | grp.AbsolutePosition = originalPosition; | ||
1942 | |||
1943 | AssetBase asset = CreateAsset( | ||
1944 | grp.GetPartName(grp.LocalId), | ||
1945 | grp.GetPartDescription(grp.LocalId), | ||
1946 | (sbyte)AssetType.Object, | ||
1947 | Utils.StringToBytes(sceneObjectXml), | ||
1948 | remoteClient.AgentId); | ||
1949 | AssetService.Store(asset); | ||
1950 | |||
1951 | InventoryItemBase item = new InventoryItemBase(); | ||
1952 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
1953 | item.CreatorData = grp.RootPart.CreatorData; | ||
1954 | item.Owner = remoteClient.AgentId; | ||
1955 | item.ID = UUID.Random(); | ||
1956 | item.AssetID = asset.FullID; | ||
1957 | item.Description = asset.Description; | ||
1958 | item.Name = asset.Name; | ||
1959 | item.AssetType = asset.Type; | ||
1960 | item.InvType = (int)InventoryType.Object; | ||
1961 | |||
1962 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
1963 | if (folder != null) | ||
1964 | item.Folder = folder.ID; | ||
1965 | else // oopsies | ||
1966 | item.Folder = UUID.Zero; | ||
1967 | |||
1968 | // Set up base perms properly | ||
1969 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
1970 | permsBase &= grp.RootPart.BaseMask; | ||
1971 | permsBase |= (uint)PermissionMask.Move; | ||
1972 | |||
1973 | // Make sure we don't lock it | ||
1974 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
1975 | |||
1976 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
1977 | { | ||
1978 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1979 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1980 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1981 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
1982 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
1983 | } | ||
1984 | else | ||
1985 | { | ||
1986 | item.BasePermissions = permsBase; | ||
1987 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
1988 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1989 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
1990 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
1991 | } | ||
1992 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
1993 | |||
1994 | // sets itemID so client can show item as 'attached' in inventory | ||
1995 | grp.SetFromItemID(item.ID); | ||
1996 | |||
1997 | if (AddInventoryItem(item)) | ||
1998 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
1999 | else | ||
2000 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
2001 | |||
2002 | itemID = item.ID; | ||
2003 | return item.AssetID; | ||
1875 | } | 2004 | } |
2005 | return UUID.Zero; | ||
1876 | } | 2006 | } |
1877 | 2007 | ||
1878 | /// <summary> | 2008 | /// <summary> |
@@ -2001,6 +2131,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2001 | 2131 | ||
2002 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2132 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2003 | { | 2133 | { |
2134 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2135 | return; | ||
2136 | |||
2004 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2137 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2005 | if (part == null) | 2138 | if (part == null) |
2006 | return; | 2139 | return; |