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