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 26eb729..245f258 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; |
@@ -344,6 +326,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
344 | { | 326 | { |
345 | if (UUID.Zero == transactionID) | 327 | if (UUID.Zero == transactionID) |
346 | { | 328 | { |
329 | item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); | ||
347 | item.Name = itemUpd.Name; | 330 | item.Name = itemUpd.Name; |
348 | item.Description = itemUpd.Description; | 331 | item.Description = itemUpd.Description; |
349 | if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) | 332 | if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) |
@@ -721,6 +704,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
721 | return; | 704 | return; |
722 | } | 705 | } |
723 | 706 | ||
707 | if (newName == null) newName = item.Name; | ||
708 | |||
724 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 709 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
725 | 710 | ||
726 | if (asset != null) | 711 | if (asset != null) |
@@ -777,6 +762,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
777 | } | 762 | } |
778 | 763 | ||
779 | /// <summary> | 764 | /// <summary> |
765 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
766 | /// </summary> | ||
767 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
768 | { | ||
769 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
770 | foreach (InventoryItemBase b in items) | ||
771 | { | ||
772 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
773 | InventoryItemBase n = InventoryService.GetItem(b); | ||
774 | n.Folder = destfolder; | ||
775 | moveitems.Add(n); | ||
776 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
777 | } | ||
778 | |||
779 | MoveInventoryItem(remoteClient, moveitems); | ||
780 | } | ||
781 | |||
782 | /// <summary> | ||
780 | /// Move an item within the agent's inventory. | 783 | /// Move an item within the agent's inventory. |
781 | /// </summary> | 784 | /// </summary> |
782 | /// <param name="remoteClient"></param> | 785 | /// <param name="remoteClient"></param> |
@@ -977,25 +980,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
977 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 980 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
978 | { | 981 | { |
979 | SceneObjectPart part = GetSceneObjectPart(localID); | 982 | SceneObjectPart part = GetSceneObjectPart(localID); |
980 | if (part == null) | 983 | SceneObjectGroup group = null; |
981 | return; | 984 | if (part != null) |
985 | { | ||
986 | group = part.ParentGroup; | ||
987 | } | ||
988 | if (part != null && group != null) | ||
989 | { | ||
990 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | ||
991 | return; | ||
982 | 992 | ||
983 | SceneObjectGroup group = part.ParentGroup; | 993 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); |
984 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | 994 | if (item == null) |
985 | return; | 995 | return; |
986 | |||
987 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); | ||
988 | if (item == null) | ||
989 | return; | ||
990 | 996 | ||
991 | if (item.Type == 10) | 997 | if (item.Type == 10) |
992 | { | 998 | { |
993 | part.RemoveScriptEvents(itemID); | 999 | part.RemoveScriptEvents(itemID); |
994 | EventManager.TriggerRemoveScript(localID, itemID); | 1000 | EventManager.TriggerRemoveScript(localID, itemID); |
1001 | } | ||
1002 | |||
1003 | group.RemoveInventoryItem(localID, itemID); | ||
1004 | part.SendPropertiesToClient(remoteClient); | ||
995 | } | 1005 | } |
996 | |||
997 | group.RemoveInventoryItem(localID, itemID); | ||
998 | part.SendPropertiesToClient(remoteClient); | ||
999 | } | 1006 | } |
1000 | 1007 | ||
1001 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) | 1008 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) |
@@ -1206,6 +1213,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1206 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) | 1213 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) |
1207 | return; | 1214 | return; |
1208 | 1215 | ||
1216 | bool overrideNoMod = false; | ||
1217 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1218 | overrideNoMod = true; | ||
1219 | |||
1209 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | 1220 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) |
1210 | { | 1221 | { |
1211 | // object cannot copy items to an object owned by a different owner | 1222 | // object cannot copy items to an object owned by a different owner |
@@ -1215,7 +1226,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1215 | } | 1226 | } |
1216 | 1227 | ||
1217 | // must have both move and modify permission to put an item in an object | 1228 | // must have both move and modify permission to put an item in an object |
1218 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1229 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1219 | { | 1230 | { |
1220 | return; | 1231 | return; |
1221 | } | 1232 | } |
@@ -1274,6 +1285,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1274 | 1285 | ||
1275 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1286 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1276 | { | 1287 | { |
1288 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1289 | if (destPart != null) // Move into a prim | ||
1290 | { | ||
1291 | foreach(UUID itemID in items) | ||
1292 | MoveTaskInventoryItem(destID, host, itemID); | ||
1293 | return destID; // Prim folder ID == prim ID | ||
1294 | } | ||
1295 | |||
1277 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1296 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1278 | 1297 | ||
1279 | UUID newFolderID = UUID.Random(); | 1298 | UUID newFolderID = UUID.Random(); |
@@ -1453,13 +1472,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1453 | { | 1472 | { |
1454 | agentTransactions.HandleTaskItemUpdateFromTransaction( | 1473 | agentTransactions.HandleTaskItemUpdateFromTransaction( |
1455 | remoteClient, part, transactionID, currentItem); | 1474 | remoteClient, part, transactionID, currentItem); |
1456 | |||
1457 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | ||
1458 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
1459 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | ||
1460 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
1461 | else | ||
1462 | remoteClient.SendAgentAlertMessage("Item saved", false); | ||
1463 | } | 1475 | } |
1464 | 1476 | ||
1465 | // Base ALWAYS has move | 1477 | // Base ALWAYS has move |
@@ -1600,7 +1612,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1600 | return; | 1612 | return; |
1601 | 1613 | ||
1602 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1614 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1603 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1615 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1604 | remoteClient.AgentId); | 1616 | remoteClient.AgentId); |
1605 | AssetService.Store(asset); | 1617 | AssetService.Store(asset); |
1606 | 1618 | ||
@@ -1753,23 +1765,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1753 | // build a list of eligible objects | 1765 | // build a list of eligible objects |
1754 | List<uint> deleteIDs = new List<uint>(); | 1766 | List<uint> deleteIDs = new List<uint>(); |
1755 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 1767 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
1756 | 1768 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
1757 | // Start with true for both, then remove the flags if objects | ||
1758 | // that we can't derez are part of the selection | ||
1759 | bool permissionToTake = true; | ||
1760 | bool permissionToTakeCopy = true; | ||
1761 | bool permissionToDelete = true; | ||
1762 | 1769 | ||
1763 | foreach (uint localID in localIDs) | 1770 | foreach (uint localID in localIDs) |
1764 | { | 1771 | { |
1772 | // Start with true for both, then remove the flags if objects | ||
1773 | // that we can't derez are part of the selection | ||
1774 | bool permissionToTake = true; | ||
1775 | bool permissionToTakeCopy = true; | ||
1776 | bool permissionToDelete = true; | ||
1777 | |||
1765 | // Invalid id | 1778 | // Invalid id |
1766 | SceneObjectPart part = GetSceneObjectPart(localID); | 1779 | SceneObjectPart part = GetSceneObjectPart(localID); |
1767 | if (part == null) | 1780 | if (part == null) |
1781 | { | ||
1782 | //Client still thinks the object exists, kill it | ||
1783 | deleteIDs.Add(localID); | ||
1768 | continue; | 1784 | continue; |
1785 | } | ||
1769 | 1786 | ||
1770 | // Already deleted by someone else | 1787 | // Already deleted by someone else |
1771 | if (part.ParentGroup.IsDeleted) | 1788 | if (part.ParentGroup.IsDeleted) |
1789 | { | ||
1790 | //Client still thinks the object exists, kill it | ||
1791 | deleteIDs.Add(localID); | ||
1772 | continue; | 1792 | continue; |
1793 | } | ||
1773 | 1794 | ||
1774 | // Can't delete child prims | 1795 | // Can't delete child prims |
1775 | if (part != part.ParentGroup.RootPart) | 1796 | if (part != part.ParentGroup.RootPart) |
@@ -1777,9 +1798,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1777 | 1798 | ||
1778 | SceneObjectGroup grp = part.ParentGroup; | 1799 | SceneObjectGroup grp = part.ParentGroup; |
1779 | 1800 | ||
1780 | deleteIDs.Add(localID); | ||
1781 | deleteGroups.Add(grp); | ||
1782 | |||
1783 | if (remoteClient == null) | 1801 | if (remoteClient == null) |
1784 | { | 1802 | { |
1785 | // Autoreturn has a null client. Nothing else does. So | 1803 | // Autoreturn has a null client. Nothing else does. So |
@@ -1796,81 +1814,193 @@ namespace OpenSim.Region.Framework.Scenes | |||
1796 | } | 1814 | } |
1797 | else | 1815 | else |
1798 | { | 1816 | { |
1799 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 1817 | if (action == DeRezAction.TakeCopy) |
1818 | { | ||
1819 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
1820 | permissionToTakeCopy = false; | ||
1821 | } | ||
1822 | else | ||
1823 | { | ||
1800 | permissionToTakeCopy = false; | 1824 | permissionToTakeCopy = false; |
1801 | 1825 | } | |
1802 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 1826 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1803 | permissionToTake = false; | 1827 | permissionToTake = false; |
1804 | 1828 | ||
1805 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 1829 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
1806 | permissionToDelete = false; | 1830 | permissionToDelete = false; |
1807 | } | 1831 | } |
1808 | } | ||
1809 | 1832 | ||
1810 | // Handle god perms | 1833 | // Handle god perms |
1811 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 1834 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
1812 | { | 1835 | { |
1813 | permissionToTake = true; | 1836 | permissionToTake = true; |
1814 | permissionToTakeCopy = true; | 1837 | permissionToTakeCopy = true; |
1815 | permissionToDelete = true; | 1838 | permissionToDelete = true; |
1816 | } | 1839 | } |
1817 | 1840 | ||
1818 | // If we're re-saving, we don't even want to delete | 1841 | // If we're re-saving, we don't even want to delete |
1819 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | 1842 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
1820 | permissionToDelete = false; | 1843 | permissionToDelete = false; |
1821 | 1844 | ||
1822 | // if we want to take a copy, we also don't want to delete | 1845 | // if we want to take a copy, we also don't want to delete |
1823 | // Note: after this point, the permissionToTakeCopy flag | 1846 | // Note: after this point, the permissionToTakeCopy flag |
1824 | // becomes irrelevant. It already includes the permissionToTake | 1847 | // becomes irrelevant. It already includes the permissionToTake |
1825 | // permission and after excluding no copy items here, we can | 1848 | // permission and after excluding no copy items here, we can |
1826 | // just use that. | 1849 | // just use that. |
1827 | if (action == DeRezAction.TakeCopy) | 1850 | if (action == DeRezAction.TakeCopy) |
1828 | { | 1851 | { |
1829 | // If we don't have permission, stop right here | 1852 | // If we don't have permission, stop right here |
1830 | if (!permissionToTakeCopy) | 1853 | if (!permissionToTakeCopy) |
1831 | return; | 1854 | return; |
1832 | 1855 | ||
1833 | permissionToTake = true; | 1856 | permissionToTake = true; |
1834 | // Don't delete | 1857 | // Don't delete |
1835 | permissionToDelete = false; | 1858 | permissionToDelete = false; |
1836 | } | 1859 | } |
1837 | 1860 | ||
1838 | if (action == DeRezAction.Return) | 1861 | if (action == DeRezAction.Return) |
1839 | { | ||
1840 | if (remoteClient != null) | ||
1841 | { | 1862 | { |
1842 | if (Permissions.CanReturnObjects( | 1863 | if (remoteClient != null) |
1843 | null, | ||
1844 | remoteClient.AgentId, | ||
1845 | deleteGroups)) | ||
1846 | { | 1864 | { |
1847 | permissionToTake = true; | 1865 | if (Permissions.CanReturnObjects( |
1848 | permissionToDelete = true; | 1866 | null, |
1849 | 1867 | remoteClient.AgentId, | |
1850 | foreach (SceneObjectGroup g in deleteGroups) | 1868 | deleteGroups)) |
1851 | { | 1869 | { |
1852 | AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 1870 | permissionToTake = true; |
1871 | permissionToDelete = true; | ||
1872 | |||
1873 | AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
1853 | } | 1874 | } |
1854 | } | 1875 | } |
1876 | else // Auto return passes through here with null agent | ||
1877 | { | ||
1878 | permissionToTake = true; | ||
1879 | permissionToDelete = true; | ||
1880 | } | ||
1855 | } | 1881 | } |
1856 | else // Auto return passes through here with null agent | 1882 | |
1883 | if (permissionToTake && (!permissionToDelete)) | ||
1884 | takeGroups.Add(grp); | ||
1885 | |||
1886 | if (permissionToDelete) | ||
1857 | { | 1887 | { |
1858 | permissionToTake = true; | 1888 | if (permissionToTake) |
1859 | permissionToDelete = true; | 1889 | deleteGroups.Add(grp); |
1890 | deleteIDs.Add(grp.LocalId); | ||
1860 | } | 1891 | } |
1861 | } | 1892 | } |
1862 | 1893 | ||
1863 | if (permissionToTake) | 1894 | SendKillObject(deleteIDs); |
1895 | |||
1896 | if (deleteGroups.Count > 0) | ||
1864 | { | 1897 | { |
1898 | foreach (SceneObjectGroup g in deleteGroups) | ||
1899 | deleteIDs.Remove(g.LocalId); | ||
1900 | |||
1865 | m_asyncSceneObjectDeleter.DeleteToInventory( | 1901 | m_asyncSceneObjectDeleter.DeleteToInventory( |
1866 | action, destinationID, deleteGroups, remoteClient, | 1902 | action, destinationID, deleteGroups, remoteClient, |
1867 | permissionToDelete); | 1903 | true); |
1868 | } | 1904 | } |
1869 | else if (permissionToDelete) | 1905 | if (takeGroups.Count > 0) |
1906 | { | ||
1907 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
1908 | action, destinationID, takeGroups, remoteClient, | ||
1909 | false); | ||
1910 | } | ||
1911 | if (deleteIDs.Count > 0) | ||
1870 | { | 1912 | { |
1871 | foreach (SceneObjectGroup g in deleteGroups) | 1913 | foreach (SceneObjectGroup g in deleteGroups) |
1872 | DeleteSceneObject(g, false); | 1914 | DeleteSceneObject(g, true); |
1915 | } | ||
1916 | } | ||
1917 | |||
1918 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
1919 | { | ||
1920 | itemID = UUID.Zero; | ||
1921 | if (grp != null) | ||
1922 | { | ||
1923 | Vector3 inventoryStoredPosition = new Vector3 | ||
1924 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1925 | ? 250 | ||
1926 | : grp.AbsolutePosition.X) | ||
1927 | , | ||
1928 | (grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1929 | ? 250 | ||
1930 | : grp.AbsolutePosition.X, | ||
1931 | grp.AbsolutePosition.Z); | ||
1932 | |||
1933 | Vector3 originalPosition = grp.AbsolutePosition; | ||
1934 | |||
1935 | grp.AbsolutePosition = inventoryStoredPosition; | ||
1936 | |||
1937 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
1938 | |||
1939 | grp.AbsolutePosition = originalPosition; | ||
1940 | |||
1941 | AssetBase asset = CreateAsset( | ||
1942 | grp.GetPartName(grp.LocalId), | ||
1943 | grp.GetPartDescription(grp.LocalId), | ||
1944 | (sbyte)AssetType.Object, | ||
1945 | Utils.StringToBytes(sceneObjectXml), | ||
1946 | remoteClient.AgentId); | ||
1947 | AssetService.Store(asset); | ||
1948 | |||
1949 | InventoryItemBase item = new InventoryItemBase(); | ||
1950 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
1951 | item.CreatorData = grp.RootPart.CreatorData; | ||
1952 | item.Owner = remoteClient.AgentId; | ||
1953 | item.ID = UUID.Random(); | ||
1954 | item.AssetID = asset.FullID; | ||
1955 | item.Description = asset.Description; | ||
1956 | item.Name = asset.Name; | ||
1957 | item.AssetType = asset.Type; | ||
1958 | item.InvType = (int)InventoryType.Object; | ||
1959 | |||
1960 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
1961 | if (folder != null) | ||
1962 | item.Folder = folder.ID; | ||
1963 | else // oopsies | ||
1964 | item.Folder = UUID.Zero; | ||
1965 | |||
1966 | // Set up base perms properly | ||
1967 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
1968 | permsBase &= grp.RootPart.BaseMask; | ||
1969 | permsBase |= (uint)PermissionMask.Move; | ||
1970 | |||
1971 | // Make sure we don't lock it | ||
1972 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
1973 | |||
1974 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
1975 | { | ||
1976 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1977 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1978 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1979 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
1980 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
1981 | } | ||
1982 | else | ||
1983 | { | ||
1984 | item.BasePermissions = permsBase; | ||
1985 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
1986 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1987 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
1988 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
1989 | } | ||
1990 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
1991 | |||
1992 | // sets itemID so client can show item as 'attached' in inventory | ||
1993 | grp.SetFromItemID(item.ID); | ||
1994 | |||
1995 | if (AddInventoryItem(item)) | ||
1996 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
1997 | else | ||
1998 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
1999 | |||
2000 | itemID = item.ID; | ||
2001 | return item.AssetID; | ||
1873 | } | 2002 | } |
2003 | return UUID.Zero; | ||
1874 | } | 2004 | } |
1875 | 2005 | ||
1876 | /// <summary> | 2006 | /// <summary> |
@@ -1999,6 +2129,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1999 | 2129 | ||
2000 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2130 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2001 | { | 2131 | { |
2132 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2133 | return; | ||
2134 | |||
2002 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2135 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2003 | if (part == null) | 2136 | if (part == null) |
2004 | return; | 2137 | return; |