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 663aa22..53f0f2e 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.SendPropertiesToClient(remoteClient); | 264 | part.SendPropertiesToClient(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; |
@@ -351,6 +333,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
351 | { | 333 | { |
352 | if (UUID.Zero == transactionID) | 334 | if (UUID.Zero == transactionID) |
353 | { | 335 | { |
336 | item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); | ||
354 | item.Name = itemUpd.Name; | 337 | item.Name = itemUpd.Name; |
355 | item.Description = itemUpd.Description; | 338 | item.Description = itemUpd.Description; |
356 | if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) | 339 | if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions)) |
@@ -728,6 +711,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
728 | return; | 711 | return; |
729 | } | 712 | } |
730 | 713 | ||
714 | if (newName == null) newName = item.Name; | ||
715 | |||
731 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 716 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
732 | 717 | ||
733 | if (asset != null) | 718 | if (asset != null) |
@@ -784,6 +769,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
784 | } | 769 | } |
785 | 770 | ||
786 | /// <summary> | 771 | /// <summary> |
772 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
773 | /// </summary> | ||
774 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
775 | { | ||
776 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
777 | foreach (InventoryItemBase b in items) | ||
778 | { | ||
779 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
780 | InventoryItemBase n = InventoryService.GetItem(b); | ||
781 | n.Folder = destfolder; | ||
782 | moveitems.Add(n); | ||
783 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
784 | } | ||
785 | |||
786 | MoveInventoryItem(remoteClient, moveitems); | ||
787 | } | ||
788 | |||
789 | /// <summary> | ||
787 | /// Move an item within the agent's inventory. | 790 | /// Move an item within the agent's inventory. |
788 | /// </summary> | 791 | /// </summary> |
789 | /// <param name="remoteClient"></param> | 792 | /// <param name="remoteClient"></param> |
@@ -984,25 +987,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
984 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 987 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
985 | { | 988 | { |
986 | SceneObjectPart part = GetSceneObjectPart(localID); | 989 | SceneObjectPart part = GetSceneObjectPart(localID); |
987 | if (part == null) | 990 | SceneObjectGroup group = null; |
988 | return; | 991 | if (part != null) |
992 | { | ||
993 | group = part.ParentGroup; | ||
994 | } | ||
995 | if (part != null && group != null) | ||
996 | { | ||
997 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | ||
998 | return; | ||
989 | 999 | ||
990 | SceneObjectGroup group = part.ParentGroup; | 1000 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); |
991 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | 1001 | if (item == null) |
992 | return; | 1002 | return; |
993 | |||
994 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); | ||
995 | if (item == null) | ||
996 | return; | ||
997 | 1003 | ||
998 | if (item.Type == 10) | 1004 | if (item.Type == 10) |
999 | { | 1005 | { |
1000 | part.RemoveScriptEvents(itemID); | 1006 | part.RemoveScriptEvents(itemID); |
1001 | EventManager.TriggerRemoveScript(localID, itemID); | 1007 | EventManager.TriggerRemoveScript(localID, itemID); |
1008 | } | ||
1009 | |||
1010 | group.RemoveInventoryItem(localID, itemID); | ||
1011 | part.SendPropertiesToClient(remoteClient); | ||
1002 | } | 1012 | } |
1003 | |||
1004 | group.RemoveInventoryItem(localID, itemID); | ||
1005 | part.SendPropertiesToClient(remoteClient); | ||
1006 | } | 1013 | } |
1007 | 1014 | ||
1008 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) | 1015 | private InventoryItemBase CreateAgentInventoryItemFromTask(UUID destAgent, SceneObjectPart part, UUID itemId) |
@@ -1213,6 +1220,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1213 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) | 1220 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) |
1214 | return; | 1221 | return; |
1215 | 1222 | ||
1223 | bool overrideNoMod = false; | ||
1224 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1225 | overrideNoMod = true; | ||
1226 | |||
1216 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | 1227 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) |
1217 | { | 1228 | { |
1218 | // object cannot copy items to an object owned by a different owner | 1229 | // object cannot copy items to an object owned by a different owner |
@@ -1222,7 +1233,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1222 | } | 1233 | } |
1223 | 1234 | ||
1224 | // must have both move and modify permission to put an item in an object | 1235 | // must have both move and modify permission to put an item in an object |
1225 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1236 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1226 | { | 1237 | { |
1227 | return; | 1238 | return; |
1228 | } | 1239 | } |
@@ -1281,6 +1292,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | 1292 | ||
1282 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1293 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1283 | { | 1294 | { |
1295 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1296 | if (destPart != null) // Move into a prim | ||
1297 | { | ||
1298 | foreach(UUID itemID in items) | ||
1299 | MoveTaskInventoryItem(destID, host, itemID); | ||
1300 | return destID; // Prim folder ID == prim ID | ||
1301 | } | ||
1302 | |||
1284 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1303 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1285 | 1304 | ||
1286 | UUID newFolderID = UUID.Random(); | 1305 | UUID newFolderID = UUID.Random(); |
@@ -1460,13 +1479,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1460 | { | 1479 | { |
1461 | agentTransactions.HandleTaskItemUpdateFromTransaction( | 1480 | agentTransactions.HandleTaskItemUpdateFromTransaction( |
1462 | remoteClient, part, transactionID, currentItem); | 1481 | remoteClient, part, transactionID, currentItem); |
1463 | |||
1464 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | ||
1465 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
1466 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | ||
1467 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
1468 | else | ||
1469 | remoteClient.SendAgentAlertMessage("Item saved", false); | ||
1470 | } | 1482 | } |
1471 | 1483 | ||
1472 | // Base ALWAYS has move | 1484 | // Base ALWAYS has move |
@@ -1607,7 +1619,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1607 | return; | 1619 | return; |
1608 | 1620 | ||
1609 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1621 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1610 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1622 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1611 | remoteClient.AgentId); | 1623 | remoteClient.AgentId); |
1612 | AssetService.Store(asset); | 1624 | AssetService.Store(asset); |
1613 | 1625 | ||
@@ -1760,23 +1772,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1760 | // build a list of eligible objects | 1772 | // build a list of eligible objects |
1761 | List<uint> deleteIDs = new List<uint>(); | 1773 | List<uint> deleteIDs = new List<uint>(); |
1762 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 1774 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
1763 | 1775 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
1764 | // Start with true for both, then remove the flags if objects | ||
1765 | // that we can't derez are part of the selection | ||
1766 | bool permissionToTake = true; | ||
1767 | bool permissionToTakeCopy = true; | ||
1768 | bool permissionToDelete = true; | ||
1769 | 1776 | ||
1770 | foreach (uint localID in localIDs) | 1777 | foreach (uint localID in localIDs) |
1771 | { | 1778 | { |
1779 | // Start with true for both, then remove the flags if objects | ||
1780 | // that we can't derez are part of the selection | ||
1781 | bool permissionToTake = true; | ||
1782 | bool permissionToTakeCopy = true; | ||
1783 | bool permissionToDelete = true; | ||
1784 | |||
1772 | // Invalid id | 1785 | // Invalid id |
1773 | SceneObjectPart part = GetSceneObjectPart(localID); | 1786 | SceneObjectPart part = GetSceneObjectPart(localID); |
1774 | if (part == null) | 1787 | if (part == null) |
1788 | { | ||
1789 | //Client still thinks the object exists, kill it | ||
1790 | deleteIDs.Add(localID); | ||
1775 | continue; | 1791 | continue; |
1792 | } | ||
1776 | 1793 | ||
1777 | // Already deleted by someone else | 1794 | // Already deleted by someone else |
1778 | if (part.ParentGroup.IsDeleted) | 1795 | if (part.ParentGroup.IsDeleted) |
1796 | { | ||
1797 | //Client still thinks the object exists, kill it | ||
1798 | deleteIDs.Add(localID); | ||
1779 | continue; | 1799 | continue; |
1800 | } | ||
1780 | 1801 | ||
1781 | // Can't delete child prims | 1802 | // Can't delete child prims |
1782 | if (part != part.ParentGroup.RootPart) | 1803 | if (part != part.ParentGroup.RootPart) |
@@ -1784,9 +1805,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1784 | 1805 | ||
1785 | SceneObjectGroup grp = part.ParentGroup; | 1806 | SceneObjectGroup grp = part.ParentGroup; |
1786 | 1807 | ||
1787 | deleteIDs.Add(localID); | ||
1788 | deleteGroups.Add(grp); | ||
1789 | |||
1790 | if (remoteClient == null) | 1808 | if (remoteClient == null) |
1791 | { | 1809 | { |
1792 | // Autoreturn has a null client. Nothing else does. So | 1810 | // Autoreturn has a null client. Nothing else does. So |
@@ -1803,81 +1821,193 @@ namespace OpenSim.Region.Framework.Scenes | |||
1803 | } | 1821 | } |
1804 | else | 1822 | else |
1805 | { | 1823 | { |
1806 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 1824 | if (action == DeRezAction.TakeCopy) |
1825 | { | ||
1826 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
1827 | permissionToTakeCopy = false; | ||
1828 | } | ||
1829 | else | ||
1830 | { | ||
1807 | permissionToTakeCopy = false; | 1831 | permissionToTakeCopy = false; |
1808 | 1832 | } | |
1809 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 1833 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1810 | permissionToTake = false; | 1834 | permissionToTake = false; |
1811 | 1835 | ||
1812 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 1836 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
1813 | permissionToDelete = false; | 1837 | permissionToDelete = false; |
1814 | } | 1838 | } |
1815 | } | ||
1816 | 1839 | ||
1817 | // Handle god perms | 1840 | // Handle god perms |
1818 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 1841 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
1819 | { | 1842 | { |
1820 | permissionToTake = true; | 1843 | permissionToTake = true; |
1821 | permissionToTakeCopy = true; | 1844 | permissionToTakeCopy = true; |
1822 | permissionToDelete = true; | 1845 | permissionToDelete = true; |
1823 | } | 1846 | } |
1824 | 1847 | ||
1825 | // If we're re-saving, we don't even want to delete | 1848 | // If we're re-saving, we don't even want to delete |
1826 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | 1849 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
1827 | permissionToDelete = false; | 1850 | permissionToDelete = false; |
1828 | 1851 | ||
1829 | // if we want to take a copy, we also don't want to delete | 1852 | // if we want to take a copy, we also don't want to delete |
1830 | // Note: after this point, the permissionToTakeCopy flag | 1853 | // Note: after this point, the permissionToTakeCopy flag |
1831 | // becomes irrelevant. It already includes the permissionToTake | 1854 | // becomes irrelevant. It already includes the permissionToTake |
1832 | // permission and after excluding no copy items here, we can | 1855 | // permission and after excluding no copy items here, we can |
1833 | // just use that. | 1856 | // just use that. |
1834 | if (action == DeRezAction.TakeCopy) | 1857 | if (action == DeRezAction.TakeCopy) |
1835 | { | 1858 | { |
1836 | // If we don't have permission, stop right here | 1859 | // If we don't have permission, stop right here |
1837 | if (!permissionToTakeCopy) | 1860 | if (!permissionToTakeCopy) |
1838 | return; | 1861 | return; |
1839 | 1862 | ||
1840 | permissionToTake = true; | 1863 | permissionToTake = true; |
1841 | // Don't delete | 1864 | // Don't delete |
1842 | permissionToDelete = false; | 1865 | permissionToDelete = false; |
1843 | } | 1866 | } |
1844 | 1867 | ||
1845 | if (action == DeRezAction.Return) | 1868 | if (action == DeRezAction.Return) |
1846 | { | ||
1847 | if (remoteClient != null) | ||
1848 | { | 1869 | { |
1849 | if (Permissions.CanReturnObjects( | 1870 | if (remoteClient != null) |
1850 | null, | ||
1851 | remoteClient.AgentId, | ||
1852 | deleteGroups)) | ||
1853 | { | 1871 | { |
1854 | permissionToTake = true; | 1872 | if (Permissions.CanReturnObjects( |
1855 | permissionToDelete = true; | 1873 | null, |
1856 | 1874 | remoteClient.AgentId, | |
1857 | foreach (SceneObjectGroup g in deleteGroups) | 1875 | deleteGroups)) |
1858 | { | 1876 | { |
1859 | AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 1877 | permissionToTake = true; |
1878 | permissionToDelete = true; | ||
1879 | |||
1880 | AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
1860 | } | 1881 | } |
1861 | } | 1882 | } |
1883 | else // Auto return passes through here with null agent | ||
1884 | { | ||
1885 | permissionToTake = true; | ||
1886 | permissionToDelete = true; | ||
1887 | } | ||
1862 | } | 1888 | } |
1863 | else // Auto return passes through here with null agent | 1889 | |
1890 | if (permissionToTake && (!permissionToDelete)) | ||
1891 | takeGroups.Add(grp); | ||
1892 | |||
1893 | if (permissionToDelete) | ||
1864 | { | 1894 | { |
1865 | permissionToTake = true; | 1895 | if (permissionToTake) |
1866 | permissionToDelete = true; | 1896 | deleteGroups.Add(grp); |
1897 | deleteIDs.Add(grp.LocalId); | ||
1867 | } | 1898 | } |
1868 | } | 1899 | } |
1869 | 1900 | ||
1870 | if (permissionToTake) | 1901 | SendKillObject(deleteIDs); |
1902 | |||
1903 | if (deleteGroups.Count > 0) | ||
1871 | { | 1904 | { |
1905 | foreach (SceneObjectGroup g in deleteGroups) | ||
1906 | deleteIDs.Remove(g.LocalId); | ||
1907 | |||
1872 | m_asyncSceneObjectDeleter.DeleteToInventory( | 1908 | m_asyncSceneObjectDeleter.DeleteToInventory( |
1873 | action, destinationID, deleteGroups, remoteClient, | 1909 | action, destinationID, deleteGroups, remoteClient, |
1874 | permissionToDelete); | 1910 | true); |
1875 | } | 1911 | } |
1876 | else if (permissionToDelete) | 1912 | if (takeGroups.Count > 0) |
1913 | { | ||
1914 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
1915 | action, destinationID, takeGroups, remoteClient, | ||
1916 | false); | ||
1917 | } | ||
1918 | if (deleteIDs.Count > 0) | ||
1877 | { | 1919 | { |
1878 | foreach (SceneObjectGroup g in deleteGroups) | 1920 | foreach (SceneObjectGroup g in deleteGroups) |
1879 | DeleteSceneObject(g, false); | 1921 | DeleteSceneObject(g, true); |
1922 | } | ||
1923 | } | ||
1924 | |||
1925 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
1926 | { | ||
1927 | itemID = UUID.Zero; | ||
1928 | if (grp != null) | ||
1929 | { | ||
1930 | Vector3 inventoryStoredPosition = new Vector3 | ||
1931 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1932 | ? 250 | ||
1933 | : grp.AbsolutePosition.X) | ||
1934 | , | ||
1935 | (grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1936 | ? 250 | ||
1937 | : grp.AbsolutePosition.X, | ||
1938 | grp.AbsolutePosition.Z); | ||
1939 | |||
1940 | Vector3 originalPosition = grp.AbsolutePosition; | ||
1941 | |||
1942 | grp.AbsolutePosition = inventoryStoredPosition; | ||
1943 | |||
1944 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
1945 | |||
1946 | grp.AbsolutePosition = originalPosition; | ||
1947 | |||
1948 | AssetBase asset = CreateAsset( | ||
1949 | grp.GetPartName(grp.LocalId), | ||
1950 | grp.GetPartDescription(grp.LocalId), | ||
1951 | (sbyte)AssetType.Object, | ||
1952 | Utils.StringToBytes(sceneObjectXml), | ||
1953 | remoteClient.AgentId); | ||
1954 | AssetService.Store(asset); | ||
1955 | |||
1956 | InventoryItemBase item = new InventoryItemBase(); | ||
1957 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
1958 | item.CreatorData = grp.RootPart.CreatorData; | ||
1959 | item.Owner = remoteClient.AgentId; | ||
1960 | item.ID = UUID.Random(); | ||
1961 | item.AssetID = asset.FullID; | ||
1962 | item.Description = asset.Description; | ||
1963 | item.Name = asset.Name; | ||
1964 | item.AssetType = asset.Type; | ||
1965 | item.InvType = (int)InventoryType.Object; | ||
1966 | |||
1967 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
1968 | if (folder != null) | ||
1969 | item.Folder = folder.ID; | ||
1970 | else // oopsies | ||
1971 | item.Folder = UUID.Zero; | ||
1972 | |||
1973 | // Set up base perms properly | ||
1974 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
1975 | permsBase &= grp.RootPart.BaseMask; | ||
1976 | permsBase |= (uint)PermissionMask.Move; | ||
1977 | |||
1978 | // Make sure we don't lock it | ||
1979 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
1980 | |||
1981 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
1982 | { | ||
1983 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1984 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1985 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1986 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
1987 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
1988 | } | ||
1989 | else | ||
1990 | { | ||
1991 | item.BasePermissions = permsBase; | ||
1992 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
1993 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
1994 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
1995 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
1996 | } | ||
1997 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
1998 | |||
1999 | // sets itemID so client can show item as 'attached' in inventory | ||
2000 | grp.SetFromItemID(item.ID); | ||
2001 | |||
2002 | if (AddInventoryItem(item)) | ||
2003 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
2004 | else | ||
2005 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
2006 | |||
2007 | itemID = item.ID; | ||
2008 | return item.AssetID; | ||
1880 | } | 2009 | } |
2010 | return UUID.Zero; | ||
1881 | } | 2011 | } |
1882 | 2012 | ||
1883 | /// <summary> | 2013 | /// <summary> |
@@ -2006,6 +2136,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2006 | 2136 | ||
2007 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2137 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2008 | { | 2138 | { |
2139 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2140 | return; | ||
2141 | |||
2009 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2142 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2010 | if (part == null) | 2143 | if (part == null) |
2011 | return; | 2144 | return; |