diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 344 |
1 files changed, 234 insertions, 110 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index dd3208a..817736f 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 | { | ||
125 | // m_log.DebugFormat( | ||
126 | // "[LOCAL INVENTORY SERVICES CONNECTOR]: Found folder {0} type {1} for item {2}", | ||
127 | // f.Name, (AssetType)f.Type, item.Name); | ||
128 | |||
129 | item.Folder = f.ID; | ||
130 | } | ||
131 | else | ||
132 | { | 126 | { |
133 | f = InventoryService.GetRootFolder(item.Owner); | 127 | folder = InventoryService.GetRootFolder(item.Owner); |
134 | if (f != null) | 128 | |
135 | { | 129 | if (folder == null) |
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> |
@@ -1121,6 +1124,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1121 | { | 1124 | { |
1122 | SceneObjectPart part = GetSceneObjectPart(primLocalId); | 1125 | SceneObjectPart part = GetSceneObjectPart(primLocalId); |
1123 | 1126 | ||
1127 | // Can't move a null item | ||
1128 | if (itemId == UUID.Zero) | ||
1129 | return; | ||
1130 | |||
1124 | if (null == part) | 1131 | if (null == part) |
1125 | { | 1132 | { |
1126 | m_log.WarnFormat( | 1133 | m_log.WarnFormat( |
@@ -1231,6 +1238,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1231 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) | 1238 | if ((part.OwnerID != destPart.OwnerID) && ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0)) |
1232 | return; | 1239 | return; |
1233 | 1240 | ||
1241 | bool overrideNoMod = false; | ||
1242 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1243 | overrideNoMod = true; | ||
1244 | |||
1234 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | 1245 | if (part.OwnerID != destPart.OwnerID && (part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) |
1235 | { | 1246 | { |
1236 | // object cannot copy items to an object owned by a different owner | 1247 | // object cannot copy items to an object owned by a different owner |
@@ -1240,7 +1251,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1240 | } | 1251 | } |
1241 | 1252 | ||
1242 | // must have both move and modify permission to put an item in an object | 1253 | // must have both move and modify permission to put an item in an object |
1243 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1254 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1244 | { | 1255 | { |
1245 | return; | 1256 | return; |
1246 | } | 1257 | } |
@@ -1299,6 +1310,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1299 | 1310 | ||
1300 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1311 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1301 | { | 1312 | { |
1313 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1314 | if (destPart != null) // Move into a prim | ||
1315 | { | ||
1316 | foreach(UUID itemID in items) | ||
1317 | MoveTaskInventoryItem(destID, host, itemID); | ||
1318 | return destID; // Prim folder ID == prim ID | ||
1319 | } | ||
1320 | |||
1302 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1321 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1303 | 1322 | ||
1304 | UUID newFolderID = UUID.Random(); | 1323 | UUID newFolderID = UUID.Random(); |
@@ -1472,28 +1491,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1472 | // m_log.DebugFormat( | 1491 | // m_log.DebugFormat( |
1473 | // "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", | 1492 | // "[PRIM INVENTORY]: Updating item {0} in {1} for UpdateTaskInventory()", |
1474 | // currentItem.Name, part.Name); | 1493 | // currentItem.Name, part.Name); |
1475 | 1494 | IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); | |
1476 | // Viewers from at least Linden Lab 1.23 onwards use a capability to update script contents rather | 1495 | if (agentTransactions != null) |
1477 | // than UDP. With viewers from at least 1.23 onwards, changing properties on scripts (e.g. renaming) causes | 1496 | { |
1478 | // this to spew spurious errors and "thing saved" messages. | 1497 | agentTransactions.HandleTaskItemUpdateFromTransaction( |
1479 | // Rather than retaining complexity in the code and removing useful error messages, I'm going to | 1498 | remoteClient, part, transactionID, currentItem); |
1480 | // comment this section out. If this was still working for very old viewers and there is | 1499 | } |
1481 | // a large population using them which cannot upgrade to 1.23 or derivatives then we can revisit | ||
1482 | // this - justincc | ||
1483 | // IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>(); | ||
1484 | // if (agentTransactions != null) | ||
1485 | // { | ||
1486 | // agentTransactions.HandleTaskItemUpdateFromTransaction( | ||
1487 | // remoteClient, part, transactionID, currentItem); | ||
1488 | // | ||
1489 | // if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | ||
1490 | // remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
1491 | // else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | ||
1492 | // remoteClient.SendAgentAlertMessage("Script saved", false); | ||
1493 | // else | ||
1494 | // remoteClient.SendAgentAlertMessage("Item saved", false); | ||
1495 | // } | ||
1496 | |||
1497 | // Base ALWAYS has move | 1500 | // Base ALWAYS has move |
1498 | currentItem.BasePermissions |= (uint)PermissionMask.Move; | 1501 | currentItem.BasePermissions |= (uint)PermissionMask.Move; |
1499 | 1502 | ||
@@ -1670,7 +1673,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1670 | } | 1673 | } |
1671 | 1674 | ||
1672 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1675 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1673 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1676 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1674 | agentID); | 1677 | agentID); |
1675 | AssetService.Store(asset); | 1678 | AssetService.Store(asset); |
1676 | 1679 | ||
@@ -1822,23 +1825,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1822 | // build a list of eligible objects | 1825 | // build a list of eligible objects |
1823 | List<uint> deleteIDs = new List<uint>(); | 1826 | List<uint> deleteIDs = new List<uint>(); |
1824 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 1827 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
1825 | 1828 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
1826 | // Start with true for both, then remove the flags if objects | ||
1827 | // that we can't derez are part of the selection | ||
1828 | bool permissionToTake = true; | ||
1829 | bool permissionToTakeCopy = true; | ||
1830 | bool permissionToDelete = true; | ||
1831 | 1829 | ||
1832 | foreach (uint localID in localIDs) | 1830 | foreach (uint localID in localIDs) |
1833 | { | 1831 | { |
1832 | // Start with true for both, then remove the flags if objects | ||
1833 | // that we can't derez are part of the selection | ||
1834 | bool permissionToTake = true; | ||
1835 | bool permissionToTakeCopy = true; | ||
1836 | bool permissionToDelete = true; | ||
1837 | |||
1834 | // Invalid id | 1838 | // Invalid id |
1835 | SceneObjectPart part = GetSceneObjectPart(localID); | 1839 | SceneObjectPart part = GetSceneObjectPart(localID); |
1836 | if (part == null) | 1840 | if (part == null) |
1841 | { | ||
1842 | //Client still thinks the object exists, kill it | ||
1843 | deleteIDs.Add(localID); | ||
1837 | continue; | 1844 | continue; |
1845 | } | ||
1838 | 1846 | ||
1839 | // Already deleted by someone else | 1847 | // Already deleted by someone else |
1840 | if (part.ParentGroup.IsDeleted) | 1848 | if (part.ParentGroup.IsDeleted) |
1849 | { | ||
1850 | //Client still thinks the object exists, kill it | ||
1851 | deleteIDs.Add(localID); | ||
1841 | continue; | 1852 | continue; |
1853 | } | ||
1842 | 1854 | ||
1843 | // Can't delete child prims | 1855 | // Can't delete child prims |
1844 | if (part != part.ParentGroup.RootPart) | 1856 | if (part != part.ParentGroup.RootPart) |
@@ -1846,9 +1858,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1846 | 1858 | ||
1847 | SceneObjectGroup grp = part.ParentGroup; | 1859 | SceneObjectGroup grp = part.ParentGroup; |
1848 | 1860 | ||
1849 | deleteIDs.Add(localID); | ||
1850 | deleteGroups.Add(grp); | ||
1851 | |||
1852 | if (remoteClient == null) | 1861 | if (remoteClient == null) |
1853 | { | 1862 | { |
1854 | // Autoreturn has a null client. Nothing else does. So | 1863 | // Autoreturn has a null client. Nothing else does. So |
@@ -1865,81 +1874,193 @@ namespace OpenSim.Region.Framework.Scenes | |||
1865 | } | 1874 | } |
1866 | else | 1875 | else |
1867 | { | 1876 | { |
1868 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 1877 | if (action == DeRezAction.TakeCopy) |
1878 | { | ||
1879 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
1880 | permissionToTakeCopy = false; | ||
1881 | } | ||
1882 | else | ||
1883 | { | ||
1869 | permissionToTakeCopy = false; | 1884 | permissionToTakeCopy = false; |
1870 | 1885 | } | |
1871 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 1886 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1872 | permissionToTake = false; | 1887 | permissionToTake = false; |
1873 | 1888 | ||
1874 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 1889 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
1875 | permissionToDelete = false; | 1890 | permissionToDelete = false; |
1876 | } | 1891 | } |
1877 | } | ||
1878 | 1892 | ||
1879 | // Handle god perms | 1893 | // Handle god perms |
1880 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 1894 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
1881 | { | 1895 | { |
1882 | permissionToTake = true; | 1896 | permissionToTake = true; |
1883 | permissionToTakeCopy = true; | 1897 | permissionToTakeCopy = true; |
1884 | permissionToDelete = true; | 1898 | permissionToDelete = true; |
1885 | } | 1899 | } |
1886 | 1900 | ||
1887 | // If we're re-saving, we don't even want to delete | 1901 | // If we're re-saving, we don't even want to delete |
1888 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | 1902 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
1889 | permissionToDelete = false; | 1903 | permissionToDelete = false; |
1890 | 1904 | ||
1891 | // if we want to take a copy, we also don't want to delete | 1905 | // if we want to take a copy, we also don't want to delete |
1892 | // Note: after this point, the permissionToTakeCopy flag | 1906 | // Note: after this point, the permissionToTakeCopy flag |
1893 | // becomes irrelevant. It already includes the permissionToTake | 1907 | // becomes irrelevant. It already includes the permissionToTake |
1894 | // permission and after excluding no copy items here, we can | 1908 | // permission and after excluding no copy items here, we can |
1895 | // just use that. | 1909 | // just use that. |
1896 | if (action == DeRezAction.TakeCopy) | 1910 | if (action == DeRezAction.TakeCopy) |
1897 | { | 1911 | { |
1898 | // If we don't have permission, stop right here | 1912 | // If we don't have permission, stop right here |
1899 | if (!permissionToTakeCopy) | 1913 | if (!permissionToTakeCopy) |
1900 | return; | 1914 | return; |
1901 | 1915 | ||
1902 | permissionToTake = true; | 1916 | permissionToTake = true; |
1903 | // Don't delete | 1917 | // Don't delete |
1904 | permissionToDelete = false; | 1918 | permissionToDelete = false; |
1905 | } | 1919 | } |
1906 | 1920 | ||
1907 | if (action == DeRezAction.Return) | 1921 | if (action == DeRezAction.Return) |
1908 | { | ||
1909 | if (remoteClient != null) | ||
1910 | { | 1922 | { |
1911 | if (Permissions.CanReturnObjects( | 1923 | if (remoteClient != null) |
1912 | null, | ||
1913 | remoteClient.AgentId, | ||
1914 | deleteGroups)) | ||
1915 | { | 1924 | { |
1916 | permissionToTake = true; | 1925 | if (Permissions.CanReturnObjects( |
1917 | permissionToDelete = true; | 1926 | null, |
1918 | 1927 | remoteClient.AgentId, | |
1919 | foreach (SceneObjectGroup g in deleteGroups) | 1928 | deleteGroups)) |
1920 | { | 1929 | { |
1921 | AddReturn(g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 1930 | permissionToTake = true; |
1931 | permissionToDelete = true; | ||
1932 | |||
1933 | AddReturn(grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
1922 | } | 1934 | } |
1923 | } | 1935 | } |
1936 | else // Auto return passes through here with null agent | ||
1937 | { | ||
1938 | permissionToTake = true; | ||
1939 | permissionToDelete = true; | ||
1940 | } | ||
1924 | } | 1941 | } |
1925 | else // Auto return passes through here with null agent | 1942 | |
1943 | if (permissionToTake && (!permissionToDelete)) | ||
1944 | takeGroups.Add(grp); | ||
1945 | |||
1946 | if (permissionToDelete) | ||
1926 | { | 1947 | { |
1927 | permissionToTake = true; | 1948 | if (permissionToTake) |
1928 | permissionToDelete = true; | 1949 | deleteGroups.Add(grp); |
1950 | deleteIDs.Add(grp.LocalId); | ||
1929 | } | 1951 | } |
1930 | } | 1952 | } |
1931 | 1953 | ||
1932 | if (permissionToTake) | 1954 | SendKillObject(deleteIDs); |
1955 | |||
1956 | if (deleteGroups.Count > 0) | ||
1933 | { | 1957 | { |
1958 | foreach (SceneObjectGroup g in deleteGroups) | ||
1959 | deleteIDs.Remove(g.LocalId); | ||
1960 | |||
1934 | m_asyncSceneObjectDeleter.DeleteToInventory( | 1961 | m_asyncSceneObjectDeleter.DeleteToInventory( |
1935 | action, destinationID, deleteGroups, remoteClient, | 1962 | action, destinationID, deleteGroups, remoteClient, |
1936 | permissionToDelete); | 1963 | true); |
1937 | } | 1964 | } |
1938 | else if (permissionToDelete) | 1965 | if (takeGroups.Count > 0) |
1966 | { | ||
1967 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
1968 | action, destinationID, takeGroups, remoteClient, | ||
1969 | false); | ||
1970 | } | ||
1971 | if (deleteIDs.Count > 0) | ||
1939 | { | 1972 | { |
1940 | foreach (SceneObjectGroup g in deleteGroups) | 1973 | foreach (SceneObjectGroup g in deleteGroups) |
1941 | DeleteSceneObject(g, false); | 1974 | DeleteSceneObject(g, true); |
1975 | } | ||
1976 | } | ||
1977 | |||
1978 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
1979 | { | ||
1980 | itemID = UUID.Zero; | ||
1981 | if (grp != null) | ||
1982 | { | ||
1983 | Vector3 inventoryStoredPosition = new Vector3 | ||
1984 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1985 | ? 250 | ||
1986 | : grp.AbsolutePosition.X) | ||
1987 | , | ||
1988 | (grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1989 | ? 250 | ||
1990 | : grp.AbsolutePosition.X, | ||
1991 | grp.AbsolutePosition.Z); | ||
1992 | |||
1993 | Vector3 originalPosition = grp.AbsolutePosition; | ||
1994 | |||
1995 | grp.AbsolutePosition = inventoryStoredPosition; | ||
1996 | |||
1997 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
1998 | |||
1999 | grp.AbsolutePosition = originalPosition; | ||
2000 | |||
2001 | AssetBase asset = CreateAsset( | ||
2002 | grp.GetPartName(grp.LocalId), | ||
2003 | grp.GetPartDescription(grp.LocalId), | ||
2004 | (sbyte)AssetType.Object, | ||
2005 | Utils.StringToBytes(sceneObjectXml), | ||
2006 | remoteClient.AgentId); | ||
2007 | AssetService.Store(asset); | ||
2008 | |||
2009 | InventoryItemBase item = new InventoryItemBase(); | ||
2010 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
2011 | item.CreatorData = grp.RootPart.CreatorData; | ||
2012 | item.Owner = remoteClient.AgentId; | ||
2013 | item.ID = UUID.Random(); | ||
2014 | item.AssetID = asset.FullID; | ||
2015 | item.Description = asset.Description; | ||
2016 | item.Name = asset.Name; | ||
2017 | item.AssetType = asset.Type; | ||
2018 | item.InvType = (int)InventoryType.Object; | ||
2019 | |||
2020 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
2021 | if (folder != null) | ||
2022 | item.Folder = folder.ID; | ||
2023 | else // oopsies | ||
2024 | item.Folder = UUID.Zero; | ||
2025 | |||
2026 | // Set up base perms properly | ||
2027 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
2028 | permsBase &= grp.RootPart.BaseMask; | ||
2029 | permsBase |= (uint)PermissionMask.Move; | ||
2030 | |||
2031 | // Make sure we don't lock it | ||
2032 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
2033 | |||
2034 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
2035 | { | ||
2036 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2037 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2038 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2039 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
2040 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
2041 | } | ||
2042 | else | ||
2043 | { | ||
2044 | item.BasePermissions = permsBase; | ||
2045 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
2046 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2047 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
2048 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
2049 | } | ||
2050 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
2051 | |||
2052 | // sets itemID so client can show item as 'attached' in inventory | ||
2053 | grp.SetFromItemID(item.ID); | ||
2054 | |||
2055 | if (AddInventoryItem(item)) | ||
2056 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
2057 | else | ||
2058 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
2059 | |||
2060 | itemID = item.ID; | ||
2061 | return item.AssetID; | ||
1942 | } | 2062 | } |
2063 | return UUID.Zero; | ||
1943 | } | 2064 | } |
1944 | 2065 | ||
1945 | /// <summary> | 2066 | /// <summary> |
@@ -2068,6 +2189,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2068 | 2189 | ||
2069 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2190 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2070 | { | 2191 | { |
2192 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2193 | return; | ||
2194 | |||
2071 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2195 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2072 | if (part == null) | 2196 | if (part == null) |
2073 | return; | 2197 | return; |